@@ -1048,7 +1048,7 @@ def fromRDKitMol(self, rdkitmol):
10481048 """
10491049 # Below are the declared variables for cythonizing the module
10501050 cython .declare (i = cython .int )
1051- cython .declare (radicalElectrons = cython .int , spinMultiplicity = cython .int , charge = cython .int )
1051+ cython .declare (radicalElectrons = cython .int , spinMultiplicity = cython .int , charge = cython .int , lonePairs = cython . int )
10521052 cython .declare (atom = Atom , atom1 = Atom , atom2 = Atom , bond = Bond )
10531053
10541054 self .vertices = []
@@ -1076,7 +1076,7 @@ def fromRDKitMol(self, rdkitmol):
10761076 # Process charge
10771077 charge = rdkitatom .GetFormalCharge ()
10781078
1079- atom = Atom (element , radicalElectrons , spinMultiplicity , charge )
1079+ atom = Atom (element , radicalElectrons , spinMultiplicity , charge , '' , 0 )
10801080 self .vertices .append (atom )
10811081
10821082 # Add bonds by iterating again through atoms
@@ -1098,6 +1098,7 @@ def fromRDKitMol(self, rdkitmol):
10981098
10991099 # Set atom types and connectivity values
11001100 self .updateConnectivityValues ()
1101+ self .updateLonePairs ()
11011102 self .updateAtomTypes ()
11021103
11031104 return self
@@ -1790,4 +1791,25 @@ def getRadicalAtoms(self):
17901791 if atom .radicalElectrons > 0 :
17911792 radicalAtomsList .append (atom )
17921793 return radicalAtomsList
1794+
1795+ def updateLonePairs (self ):
1796+ """
1797+ Iterate through the atoms in the structure and calcualte the
1798+ number of lone electron pairs, assumin a neutral molecule.
1799+ """
1800+ for atom1 in self .vertices :
1801+ order = 0
1802+ if not atom1 .isHydrogen ():
1803+ for atom2 , bond12 in atom1 .edges .items ():
1804+ if bond12 .isSingle ():
1805+ order = order + 1
1806+ if bond12 .isDouble ():
1807+ order = order + 2
1808+ if bond12 .isTriple ():
1809+ order = order + 3
1810+
1811+ atom1 .lonePairs = 4 - atom1 .radicalElectrons - order
1812+
1813+ else :
1814+ atom1 .lonePairs = 0
17931815
0 commit comments