In addition to the stored properties listed above, the
OEMolBase interface also contains several
methods for getting derived (or read-only) properties of the molecule.
NumAtoms method returns the number of atoms
in the molecule, and the NumBonds method
returns the number of bonds in a molecule. Note that these methods
return the number of explicit atoms and explicit bonds
of a molecule, and don't include any implicit
hydrogens (or bonds to them). For more
details, see Section 12.2.
GetMaxAtomIdx method returns the
largest allocated atom index plus one, and the GetMaxBondIdx
method returns the largest allocated bond index plus one. For more
details, see Section 11.
The GetAtom and GetBond methods return a single OEAtomBase or
OEBondBase respectively. The object returned
is the first instance in the molecule of an atom or bond for which the
predicate (see Section 22) passed
into these methods as an argument returns true. If no match is
found null is returned.
Thus mol.GetBond(OEHasOrder(2)) will return the first double-bond in the molecule.
The GetBond method can also take two OEAtomBases and
return a the bond between them, or null if one does not exist.
These two functions provide the primary mode of access to the atoms
and bonds of a molecule. They return an object which is an iterator
over the OEAtomBases or
OEBondBases of the molecule respectively.
The use of the iterators will be covered in great detail in Section 8.