The next example creates a caffeine molecule from SMILES, adds hydrogens explicitly, assigns Tripos atom names and typenames and prints them all out.
# ch15-1.py from openeye.oechem import * mol = OECreateOEMol() caffeine = 'Cn1cnc2n(C)c(=O)n(C)c(=O)c12' OEParseSmiles(mol, caffeine) mol.SetTitle('caffeine') print '#atoms=',mol.NumAtoms() # add explicit hydrogens OEAddExplicitHydrogens(mol) print '#atoms=',mol.NumAtoms() # now loop over atoms, printing their atomic number for atom in mol.GetAtoms(): print atom.GetAtomicNum(), print # assign tripos atom names and types OETriposAtomNames(mol) OETriposAtomTypeNames(mol) # now loop over atoms, printing their name for atom in mol.GetAtoms(): print atom.GetName(), print # now loop over heavy atoms, printing their types for atom in mol.GetAtoms(): if atom.GetAtomicNum()!=1: print atom.GetType(), print