Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions documentation/source/reference/molecule/atomtype.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,8 @@ Atom type Description
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
``Cl`` chlorine atom with any local bond structure
``Cl1s`` chlorine atom with three lone pairs and zero to one single bonds
*Iodine atom types*
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
``I`` iodine atom with any local bond structure
``I1s`` iodine atom with three lone pairs and zero to one single bonds
=============== ==============================================================================================================================================================
4 changes: 4 additions & 0 deletions documentation/source/users/rmg/database/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ table below shows all atoms types in RMG.
+----------+-------------------+------------------------------------------------------------------------------------------------------------------+
|Cl1s |Chlorine |Three lone pairs, zero to one single bonds |
+----------+-------------------+------------------------------------------------------------------------------------------------------------------+
|I |Iodine |No requirements |
+----------+-------------------+------------------------------------------------------------------------------------------------------------------+
|I1s |Iodine |Three lone pairs, zero to one single bonds |
+----------+-------------------+------------------------------------------------------------------------------------------------------------------+
|He |Helium |No requirements, nonreactive |
+----------+-------------------+------------------------------------------------------------------------------------------------------------------+
|Ne |Neon |No requirements, nonreactive |
Expand Down
16 changes: 12 additions & 4 deletions rmgpy/molecule/atomtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ def getFeatures(self):
'C','Ca','Cs','Csc','Cd','CO','CS','Cdd','Cdc','Ct','Cb','Cbf','C2s','C2sc','C2d','C2dc','C2tc',
'N','N0sc','N1s','N1sc','N1dc','N3s','N3sc','N3d','N3t','N3b','N5sc','N5dc','N5ddc','N5dddc','N5t','N5tc','N5b','N5bd',
'O','Oa','O0sc','O2s','O2sc','O2d','O4sc','O4dc','O4tc','O4b',

'Si','Sis','Sid','Sidd','Sit','SiO','Sib','Sibf',
'S','Sa','S0sc','S2s','S2sc','S2d','S2dc','S2tc','S4s','S4sc','S4d','S4dd','S4dc','S4b','S4t','S4tdc','S6s','S6sc','S6d','S6dd','S6ddd','S6dc','S6t','S6td','S6tt','S6tdc',
'Cl','Cl1s'])
'Cl','Cl1s',
'I','I1s'])

atomTypes['R!H'] = AtomType(label='R!H', generic=['R'], specific=[
'Val4','Val5','Val6','Val7',
Expand All @@ -252,7 +252,8 @@ def getFeatures(self):
'O','Oa','O0sc','O2s','O2sc','O2d','O4sc','O4dc','O4tc','O4b',
'Si','Sis','Sid','Sidd','Sit','SiO','Sib','Sibf',
'S','Sa','S0sc','S2s','S2sc','S2d','S2dc','S2tc','S4s','S4sc','S4d','S4dd','S4dc','S4b','S4t','S4tdc','S6s','S6sc','S6d','S6dd','S6ddd','S6dc','S6t','S6td','S6tt','S6tdc',
'Cl','Cl1s'])
'Cl','Cl1s',
'I','I1s'])

atomTypes['Val4'] = AtomType(label='Val4', generic=['R','R!H'], specific=[
'C','Ca','Cs','Csc','Cd','CO','CS','Cdd','Cdc','Ct','Cb','Cbf','C2s','C2sc','C2d','C2dc','C2tc',
Expand All @@ -266,7 +267,8 @@ def getFeatures(self):
'S','Sa','S0sc','S2s','S2sc','S2d','S2dc','S2tc','S4s','S4sc','S4d','S4dd','S4dc','S4b','S4t','S4tdc','S6s','S6sc','S6d','S6dd','S6ddd','S6dc','S6t','S6td','S6tt','S6tdc'])

atomTypes['Val7'] = AtomType(label='Val7', generic=['R','R!H'], specific=[
'Cl','Cl1s'])
'Cl','Cl1s',
'I','I1s'])

atomTypes['H' ] = AtomType('H', generic=['R'], specific=[])

Expand Down Expand Up @@ -509,6 +511,10 @@ def getFeatures(self):
single=[0,1], allDouble=[0], rDouble=[], oDouble=[], sDouble=[], triple=[0], benzene=[0], lonePairs=[3], charge=[0])
# examples for Cl1s: HCl, [Cl]

atomTypes['I' ] = AtomType('I', generic=['R','R!H','Val7'], specific=['I1s'])
atomTypes['I1s'] = AtomType('I1s', generic=['R','R!H','I','Val7'], specific=[],
single=[0,1], allDouble=[0], rDouble=[], oDouble=[], sDouble=[], triple=[0], benzene=[0], lonePairs=[3], charge=[0])
# examples for I1s: HI, [I], IO, CH3I, I2

atomTypes['R' ].setActions(incrementBond=['R'], decrementBond=['R'], formBond=['R'], breakBond=['R'], incrementRadical=['R'], decrementRadical=['R'], incrementLonePair=['R'], decrementLonePair=['R'])
atomTypes['R!H' ].setActions(incrementBond=['R!H'], decrementBond=['R!H'], formBond=['R!H'], breakBond=['R!H'], incrementRadical=['R!H'], decrementRadical=['R!H'], incrementLonePair=['R!H'], decrementLonePair=['R!H'])
Expand Down Expand Up @@ -610,6 +616,8 @@ def getFeatures(self):
atomTypes['Cl' ].setActions(incrementBond=[], decrementBond=[], formBond=['Cl'], breakBond=['Cl'], incrementRadical=['Cl'], decrementRadical=['Cl'], incrementLonePair=[], decrementLonePair=[])
atomTypes['Cl1s'].setActions(incrementBond=[], decrementBond=[], formBond=['Cl1s'], breakBond=['Cl1s'], incrementRadical=['Cl1s'], decrementRadical=['Cl1s'], incrementLonePair=[], decrementLonePair=[])

atomTypes['I' ].setActions(incrementBond=[], decrementBond=[], formBond=['I'], breakBond=['I'], incrementRadical=['I'], decrementRadical=['I'], incrementLonePair=[], decrementLonePair=[])
atomTypes['I1s'].setActions(incrementBond=[], decrementBond=[], formBond=['I1s'], breakBond=['I1s'], incrementRadical=['I1s'], decrementRadical=['I1s'], incrementLonePair=[], decrementLonePair=[])

#list of elements that do not have more specific atomTypes
#these are ordered on priority of picking if we encounter a more general atomType for make
Expand Down
9 changes: 9 additions & 0 deletions rmgpy/molecule/atomtypeTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ def setUp(self):
self.mol73 = Molecule().fromAdjacencyList('''1 H u0 p0 c0 {2,S}
2 Cl u0 p3 c0 {1,S}''')

self.mol74 = Molecule().fromAdjacencyList('''1 H u0 p0 c0 {2,S}
2 I u0 p3 c0 {1,S}''')

def atomType(self, mol, atomID):
atom = mol.atoms[atomID]
type = getAtomType(atom, mol.getBonds(atom))
Expand Down Expand Up @@ -614,6 +617,12 @@ def testChlorineTypes(self):
"""
self.assertEqual(self.atomType(self.mol73, 1), 'Cl1s')

def testIodineTypes(self):
"""
Test that getAtomType() returns appropriate iodine atom types.
"""
self.assertEqual(self.atomType(self.mol74, 1), 'I1s')

def testOtherTypes(self):
"""
Test that getAtomType() returns appropriate types for other misc inerts.
Expand Down
1 change: 1 addition & 0 deletions rmgpy/molecule/group.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ cdef class Group(Graph):
cdef public short oxygenCount
cdef public short sulfurCount
cdef public short chlorineCount
cdef public short iodineCount
cdef public short siliconCount
cdef public short radicalCount

Expand Down
14 changes: 10 additions & 4 deletions rmgpy/molecule/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,23 +1117,26 @@ def updateFingerprint(self):
isomorphism checks.
"""
cython.declare(atom=GroupAtom, atomType=AtomType)
cython.declare(carbon=AtomType, nitrogen=AtomType, oxygen=AtomType, sulfur=AtomType, chlorine=AtomType, silicon=AtomType)
cython.declare(carbon=AtomType, nitrogen=AtomType, oxygen=AtomType, sulfur=AtomType, chlorine=AtomType,
iodine=AtomType, silicon=AtomType)
cython.declare(isCarbon=cython.bint, isNitrogen=cython.bint, isOxygen=cython.bint, isSulfur=cython.bint,
isChlorine=cython.bint, isSilicon=cython.bint, radical=cython.int)
isChlorine=cython.bint, isIodine=cython.bint, isSilicon=cython.bint, radical=cython.int)

carbon = atomTypes['C']
nitrogen = atomTypes['N']
oxygen = atomTypes['O']
sulfur = atomTypes['S']
chlorine = atomTypes['Cl']
iodine = atomTypes['I']
silicon = atomTypes['Si']

self.carbonCount = 0
self.nitrogenCount = 0
self.oxygenCount = 0
self.sulfurCount = 0
self.chlorineCount = 0
self.siliconCount = 0
self.iodineCount = 0
self.siliconCount = 0
self.radicalCount = 0
for atom in self.vertices:
if len(atom.atomType) == 1:
Expand All @@ -1143,8 +1146,9 @@ def updateFingerprint(self):
isOxygen = atomType.equivalent(oxygen)
isSulfur = atomType.equivalent(sulfur)
isChlorine = atomType.equivalent(chlorine)
isIodine = atomType.equivalent(iodine)
isSilicon = atomType.equivalent(silicon)
sum_is_atom = isCarbon + isNitrogen + isOxygen + isSulfur + isChlorine + isSilicon
sum_is_atom = isCarbon + isNitrogen + isOxygen + isSulfur + isChlorine + isIodine + isSilicon
if sum_is_atom == 1:
if isCarbon:
self.carbonCount += 1
Expand All @@ -1156,6 +1160,8 @@ def updateFingerprint(self):
self.sulfurCount += 1
elif isChlorine:
self.chlorineCount += 1
elif isIodine:
self.iodineCount += 1
elif isSilicon:
self.siliconCount += 1
if len(atom.radicalElectrons) >= 1:
Expand Down
4 changes: 2 additions & 2 deletions rmgpy/molecule/isomorphismTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from rmgpy.molecule.molecule import Molecule
from rmgpy.molecule.group import Group

molecule_atom_types = [ 'C', 'O', 'N', 'S', 'Si', 'Cl']
molecule_atom_types = [ 'C', 'O', 'N', 'S', 'Si', 'Cl', 'I']
group_atomtypes = {}

for item in create_atom_types() :
Expand Down Expand Up @@ -140,7 +140,7 @@ def load_cases_molecule_atom_types():
'''
output = []
a_types = list(itertools.product(molecule_atom_types, repeat=2))
uncharged_a_types = ['Cl']
uncharged_a_types = ['Cl','I']
unpaired_electrons = list(itertools.product(range(3), repeat=2))
cross_element_unpaired = list(itertools.product(a_types,unpaired_electrons))
for item in cross_element_unpaired:
Expand Down
14 changes: 8 additions & 6 deletions rmgpy/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,22 +922,24 @@ def generatePairs(self):
productSulfurs = [sum([1 for atom in product.molecule[0].atoms if atom.isSulfur()]) for product in products ]
reactantChlorines = [sum([1 for atom in reactant.molecule[0].atoms if atom.isChlorine()]) for reactant in reactants]
productChlorines = [sum([1 for atom in product.molecule[0].atoms if atom.isChlorine()]) for product in products ]
reactantIodines = [sum([1 for atom in reactant.molecule[0].atoms if atom.isChlorine()]) for reactant in reactants]
productIodines = [sum([1 for atom in product.molecule[0].atoms if atom.isChlorine()]) for product in products ]

# Sort the reactants and products by C/O/N/S numbers
reactants = [(carbon, oxygen, nitrogen, silicon, sulfur, chlorine, reactant) for carbon, oxygen, nitrogen, silicon, sulfur, chlorine, reactant
in zip(reactantCarbons,reactantOxygens,reactantNitrogens,reactantSilicons,reactantSulfurs,reactantChlorines,reactants)]
reactants = [(carbon, oxygen, nitrogen, silicon, sulfur, chlorine, iodine, reactant) for carbon, oxygen, nitrogen, silicon, sulfur, chlorine, iodine, reactant
in zip(reactantCarbons,reactantOxygens,reactantNitrogens,reactantSilicons,reactantSulfurs,reactantChlorines, reactantIodines, reactants)]
reactants.sort()
products = [(carbon, oxygen, nitrogen, silicon, sulfur, chlorine, product) for carbon, oxygen, nitrogen, silicon, sulfur, chlorine, product
in zip(productCarbons,productOxygens,productNitrogens,productSilicons,productSulfurs,productChlorines,products)]
products = [(carbon, oxygen, nitrogen, silicon, sulfur, chlorine, iodine, product) for carbon, oxygen, nitrogen, silicon, sulfur, chlorine, iodine, product
in zip(productCarbons,productOxygens,productNitrogens,productSilicons,productSulfurs,productChlorines, productIodines, products)]
products.sort()

while len(reactants) > 1 and len(products) > 1:
self.pairs.append((reactants[-1][6], products[-1][6]))
self.pairs.append((reactants[-1][-1], products[-1][-1]))
reactants.pop()
products.pop()
for reactant in reactants:
for product in products:
self.pairs.append((reactant[6], product[6]))
self.pairs.append((reactant[-1], product[-1]))

def draw(self, path):
"""
Expand Down