The IteratorFactory class provides implementations of java.util.Iterator
to ease the handling of atoms and bonds used in Molecule objects and its
descendants. The IteratorFactory object always belongs to one particular Molecule object (or descendant).
The following iterators are included in this class:
AtomIterator class provides
an iterator for the atoms of the specified molecule of the factory
according to the atom related behavior set in the factory.
BondIterator class provides an iterator to process
the bonds of the specified molecule in this factory
according to the bond related behavior of this factory.
AtomNeighbourIterator class provides an iterator to process
the atoms connecting to a specified atom according to the atom and bond related
behavior of the factory
BondNeighbourIterator class provides an iterator to
process the bonds connecting to the specified atom according to the atom
and bond related behavior of this factory.
RxnComponentIterator class provides an iterator to process
the reaction components (reactant, product and agent components) in the reaction molecule of
the factory.
RgComponentIterator class provides an iterator to process
the R-group definition components in the specified molecule of
the factory.
Example for simple usage of an atom iterator:
//initialize a Molecule; Molecule molecule = ...; //create an iterator factory where the iterators skip the pseudo atom and coordinate bonds. IteratorFactory ifc = new IteratorFactory(molecule, IteratorFactory.SKIP_PSEUDO_ATOM | IteratorFactory.SKIP_EXPLICIT_H, IteratorFactory.SKIP_COORDINATE_BONDS); AtomIterator atomIterator = ifc.createAtomIterator(); //iteration on the atoms of a component except the pseudo atoms. while (atomIterator.hasNext()){ MolAtom atom = atomIterator.nextAtom(); //process the atom ... }
Example for complex usage of iterators:
//initialize an RgMolecule;
RgMolecule mol = ... ;
//create the iterator factory with the specified molecule and parameters related to atoms and bonds.
IteratorFactory factory = new IteratorFactory(mol, IteratorFactory.INCLUDE_ALL_ATOMS, IteratorFactory.INCLUDE_ALL_BONDS);
RgComponentIterator rgIterator = factory.createRgComponentIterator();
//iteration on the components of the RgMolecule.
while (rgIterator.hasNext()) {
Molecule component = rgIterator.nextComponent();
IteratorFactory ifc = new IteratorFactory(component, IteratorFactory.SKIP_PSEUDO_ATOM | IteratorFactory.SKIP_EXPLICIT_H,
IteratorFactory.SKIP_COORDINATE_BONDS);
AtomIterator atomIterator = ifc.createAtomIterator();
//iteration on the atoms of a component
while (atomIterator.hasNext()){
MolAtom atom = atomIterator.nextAtom();
//process the atom
...
}
//iteration on the bonds of a component
BondIterator bondIterator = ifc.createBondIterator();
while (bondIterator.hasNext()){
MolBond bond = bondIterator.nextBond();
//process the bond
...
}
}
|
Relative configuration of tetrahedral stereo centers |
Atom and bond-set handling |