Occasionally, one may want to use a logical operator to join two or
more functors. While it is certainly possible to write a quick
functor which wraps two or more functors, but this is not necessary.
The functors OEAndAtom, OEOrAtom and OENotAtom
are already defined. The each have constructors which take the
appropriate number of predicates as arguments and generate a single
unary predicate. Similar logical predicates are defined for bonds,
residues, etc.
The following example demonstrates use of the OEAndAtom and
OENotAtom composition predicates with two of the predefined
atom predicates
#!/usr/bin/env python
# ch21-3.py
from openeye.oechem import *
def Count(fcn, mol):
count=0
for atom in mol.GetAtoms():
if fcn(atom)==1:
count += 1
return count
mol = OEGraphMol()
OEParseSmiles(mol, "c1c(O)c(O)c(Cl)cc1CCCBr")
print "Number of Aromatic Oxygens = ",
print Count(OEAndAtom(IsOxygen(),IsAromaticAtom()),mol)
print "Number of Non-Carbons = ",
print Count(OENotAtom(HasAtomicNum(6)),mol)