Package CHEM :: Package Common :: Module MolExt
[hide private]
[frames] | no frames]

Module MolExt



Extensions for molecule object descriptors

Classes [hide private]
  Orbital
Functions [hide private]
 
nStdValenceElectrons(atomicNum)
Return the standard number of valence electrons for an atom type specified by atomic number.
 
atomIonizationEnergy(atom, formalCharge=None)
Return a reference value for the atom's ionization energy (kcal/mol).
 
atomElectronAffinity(atom, formalCharge=None)
Return a reference value for the atom's electron affinity (kcal/mol).
 
atomElectronegativity(atom, formalCharge=None)
Return a reference value for the electronegativity of a given atom.
 
stableValenceShell(atomicNum)
How many electrons should be in the outer shell for this atom type to be stable? Most commonly should just be 8 to make the octet rule, except for hydrogen.
 
orbitalInfo(atom)
Returns various statistics related to the atom's non-bonded orbitals.
 
atomHybridization(atom, visitedAtomIndexes=None)
OEChem has OEGetHybridization method, and this works similarly.
 
orbitalIter(atom)
Iterate over all of the apparent orbitals in the current atom.
 
resonanceStructureIter(mol, observedSmilesSet=None, depth=0)
For the given molecule or intermediate, enumerate all of the reasonable resonance structures by shifting electrons around available p atomic orbitals and pi molecular orbitals.
 
uniqueAtomResonanceStructureIter(mol, undoLabels=True)
Simple wrapper around resonance structureIter method.
 
labelUniqueAtomMaps(mol, undoDict=None)
Helper to label the atom map attribute of all of the atoms of the molecule equal to their index position in the molecule, which ensures they will all receive a unique value.
 
undoLabelUniqueAtomMaps(mol, undoDict=None)
Undo the effects of the labelUniqueAtomMaps function.
 
rearrangeOrbitalElectrons(mol, bond, beginPOrbs, endPOrbs)
Given just the p and pi orbitals for the given bond, enumerate each natural way of rearranging the electrons within them.
 
rearrangeOrbitalElectronsAllowDoubleCharges(mol, bond, beginPOrbs, endPOrbs)
The real implementation method.
 
grossFormalCharges(mol)
Figure out the total gross positive and negative charge on the molecule, which may be non-zero even if the net charge on the molecule is zero.
 
screenResonanceStruct(mol)
The molecule should represent a proposed resonance structure.
 
moveOrbitalElectrons(orb1, orb2, electronCount=2)
Most general half-reaction, movement of electrons from one molecular orbital to another.
 
undoMoveOrbitalElectrons(orb1, orb2, electronCount=2)
Assume the moveOrbitalElectrons function was just called for orb1 and orb2.
 
moveAtomElectrons(atom1, atom2, electronCount=2, halfBondIndexes=None)
Move electrons from atom1 to atom2.
 
moveBondElectrons(bond, atom, electronCount=2, pivotAtom=None, halfBondIndexes=None)
Move electrons from the bond to the target atom.
 
atomsAltered(mol1, mol2)
Given 2 molecules, that should be based on a common one, determine how many atoms in the molecule have been altered by electron rearrangement.
 
atomIsChiral(atom)
Extension of OpenEye OEAtomBase.IsChiral method.
 
bondIsChiral(bond)
Extension of OpenEye OEBondBase.IsChiral method.
 
createStandardMol(mol)
Reparse the molecule SMILES string to ensure any unusual properties are cleared out.
 
enumerateRacemicMixture(mol, unspecifiedAtoms=None, unspecifiedBonds=None, allCisTrans=False)
Assume the molecule object represents a racemic mixture of otherwise identical isomers.
 
clearAtomStereo(atom)
 
clearBondStereo(bond)
 
enumerateRacemicMixtureList(molList, currStereoList=None)
Given a list of molecule objects, call enumerateRacemicMixture on each to yield a list of all possible isomer combinations of the molecules.
 
neighborTreeWeight(atom, visitedAtomIndexes)
Determine the molecular weight of all atoms connected up to the atom, that are not counted in the visitedAtomIndexes.
 
molSkeleton(mol, clearChiralFlags=True, copyMol=True, carbonSkeleton=False)
Reduces the molecule down to just it's (carbon) skeleton.
 
clearMol(mol)
Delete all of the atoms in the molecule.
Variables [hide private]
  ORBITAL_TYPES = Set(["sigma", "pi", "s", "sp0", "sp", "sp1", "...
  BOND_ORBITAL_TYPES = Set(["sigma", "pi"])
Function Details [hide private]

nStdValenceElectrons(atomicNum)

 
Return the standard number of valence electrons for an atom type specified by atomic number. Based on lookup table for now, can come up with more generalized scheme later.

atomIonizationEnergy(atom, formalCharge=None)

 
Return a reference value for the atom's ionization energy (kcal/mol). If the atom has a formal charge, should return an adjusted value to estimate 2nd ionization energies, etc. If a formal charge parameter is specified use that value instead of any set on the actual atom object.

atomElectronAffinity(atom, formalCharge=None)

 
Return a reference value for the atom's electron affinity (kcal/mol). If the atom has a formal charge, should return an adjusted value to estimate 2nd electron affinities, etc. If a formal charge parameter is specified use that value instead of any set on the actual atom object.

atomElectronegativity(atom, formalCharge=None)

 
Return a reference value for the electronegativity of a given atom. This uses a general Mulliken scale where EN = (IE - EA) / 2, (IE = Ionization Energy, EA = Electron Affinity) which can in turn be found by standard values and inferred for charged atoms.

stableValenceShell(atomicNum)

 
How many electrons should be in the outer shell for this atom type to be stable? Most commonly should just be 8 to make the octet rule, except for hydrogen. Note also that essentially any can be come stable with "zero" outer shell electrons, since that just means the next complete inner shell becomes the outer shell.

orbitalInfo(atom)

 
Returns various statistics related to the atom's non-bonded orbitals. This is a dictionary with keys:
  • nUnbondedElectrons
  • nLonePairs
  • nRadicals
  • nEmptyOrbitals
Given an atom object, figure out how many electrons are in its outer valence shell that are NOT part of a bond. Based on standard valence electron number.

atomHybridization(atom, visitedAtomIndexes=None)

 

OEChem has OEGetHybridization method, and this works similarly.

Return value is the p character of the hybridization, for example 2 for sp2

Simple rule based now, that should work for atoms up to the second row at least. Easy to tell if this atom has more than one pi bond. Otherwise, assume is sp3 unless have an empty orbital then assume is sp2. Or, if have a lone pair in an aromatic system, must be sp2. In cases like oxygen of C=CO, is probably somewhere in between.

Hydrogen is special case.

orbitalIter(atom)

 
Iterate over all of the apparent orbitals in the current atom. These will include sigma and pi molecular orbitals or possible sp or p atomic orbitals. For each, will have a bond associated with it, or a certain number of lone electrons.

resonanceStructureIter(mol, observedSmilesSet=None, depth=0)

 

For the given molecule or intermediate, enumerate all of the reasonable resonance structures by shifting electrons around available p atomic orbitals and pi molecular orbitals. For efficiency, will always be the same molecule object yielded, just modified. Caller must make sure that it comes back in the same state.

Strategy: Look for any 2 adjacent atoms hybridized with p or pi orbitals and rearrange electrons in a chemically natural manner.

After any case, recursively look for more possibilities. Use observedSmilesSet to avoid recursion loops

uniqueAtomResonanceStructureIter(mol, undoLabels=True)

 
Simple wrapper around resonance structureIter method.  Before generating
the resonance structures however, will give a unique atom map label to
every atom in the molecule with the effect that symmetric resonance structures
will each be counted individually, instead of being skipped over as if identical.

undoLabels: Specifies whether to clear out these fake labels before
                each result is yielded

labelUniqueAtomMaps(mol, undoDict=None)

 

Helper to label the atom map attribute of all of the atoms of the molecule equal to their index position in the molecule, which ensures they will all receive a unique value.

If undoDict provided, then store the original values of the atom map indexes so they can later be restored by the undoLabelUniqueAtomMaps function.

undoLabelUniqueAtomMaps(mol, undoDict=None)

 
Undo the effects of the labelUniqueAtomMaps function. If no specific undoDict is provided, then just reset all of the atom map indexes to "0" indicating standard values. Otherwise, use the specific values stored in the undoDict.

rearrangeOrbitalElectrons(mol, bond, beginPOrbs, endPOrbs)

 
Given just the p and pi orbitals for the given bond,
enumerate each natural way of rearranging the electrons within them.
Don't have to consider mirror cases, leave that as caller's responsibility
by calling this function twice, but swapping the begin and end atoms and pOrbs.

Cases of interest (not counting radicals for now):
    - Both atoms share a pi molecular orbital.  That is, the bond includes a pi bond.
        . Separate the pi molecular orbitals into one empty orbital (+ charge) and 
            one lone pair orbital (- charge).
            Then caller can recurse on this intermediate which should fit the above rules.
    - One atom has lone pair, other has empty p orbital (artificial case representing charge separation modeling)
        . Move lone pair to empty p orbital to form new pi bond here
    - One atom has pi molecular orbital other has empty p orbital
        . Move the pi electrons to form a new pi bond here
    - One atom has a lone pair in p orbital, other has a pi molecular orbital
        . Move the lone pair into a new pi bond
        . Move the pi electrons to a lone pair over the far (3rd) atom

Additional case where atoms each have a pi molecular orbital, but not the same one,
like the central bond in C=C-C=C.  Do nothing here, let another case separate
the pi orbital of one of the adjacent double bonds, and then it will look like
a case we can work with (lone pair or empty orbital next to pi orbital).

Note that this keeps yielding the same (but modified) molecule object.
Thus, in implementing, after each yield usage, the atom and bond states must 
be returned to how they were.

rearrangeOrbitalElectronsAllowDoubleCharges(mol, bond, beginPOrbs, endPOrbs)

 

The real implementation method. Interface method is just a wrapper on this one with a filter to eliminate overcharged resonance structure proposals.

Can almost just use the moveOrbitalElectrons functions from every beginPOrb to every endPOrb and let that sort out the details. This would work, except that we need to undo the changes at each step to revert the molecule to its original state, which is hard to do if we don't know the specific steps.

grossFormalCharges(mol)

 

Figure out the total gross positive and negative charge on the molecule, which may be non-zero even if the net charge on the molecule is zero.

For example: >>> from CHEM.Common.Util import molBySmiles; >>> print grossFormalCharges(molBySmiles( "CC(=O)Cl" )); (0, 0) >>> print grossFormalCharges(molBySmiles( "[OH3+]" )); (1, 0) >>> print grossFormalCharges(molBySmiles( "CC[N+](=O)[O-]" )); (1, -1) >>> print grossFormalCharges(molBySmiles( "[N-]=[N+]=[N-]" )); (1, -2)

screenResonanceStruct(mol)

 
The molecule should represent a proposed resonance structure.
Decide whether it should be accepted as a valid / meaningful one.

For example:
    Don't accept charge separated structures if it leaves an empty orbital 
    (incomplete octet) on the formal positive atom.
    It's okay if the formal positive atom has a complete octet, like
    the nitrogen on nitro and azide groups.
    Also okay if lone positive charge, like carbocation with no anion available
    to "fill-in" the empty orbital.

moveOrbitalElectrons(orb1, orb2, electronCount=2)

 

Most general half-reaction, movement of electrons from one molecular orbital to another. Function should figure out all of the substeps necessary to properly represent the change, including consideration for whether the orbitals are atomic (non-bond) or molecular (bond).

Assume this is called in a sensible manner however. Cannot use any arbitary orbitals as the arguments. The source orbital (orb1) must contain electrons to move, no empty orbitals allowed. The target orbital (orb2) must have space for electrons to move in. In general this means it is either an empty orbital or a bond orbital which can displace the existing bond electrons to the neighbor atom. No lone pairs allowed.

Returns a 2-ple consisting of the bond just created or added to by the move and a string representing the respective "arrow-pushing" diagram.

undoMoveOrbitalElectrons(orb1, orb2, electronCount=2)

 
Assume the moveOrbitalElectrons function was just called for orb1 and orb2. Revert the molecule state to where it was before then based on the info in the orbitals.

moveAtomElectrons(atom1, atom2, electronCount=2, halfBondIndexes=None)

 

Move electrons from atom1 to atom2. If these are bonded already, just change the bond order and adjust the formal charges. If they are not already bonded, then create a new bond and adjust the formal charges.

If moving single electrons (radical reactions) better provide halfBonds list. Used to keep track of which bonds have only been "half-formed" by a radical movement, and are waiting for a complementary one to complete or eliminate the bond. Note that the bond could be "1 1/2" or "2 1/2." The point is that it's just not a whole number bond yet.

Return 2-ple with reference to new bond object if it was created and the arrow code string representing the electron movement.

moveBondElectrons(bond, atom, electronCount=2, pivotAtom=None, halfBondIndexes=None)

 

Move electrons from the bond to the target atom. If the atom is already part of the bond, then just down shift the bond order (maybe deleting the bond altogether) and adjust atom formal charges.

Otherwise, down shift this bond order and create a new one to the atom, again adjusting atom formal charges. Note that this only works if the "pivotAtom" is specified. That is, the atom which appears in both the source and the target bond. Otherwise, without the polarity of the source bond specified, can't tell which end to remain connected to.

Return the arrow code string representing the electron movement.

atomsAltered(mol1, mol2)

 

Given 2 molecules, that should be based on a common one, determine how many atoms in the molecule have been altered by electron rearrangement. One of the molecules should probably have been a copy of the other, because this method depends on the mol.GetAtoms iterator returning the atoms in the same order.

If that's the case, will go through each matching pair of atoms and check whether they share the same bond orders and formal charge. If not, assume the electron arrangement has changed.

atomIsChiral(atom)

 
Extension of OpenEye OEAtomBase.IsChiral method. Manual corrections for
  • Organometallics do not have configurationally stable stereochemistry

bondIsChiral(bond)

 
Extension of OpenEye OEBondBase.IsChiral method. Manual corrections for
  • Vinylic carbocations should not have stereochemistry, should be linear, sp hybridized

createStandardMol(mol)

 

Reparse the molecule SMILES string to ensure any unusual properties are cleared out. Happens often when doing direct molecule graph manipulations or reaction processing.

In addition, check molecule bonds and atoms and clear out any bogus stereoassignments.

enumerateRacemicMixture(mol, unspecifiedAtoms=None, unspecifiedBonds=None, allCisTrans=False)

 
Assume the molecule object represents a racemic mixture of otherwise identical isomers.  
Go through every unassigned stereocenter and generate all possible specific isomers
by assiging all possible stereo configurations.

allCisTrans: If true, will enumerate all cis-trans isomers for unspecified chiral bonds.
    Otherwise, will only generate one with the bulkiest (largest by molecular weight)
    groups trans to each other

enumerateRacemicMixtureList(molList, currStereoList=None)

 

Given a list of molecule objects, call enumerateRacemicMixture on each to yield a list of all possible isomer combinations of the molecules.

currStereoList is the current list of fully-stereospecified molecules. One it reaches the same length of the original molList, one complete set of stereoisomers has been produced and can be returned. Use to track depth in recursion

neighborTreeWeight(atom, visitedAtomIndexes)

 
Determine the molecular weight of all atoms connected up to the atom, that are not counted in the visitedAtomIndexes. Ignore implicit hydrogens, which should be fine for relative comparisons as long as they are consistently ignored throughout the molecule.

molSkeleton(mol, clearChiralFlags=True, copyMol=True, carbonSkeleton=False)

 
Reduces the molecule down to just it's (carbon) skeleton.
  • All implicit and explicit hydrogen atoms are removed
  • All bond orders are set to 1
  • All formal charges are neutralized
  • All isotopes are reset
  • All atom mapping indexes are reset

    If carbonSkeleton is True
    • All non-carbon atoms that are not within a ring or chain are removed

clearMol(mol)

 
Delete all of the atoms in the molecule. Don't just use mol.Clear(), if want to retain other information, such as SD tagged or other name-value pair data

Variables Details [hide private]

ORBITAL_TYPES

Value:
Set(["sigma", "pi", "s", "sp0", "sp", "sp1", "sp2", "sp3", "p"])