Skip to content

Instantly share code, notes, and snippets.

@jhjensen2
Created November 5, 2016 10:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhjensen2/575785e225d863f6de21f228210e73d9 to your computer and use it in GitHub Desktop.
Save jhjensen2/575785e225d863f6de21f228210e73d9 to your computer and use it in GitHub Desktop.
Converts a SMILES string to a 2D picture
import sys
sys.path.append("/usr/local/lib/python2.7/site-packages/")
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.Chem import Draw
from rdkit.sping import PIL
filename = sys.argv[1]
file = open(filename, "r+")
for line in file:
words = line.split()
name = words[0]
smiles = words[1]
m = Chem.MolFromSmiles(smiles)
Draw.MolToFile(m,name+".png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment