Skip to content

Instantly share code, notes, and snippets.

@leelasd
Last active January 5, 2016 21:07
Show Gist options
  • Save leelasd/1be159a45b756f0c3776 to your computer and use it in GitHub Desktop.
Save leelasd/1be159a45b756f0c3776 to your computer and use it in GitHub Desktop.
Generating Chemdraw 2d Figures from MOL file or Smiles file. Download SAMPL1_Dataset from https://github.com/leelasd/SAMPL1/blob/master/SAMPL1_Dataset.csv.
## installing dependencies
## conda install boost
## conda install rdkit
## Download SAMPL1 database file from leelasd/SAMPL1 github repo
from __future__ import print_function
from rdkit import Chem
from rdkit.Chem import AllChem,Draw
import pandas as pd
df=pd.read_csv('SAMPL1_Dataset.csv')
mols = [Chem.MolFromSmiles(smi) for smi in df.SMILES]
for m,name in zip(mols,df.NAME):
tmp=AllChem.Compute2DCoords(m)
Draw.MolToFile(m,'SAMPL1/'+name+'.png',size=(300,300),fitImage=True)
@leelasd
Copy link
Author

leelasd commented Jan 5, 2016

Dependencies include

  • Matplotlib
  • Pandas
  • RDkit

It produces output like this
fig_sampl1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment