Up to this point in the manual, all of the examples have involved
using concrete OEGraphMol 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 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 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 OEGraphMol ,
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. 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 an OEMolBase or an
OEMCMolBaseT as an argument.
An OEGraphMol is a concrete class similar to
the OEMol which provides access to only the
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 .
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.