Last active
April 5, 2020 11:43
-
-
Save GerardBCN/e42c596c7d9830002b7961950c885c50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from rdkit import Chem\n", | |
"from rdkit.Chem import AllChem\n", | |
"import pandas as pd\n", | |
"from tqdm import tqdm" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"799it [00:09, 85.79it/s] \n" | |
] | |
} | |
], | |
"source": [ | |
"df = pd.read_csv(\"./SAMPL7/protein_ligand/fragments_screened.csv\", header=None)\n", | |
"fragments = df[1].values\n", | |
"mols = []\n", | |
"for i,frag in tqdm(enumerate(fragments), total=len(fragments)):\n", | |
" m = Chem.MolFromSmiles(frag) # Read SMILES\n", | |
" m.SetProp(\"_Name\",\"frag_{}\".format(i)) # Give the molecule a name\n", | |
" m = Chem.AddHs(m) # Add hydrogens\n", | |
" AllChem.EmbedMolecule(m) # Generate 3D coordinates\n", | |
" mols.append(m)\n", | |
"w = Chem.SDWriter('fragments.sdf')\n", | |
"for frag in mols: \n", | |
" w.write(frag)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.8" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment