Created
March 10, 2018 07:00
-
-
Save jhjensen2/55c2aaca1dd4134e8ed51a73a30adc6b 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
from rdkit import Chem | |
from rdkit.Chem import Draw | |
from rdkit.Chem.Draw import IPythonConsole | |
import string | |
filename_smiles = "/Users/jan/Desktop/diels_alder.smiles" | |
molecules = [] | |
names = [] | |
with open(filename_smiles, "r") as file: | |
for line in file: | |
if len(line.split()) == 4: | |
name, smiles, energy, filenames = line.split() | |
name = name + " " + energy | |
else: | |
name, smiles = line.split() | |
smiles = string.replace(smiles,".[H][H]","",3) | |
mol = Chem.MolFromSmiles(smiles) | |
names.append(name) | |
molecules.append(mol) | |
print len(molecules) | |
img = Draw.MolsToGridImage(molecules,molsPerRow=5,legends=[x for x in names],subImgSize=(200,200)) | |
img |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment