8.2 Multi-conformer and single-conformer molecules

Up to this point in the manual, all of the examples have involved using concrete OEMol molecules. These molecules have been utilizing the functionality defined in the API of the OEMolBase abstract base-class. At this point we will introduce another layer of abstraction in OEChem's representation of molecules. In OEChem, we draw a distinction between molecules which are limited to a single conformer and those which may have any number of conformers. While this may be an arbitrary decision, it is a pragmatic one which allows more efficient implementation of both classes. The single-conformer molecule's API is that defined by the OEMolBase abstract base-class, of which you are already familiar. The multi-conformer molecule's API is defined by another abstract base-class, the OEMCMolBaseT (here the MC stands for Multi-Conformer, and the T indicates that this class is a template). The OEMCMolBaseT class inherits publicly from the OEMolBase, thus the multi-conformer molecule supports the single-conformer API but adds additional functions to manage conformers. Both the single-conformer and the multi-conformer molecules contain atoms and bonds, but only the multi-conformer molecule contains conformers as first-class objects.

You are already familiar with the OEMol, which you have learned is a concrete class which can support the OEMolBase API and can be passed to functions which take an OEMolBase as an argument. In the following chapters, you will discover that an OEMol provides the API of the OEMCMolBaseT class in addition to that of the OEMolBase. Further, an OEMol can be passed to any function which takes either and OEMolBase or an OEMCMolBaseT as an argument.

An OEGraphMol is an additional concrete class similar to the OEMol which provides access to only the OEMolBase API. An OEGraphMol can be passed to any function which takes an OEMolBase argument, but not to a function which takes an OEMCMolBaseT argument. A OEGraphMol does not inherit from OEMolBase. This is analogous to an OEMol not inheriting from an OEMCMolBaseT. In both cases, this is for efficiency.

Simplistic OEChem inheritance scheme:
                OEBase
                  |
                  |
                OEMolBase ---------------- OEGraphMol
                  |
                  |
                OEMCMolBaseT ------------- OEMol
<- indicates inheritance
-- indicates API correspondence without inheritance

Now a programmer has two OEChem molecules to choose among, the OEMol and the OEGraphMol. As you have already learned, an OEMol supplies the entire API supplied by the OEGraphMol, so if there is any doubt which molecule to choose, the OEMol is a safe choice. However, in instances when you are certain that the code you are writing will never need to manage molecules with multiple conformations, it is safe (and can be more efficient) to use an OEGraphMol.

To this point, our discussion of molecules has neglected to cover the API provided by the OEBase class. This will be covered in subsequent chapters.