Many of the file formats supported by OEChem are inherently a single conformer format (SDF and MOL2, for example). However, a common practice is to store multiple conformers in these files. OEChem supports a rather advanced mechanism for recovering these separate conformers into a single, multi-conformer OEMol. Note that this does not apply to file formats where conformers are stored together. For example, all molecules in old OEBinary file are multi-conformer molecules. New OEBinary (.oeb) stores either single conformer or multi-conformer molecules explicitly so the file itself determines how to deal with conformers. Additionally, file formats that have no notion of conformers (i.e. SMILES files) are also unaffected by this feature.
In early versions of OEChem, the default behaviour for reading into an OEMol was to attempt to combine conformers of the same molecules together into a single OEMol. This is no longer the default, but is instead something controlled by the programmer.
oemolistreams have a method, SetConfTest
, that sets a functor to be
used to compare the graphs of incoming molecules to determine whether to combine them.
These functors are instances of OEConfTest. Several predefined versions include:
No change to the connection table are made.
The constructor for OEIsomericConfTest has a default argument for whether or not to compare titles. If the constructor is called with no arguments or with the argument true, the titles will be required to be the same. Otherwise, the titles will not be compared. In the latter instance, each conformer will have the individual title of its original connection table and the multiconformer molecule will reflect the title of the active conformer.
This conformer test sets all fully specified isomeric values to UNDEFINED.
The constructor for OEAbsoluteConfTest has a default argument for whether or not to compare titles. If the constructor is called with no arguments or with the argument true, the titles will be required to be the same. Otherwise, the titles will not be compared. In the latter instance, each conformer will have the individual title of its original connection table and the multiconformer molecule will reflect the title of the active conformer.
This conformer test puts all of the molecules in their canonical atom order. In addition, all fully specified isomeric values are set to UNDEFINED.
The following example will attempt to read multi-conformer molecules from an input file based on OEAbsoluteConfTest. Note that creating the instance of OEAbsoluteConfTest with the default constructor argument (0 or false), allows conformers to be combined when they have different titles. This is very useful when dealing with files created by programs that modify molecule titles to indicate conformer number (i.e. acetsali_1, acetsali_2, acetsali_3). The resulting multi-conformer molecule will have the title associated with the first connection table read from the file.
#!/usr/bin/env python from openeye.oechem import * ifs = oemolistream('mcdrugs.sdf') ifs.SetConfTest(OEIsomericConfTest()) for mol in ifs.GetOEMols(): print '%s has %d conformers' % (mol.GetTitle(), mol.NumConfs())