Subsections

 
5.3 Derived Properties of Molecules

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.

5.3.1 NumAtoms, NumBonds

The 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 11.2.

5.3.2 GetMaxAtomIdx, GetMaxBondIdx

The 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 10.

5.3.3 GetAtom, GetBond

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 None 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 None if one does not exist.

5.3.4 GetAtoms, GetBonds

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 7.