Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demonstrating using chembl_downloader to get SDF path #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions _notebooks/2021-12-20-substructlibrary-search-order.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,17 @@
"metadata": {},
"source": [
"Here's the code to build the `SubstructLibrary` from the sdf file distributed by the ChEMBL team. \n",
"This uses a feature added in RDKit v2021.09 to allow a molecule key (or name) to be stored with the molecules in a `SubstructLibrary`.\n",
"This uses a feature added in RDKit v2021.09 to allow a molecule key (or name) to be stored with the molecules in a `SubstructLibrary`. Note you'll need to `pip install chembl_downloader` to run this block.\n",
"\n",
"Executing this takes about 45 minutes on my machine."
]
},
{
"cell_type": "raw",
"cell_type": "markdown",
"metadata": {},
"source": [
"```python\n",
"import chembl_downloader\n",
"RDLogger.DisableLog(\"rdApp.warning\")\n",
"\n",
"molholder = rdSubstructLibrary.CachedTrustedSmilesMolHolder()\n",
Expand All @@ -79,7 +81,8 @@
"keys = rdSubstructLibrary.KeyFromPropHolder() \n",
"slib = rdSubstructLibrary.SubstructLibrary(molholder,patts,keys)\n",
"t1 = time.time()\n",
"with gzip.GzipFile('/home/glandrum/Downloads/chembl_29.sdf.gz') as gz, Chem.ForwardSDMolSupplier(gz) as suppl:\n",
"sdf_path = chembl_downloader.download_sdf(version=\"29\")\n",
"with gzip.open(sdf_path) as gz, Chem.ForwardSDMolSupplier(gz) as suppl:\n",
" nDone = 0\n",
" for m in suppl:\n",
" if m is None:\n",
Expand All @@ -96,7 +99,7 @@
"print(f'That took {time.time()-t1:.2f}s in total.')\n",
"with open('./results/chembl29_ssslib.pkl','wb+') as outf:\n",
" pickle.dump(slib,outf)\n",
" "
"```"
]
},
{
Expand Down