Skip to content

Instantly share code, notes, and snippets.

@avbelyaev
Last active March 6, 2019 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avbelyaev/f4c390457d20cfb6561dc3f79f085864 to your computer and use it in GitHub Desktop.
Save avbelyaev/f4c390457d20cfb6561dc3f79f085864 to your computer and use it in GitHub Desktop.
import openbabel as ob
import pybel
ASPIRIN = "CC(=O)OC1=CC=CC=C1C(=O)O"
SALICIL = "C1=CC=C(C(=C1)C(=O)O)O"
smiles = [ASPIRIN, SALICIL]
mols = [pybel.readstring("smi", x) for x in smiles]
for mol in mols:
mol.OBMol.AddHydrogens()
fps = [x.calcfp() for x in mols]
print fps[0].bits, fps[1].bits
print fps[0] | fps[1]
from rdkit import Chem
from rdkit.Chem import AllChem, Draw, Descriptors
BENZENE = "C1=CCC=CC=C1"
METH = "CC(CC1=CC=CC=C1)NC"
m = Chem.MolFromSmiles(BENZENE)
# add hydrogen
m_hydrogenized = Chem.AddHs(m)
Draw.MolToFile(m_hydrogenized, 'cdk2_mol1.o.png')
for desc in Descriptors._descList:
desc_name = desc[0]
desc_value = desc[1](m_hydrogenized)
print(str(desc_value) + "\t" + desc_name)
# http://www.qsar4u.com/files/rdkit_tutorial/rdkit.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment