def MyReadSmilesMolecule(pyfile, mol):
mol.Clear()
for line in pyfile.xreadlines():
if OEParseSmiles(mol, line):
OEFindRingAtomAndBonds(mol)
OEAssignAromaticFlags(mol)
return 1
mol.Clear()
return 0
Note that the canonical SMILES generated by this function remains
dependent on the state of the molecule, esp. its aromaticity
state. Thus, to generate a canonical smiles suitable for purposes
such as a database key, the programmer must assure that the state of
the molecule has been standardized. In particular, aromaticity should
be perceived according to the preferred model. The SMILES
canonicalization flag OESMILESFlag_Canonical
refers specifically to canonical ordering of
atoms. In contrast, the high-level output function
OEWriteMolecule, when writing the canonical SMILES
format (OEFormat::CAN) does invoke
OEFindRingAtomsAndBonds OEAssignAromaticFlags,
and is equivalent to the following code.
def MyWriteCanSmilesMolecule(pyfile, mol):
OEFindRingAtomsAndBonds(mol)
OEAssignAromaticFlags(mol)
smiles = OECreateCanSmiString(mol)
pyfile.write("%s %s\n" % (smiles, mol.GetTitle()))