RDKit - read/write
Read a molecule
from rdkit import Chem
m = Chem.MolFromSmiles('Cc1ccccc1')
m = Chem.MolFromMolFile('data/input.mol')
mol_str=open('data/input.mol','r').read()
m = Chem.MolFromMolBlock(mol_str)Read molecule will return <rdkit.Chem.rdchem.Mol object at 0x...> or None
Read molecules
mols = Chem.SDMolSupplier('data/5ht3ligs.sdf')
f = open('data/5ht3ligs.sdf','rb')
mols = Chem.ForwardSDMolSupplier(f)
for mol in mols:
print(mol.GetNumAtoms())Write molecule
generic SMILES = no chiral or isotopic info
isomeric SMILES = with chiral & isotopic info
unique SMILES = canonicalized generic SMILES
absolute SMILES = unique isomeric SMILES
Output SMILES is canonical.
Molfile with coord
Chem vs AllChem
speed startup and lower import times
rdkit.Chem = basic func (reading/writing, substructure searching, cleanup, etc)
rdkit.Chem.AllChem = advanced
Last updated
Was this helpful?