3.2 Reusing Molecules

OEChem also provides a mechanism for reusing a molecule. For example, when processing multiple, sequential molecules in a database or input file, instead of requiring a new molecule to be allocated and destroyed for each iteration, OEMolBase's provides a Clear method to reset a molecule to its initial (empty) state.

The following example demonstrates calling the Clear method of our molecule. Note that the Clear in the following example is not required as the molecule is already initialized (empty) by the creation function. The code does demonstrate that the OEMol does behave as an OEMolBase allowing it to be used with any of OEChem's OEMolBase methods or functions.

from openeye.oechem import *
mol = OEMol()
mol.Clear()