Skip to content

Commit 84c8608

Browse files
committed
initial public release
0 parents  commit 84c8608

File tree

8 files changed

+1314
-0
lines changed

8 files changed

+1314
-0
lines changed

.gitignore

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/
130+
.vscode/settings.json
131+
.vscode/launch.json
132+
subject_smiles_dictionary*
133+
134+
*.pdf
135+
*.ipynb
136+
*.txt
137+
*.smi

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Kevin Greenman
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# PatentChem
2+
3+
This code downloads the weekly bulk files from the [USPTO](https://developer.uspto.gov/product/patent-grant-dataxml), selects the patents relevant to chemistry, and queries the chemistry patent claims sections for given keywords to find molecule SMILES related to those keywords.
4+
5+
## Installation
6+
```
7+
conda install -c conda-forge mamba
8+
mamba env create -f environment.yml
9+
```
10+
11+
## Example Usage
12+
The scripts should be run in the following order. Steps 1 and 2 only need to be run once, then steps 3 and 4 can be run as many times as desired using different query terms.
13+
14+
15+
### 1. Download
16+
Download all USPTO patents for the given years:
17+
18+
`python download.py --years 2021 --data_dir /data/patents_data/`
19+
20+
Additional options:
21+
* `--remove_compressed`: remove the original .tar and .zip files for the weekly releases after decompressing them
22+
23+
### 2. Select
24+
Select the patents related to chemistry based on the presence of CDX files:
25+
26+
`python select_chem.py --years 2021 --data_dir /data/patents_data/`
27+
28+
Additional options:
29+
* `--remove_compressed`: remove all original .zip files after unzipping those relevant to chemistry
30+
31+
### 3. Search
32+
Provide a list of query terms to search for in the claims sections of the chemistry-related patents:
33+
34+
`python search.py --years 2021 --data_dir /data/patents_data/ --naming opd --subject_list "organic electronic" "photodiode" "organic photovoltaic"`
35+
36+
### 4. Clean
37+
Output a yaml file with the SMILES strings found related to the query terms and all of the patents related to each SMILES. Also output a text file with all unique SMILES strings from the query.
38+
39+
`python clean.py --years 2021 --naming opd`
40+
41+
Additional options:
42+
* `--output_dir`: parent directory of `--naming` if different from `.`
43+
* `--charged_only`: include only charged molecules in output
44+
* `--neutral_only`: include only neutral molecules in output
45+
* `--mw_min`: include only molecules with molecular weight greater than this
46+
* `--mw_max`: include only molecules with molecular weight less than this
47+
48+
## Download File Sizes
49+
50+
The following file sizes are taken from the [USPTO Bulk Data Storage System](https://bulkdata.uspto.gov) using the URLs `https://bulkdata.uspto.gov/data/patent/grant/redbook/<YEAR>/` and converting from bytes to GB. The 2023 file size is as of 10 March 2023. The download speed seems to be restricted to ~5-10MB/s, which means downloading the full set could require > 4 days if done in series. Alternatively, you can run multiple downloads in parallel. Either way, we recommend starting the downloads in a [tmux](https://github.com/tmux/tmux/wiki) session to run in the background. Note that these file sizes are for the *compressed* (zip or tar) files, so the total space required to store this data is larger than what is reported below. Use caution to avoid filling your hard drive to capacity.
51+
52+
| **Year** | **File Size** | **Units** |
53+
|-------|-----------|-------|
54+
| 2001 | 37.07 | GB |
55+
| 2002 | 37.23 | GB |
56+
| 2003 | 39.20 | GB |
57+
| 2004 | 38.95 | GB |
58+
| 2005 | 30.67 | GB |
59+
| 2006 | 39.90 | GB |
60+
| 2007 | 39.98 | GB |
61+
| 2008 | 42.08 | GB |
62+
| 2009 | 43.82 | GB |
63+
| 2010 | 61.65 | GB |
64+
| 2011 | 68.24 | GB |
65+
| 2012 | 85.42 | GB |
66+
| 2013 | 96.55 | GB |
67+
| 2014 | 111.26 | GB |
68+
| 2015 | 119.98 | GB |
69+
| 2016 | 117.42 | GB |
70+
| 2017 | 124.10 | GB |
71+
| 2018 | 148.02 | GB |
72+
| 2019 | 182.28 | GB |
73+
| 2020 | 192.45 | GB |
74+
| 2021 | 184.41 | GB |
75+
| 2022 | 185 | GB |
76+
| 2023 | 39 | GB |
77+
| **Total** | **2.05** | **TB** |
78+
79+
## Notes
80+
* Patent archives from 2001 - 2004 and 2009 follow a different format than other years; this code may not be able to process patents from these years properly.
81+
* For simplicity, `clean.py` replaces "*" and "Y" substituents from Markush structures with ethyl and O groups. This might not be appropriate for your applications.
82+
83+
## Citation
84+
If you use this code, please cite the following [manuscript](): <!-- # TODO: fill in link and rest of bibtex citation -->
85+
```
86+
@article{patents-generative2023,
87+
title={Automated patent extraction powers generative modeling in focused chemical spaces},
88+
author={Subramanian, Akshay and Greenman, Kevin P. and Gervaix, Alexis and Yang, Tzuhsiung and G{\'{o}}mez-Bombarelli, Rafael},
89+
journal={TBD},
90+
doi={TBD},
91+
year={2023}
92+
}
93+
```

0 commit comments

Comments
 (0)