Package CHEM :: Package CombiCDB :: Module ReactionPredictor :: Class ReactionPredictor
[hide private]
[frames] | no frames]

Class ReactionPredictor



Given pairs of molecules, try breaking a bond in each, and reattaching
them to the other molecule.  Report each possibility with the predicted
change in enthalpy based on a respective (FreeEnergy) Score object.    
Those with larger, negative changes suggest energetically favorable,
exothermic reactions.

Any bond attached to a "*" atom will be ignored.  This allows "*"
to represent arbitary "R" groups, and thus allows for the testing
of functional groups rather than whole molecules.

Higher order bonds (double bonds, triple bonds) are also considered.
However, rather than being completely broken, only "one" of the bonds
will be broken and reattached elsewhere which only reduces the bond order.

Known Limitations:
(1) Only handles binary (two reactant) reactions
(2) Only handles simple bond-break, reform reactions.
    Does not allow for consideration of resonance structure intermediates.
(3) Only considers predicted bond dissociation energy enthalpy,
    no entropy terms.



Instance Methods [hide private]
 
__init__(self)
Default constructor.
 
predictReactionsStream(self, molstreamFactory1, molstreamFactory2, productStream)
Given two input molecule streams factories, try the predictReactions method for every pair of molecules.
 
predictReactions(self, reactant1, reactant2)
Primary method.
 
__generateIntermediates(self, composite, componentIndex)
Generate a list (actually an iterator over a dynamic list) of intermediate structures by taking the composite molecule and breaking bonds and rearranging electrons in the component specified by the componentIndex.
 
__assembleIntermediates(self, intermediateComposite)
Given a composite molecule where the first 2 components have been broken down into some kind of intermediate structure (bonds broken, maybe electrons shifted, with respective + and - formal charge somewhere to account for the broken bond), reassemble the intermediates into a completed composite by matching opposite formal charges in the 1st and 2nd component.
 
__molBondList(self, mol, componentIndex)
Return a concrete list of all of the bonds in the molecule where...
 
__atomsByComponentAndCharge(self, mol, componentIndex, charge)
Return an iterator over all of atoms in the composite molecule whose componentIndex matches that specified and whose FormalCharge property matches that given.
 
__getAtomComponentIndexes(self, mol)
If the attribute is already on this instance, just return it.
Static Methods [hide private]
 
__breakableBond(bond)
Decide whether the given bond should be breakable in terms of predicting reactions.
 
__breakBond(bond)
Represent the bond having broken, at least by one order.
 
__reassembleBond(bond)
Undo the affects of the __breakBond method.
 
__shiftElectrons(mol, startAtom, visitedAtomIndexes=None)
Given a starting atom from the molecule, check if it has a negative formal charge.
Method Details [hide private]

predictReactionsStream(self, molstreamFactory1, molstreamFactory2, productStream)

 
Given two input molecule streams factories, try the predictReactions method for every pair of molecules. Write the outputs as "reaction" molecules to the molecule output stream. The "title" of the output molecules will be the change in enthaly predicted for the reaction.

predictReactions(self, reactant1, reactant2)

 

Primary method. Given two molecule objects, return an iterator over composite molecule objects representing predicted reaction products from the 2 molecules. These will have their energy property set to the predicted change in enthalpy for that reaction, accessible with the GetEnergy method.

Note that this actually returns a dynamic iterator over the same molecule object (just modifed atom-bonds and properties). If you need to modify or otherwise keep multiple instances of the products, make your own copies by using the OEGraphMol copy constructor like copy = OEGraphMol(product);

__generateIntermediates(self, composite, componentIndex)

 

Generate a list (actually an iterator over a dynamic list) of intermediate structures by taking the composite molecule and breaking bonds and rearranging electrons in the component specified by the componentIndex.

The self.__atomComponentIndexes member should be a precomputed list of componentIndexes for each atom in the composite molecule, as returned by the OEDetermineComponents method. If that has not yet been filled in, it will be.

In the interests of efficiency, each item returned is actually the same molecule object returned over and over again, just with different atom-bond modifications. This as opposed to generating a copy each time. As a result, it is the callers responsibility to keep or put the molecule back into it's original state before asking for the next item.

__assembleIntermediates(self, intermediateComposite)

 

Given a composite molecule where the first 2 components have been broken down into some kind of intermediate structure (bonds broken, maybe electrons shifted, with respective + and - formal charge somewhere to account for the broken bond), reassemble the intermediates into a completed composite by matching opposite formal charges in the 1st and 2nd component.

Return the results as a list of copies.

__molBondList(self, mol, componentIndex)

 
Return a concrete list of all of the bonds in the molecule where...

(1) The bond is considered "breakable" for purposes of reaction simulation
    as defined in the __breakableBond method
(2) The bond is a part of the component of the composite molecule
    indexed by the componentIndex parameter.  self.__atomComponentIndexes
    should be a precomputed list of componentIndexes for each atom in
    the composite molecule, as returned by the OEDetermineComponents method.

Must use this concrete list because the algorithm will be creating and 
deleting bonds, making the use of a dynamic iterator unsafe

__breakableBond(bond)
Static Method

 
Decide whether the given bond should be breakable in terms of predicting reactions. When breaking higher order bonds (double or greater), we are really only considered breaking one of the bond orders (double down to single, etc.)

__breakBond(bond)
Static Method

 
Represent the bond having broken, at least by one order. Do so by decrementing the bond order or delete the given bond altogether from the containing molecule object.

__reassembleBond(bond)
Static Method

 

Undo the affects of the __breakBond method. Increment the bond order and, if necessary, recreate a new bond instance into the parent molecule.

Returns the bond object which may just be the same thing if the order was incremented, but if the bond had to be recreated, the new instance is returned.

__shiftElectrons(mol, startAtom, visitedAtomIndexes=None)
Static Method

 

Given a starting atom from the molecule, check if it has a negative formal charge. If so, try shifting the negative charge into a new adjacent bond. This should only be applied if the adjacent atom of the increasing bond has a pi orbital system that can accept the electrons. Basically, the adjacent atom must already have another bond of at least order >= 2. If so, then shift the electrons to increase the order of the bond to the adjacent atom and decrease the order of the adjacent atom's other double / triple bond to the last opposite atom.

e.g. [C-]-C=O will become C=C-[O-]

This function will be called recursively for repeated shifts. Uses the visitedAtomIndexes Set to keep track of atoms already visited to avoid backtracking. For efficiency, will keep yielding modifications of the same molecule object instead of copies. This requires that the state of the molecule always be brought back to where it was.

__getAtomComponentIndexes(self, mol)

 
If the attribute is already on this instance, just return it. Otherwise, compute its value from the molecule object first.