Skip to content

Commit 373e73c

Browse files
committed
Added sulfur atomTypeTests, reorginized nitrogen tests as well
Some tests are currently commented out untill charge is implemented for atomTypes
1 parent c1e2d87 commit 373e73c

1 file changed

Lines changed: 147 additions & 14 deletions

File tree

rmgpy/molecule/atomtypeTest.py

Lines changed: 147 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,31 +182,140 @@ def setUp(self):
182182
10 H u0 p0 {4,S}
183183
11 H u0 p0 {5,S}''')
184184

185-
self.mol19 = Molecule().fromAdjacencyList('''1 C u0 p0 c0 {2,D} {3,S} {4,S}
186-
2 S u0 p2 c0 {1,D}
187-
3 H u0 p0 c0 {1,S}
188-
4 H u0 p0 c0 {1,S}''')
185+
self.mol19 = Molecule().fromSMILES('C=S')
189186

190187
self.mol20 = Molecule().fromSMILES('[C-]#[O+]')
191188

192-
self.mol21 = Molecule().fromSMILES('[C-]#[S+]')
189+
self.mol21 = Molecule().fromAdjacencyList('''1 S u0 p3 c-1 {2,S}
190+
2 S u0 p2 c+1 {1,S}''')
191+
192+
self.mol22 = Molecule().fromAdjacencyList('''1 S u0 p3 c0''')
193+
194+
self.mol23 = Molecule().fromAdjacencyList('''1 S u0 p2 c0 {2,S} {5,S}
195+
2 S u0 p1 c+1 {1,S} {3,S} {4,S}
196+
3 C u0 p0 c0 {2,S} {6,S} {7,S} {8,S}
197+
4 O u0 p3 c-1 {2,S}
198+
5 H u0 p0 c0 {1,S}
199+
6 H u0 p0 c0 {3,S}
200+
7 H u0 p0 c0 {3,S}
201+
8 H u0 p0 c0 {3,S}''')
202+
203+
self.mol24 = Molecule().fromAdjacencyList('''1 C u0 p0 c0 {2,D} {4,S} {5,S}
204+
2 S u0 p2 c-1 {1,D} {3,S}
205+
3 O u0 p2 c+1 {2,S}
206+
4 H u0 p0 c0 {1,S}
207+
5 H u0 p0 c0 {1,S}''')
208+
209+
self.mol25 = Molecule().fromAdjacencyList('''1 S u0 p1 c0 {2,S} {5,S} {7,S} {8,S}
210+
2 O u0 p2 c0 {1,S} {3,S}
211+
3 S u0 p1 c0 {2,S} {4,S} {9,D}
212+
4 O u0 p2 c0 {3,S} {6,S}
213+
5 H u0 p0 c0 {1,S}
214+
6 H u0 p0 c0 {4,S}
215+
7 H u0 p0 c0 {1,S}
216+
8 H u0 p0 c0 {1,S}
217+
9 O u0 p2 c0 {3,D}''')
218+
219+
self.mol26 = Molecule().fromAdjacencyList('''1 O u0 p3 c-1 {2,S}
220+
2 S u0 p1 c+1 {1,S} {3,D}
221+
3 O u0 p2 c0 {2,D}''')
222+
223+
#self.mol27 = Molecule().fromAdjacencyList('''1 S u0 p1 c0 {2,B} {5,B}
224+
# 2 C u0 p0 c0 {1,B} {3,B} {6,S}
225+
# 3 C u0 p0 c0 {2,B} {4,B} {7,S}
226+
# 4 C u0 p0 c0 {3,B} {5,B} {8,S}
227+
# 5 C u0 p0 c0 {1,B} {4,B} {9,S}
228+
# 6 H u0 p0 c0 {2,S}
229+
# 7 H u0 p0 c0 {3,S}
230+
# 8 H u0 p0 c0 {4,S}
231+
# 9 H u0 p0 c0 {5,S}''')
232+
233+
self.mol28 = Molecule().fromAdjacencyList('''1 O u0 p2 c0 {2,D}
234+
2 S u0 p1 c0 {1,D} {3,D}
235+
3 C u0 p0 c0 {2,D} {4,S} {7,S}
236+
4 C u0 p0 c0 {3,S} {5,T}
237+
5 S u0 p1 c0 {4,T} {6,S}
238+
6 S u0 p0 c0 {5,S} {8,S} {9,S} {10,S} {11,S} {12,S}
239+
7 H u0 p0 c0 {3,S}
240+
8 H u0 p0 c0 {6,S}
241+
9 H u0 p0 c0 {6,S}
242+
10 H u0 p0 c0 {6,S}
243+
11 H u0 p0 c0 {6,S}
244+
12 H u0 p0 c0 {6,S}''')
245+
246+
self.mol29 = Molecule().fromAdjacencyList('''1 C u0 p1 c-1 {2,T}
247+
2 S u0 p1 c+1 {1,T}''')
248+
249+
self.mol30 = Molecule().fromAdjacencyList('''1 S u0 p0 c0 {2,D} {3,S} {4,S} {5,S} {6,S}
250+
2 O u0 p2 c0 {1,D}
251+
3 H u0 p0 c0 {1,S}
252+
4 H u0 p0 c0 {1,S}
253+
5 H u0 p0 c0 {1,S}
254+
6 H u0 p0 c0 {1,S}''')
255+
256+
self.mol31 = Molecule().fromAdjacencyList('''1 O u0 p3 c-1 {2,S}
257+
2 S u0 p0 c+2 {1,S} {3,S} {4,D}
258+
3 O u0 p3 c-1 {2,S}
259+
4 O u0 p2 c0 {2,D}''')
193260

261+
self.mol32 = Molecule().fromAdjacencyList('''1 O u0 p2 c0 {2,D}
262+
2 S u0 p0 c0 {1,D} {3,D} {4,S} {5,S}
263+
3 O u0 p2 c0 {2,D}
264+
4 O u0 p2 c0 {2,S} {6,S}
265+
5 O u0 p2 c0 {2,S} {7,S}
266+
6 H u0 p0 c0 {4,S}
267+
7 H u0 p0 c0 {5,S}''')
194268

195-
self.mol22 = Molecule().fromAdjacencyList('''1 N u0 p2 c-1 {2,S} {3,S}
269+
self.mol33 = Molecule().fromAdjacencyList('''1 O u0 p3 c-1 {2,S}
270+
2 S u0 p0 c+1 {1,S} {3,D} {4,D}
271+
3 O u0 p2 c0 {2,D}
272+
4 O u0 p2 c0 {2,D}''')
273+
274+
self.mol34 = Molecule().fromAdjacencyList('''1 O u0 p2 c0 {2,D}
275+
2 S u0 p0 c0 {1,D} {3,D} {4,D}
276+
3 O u0 p2 c0 {2,D}
277+
4 O u0 p2 c0 {2,D}''')
278+
279+
self.mol35 = Molecule().fromAdjacencyList('''1 S u0 p0 c0 {2,T} {3,S} {4,S} {5,S}
280+
2 N u0 p1 c0 {1,T}
281+
3 H u0 p0 c0 {1,S}
282+
4 H u0 p0 c0 {1,S}
283+
5 H u0 p0 c0 {1,S}''')
284+
285+
self.mol36 = Molecule().fromAdjacencyList('''1 S u0 p0 c0 {2,T} {3,D} {4,S}
286+
2 N u0 p1 c0 {1,T}
287+
3 O u0 p2 c0 {1,D}
288+
4 H u0 p0 c0 {1,S}''')
289+
290+
self.mol37 = Molecule().fromAdjacencyList('''1 N u0 p1 c0 {2,T}
291+
2 S u0 p0 c0 {1,T} {3,T}
292+
3 N u0 p1 c0 {2,T}''')
293+
294+
self.mol38 = Molecule().fromSMILES('O=S=O')
295+
296+
self.mol39 = Molecule().fromAdjacencyList('''1 N u0 p2 c-1 {2,S} {3,S}
196297
2 H u0 p0 c0 {1,S}
197298
3 N u0 p0 c+1 {1,S} {4,T}
198299
4 C u0 p0 c0 {3,T} {5,S}
199300
5 H u0 p0 c0 {4,S}''')
200301

201-
self.mol23 = Molecule().fromAdjacencyList('''1 N u0 p0 c+1 {2,S} {3,T}
302+
self.mol40 = Molecule().fromAdjacencyList('''1 N u0 p0 c+1 {2,S} {3,T}
202303
2 H u0 p0 c0 {1,S}
203304
3 N u0 p0 c+1 {1,T} {4,S}
204305
4 N u0 p3 c-2 {3,S}''')
205306

206307

207-
self.mol24 = Molecule().fromAdjacencyList('''1 N u0 p2 c0 {2,S}
308+
self.mol41 = Molecule().fromAdjacencyList('''1 N u0 p2 c0 {2,S}
208309
2 H u0 p0 c0 {1,S}''')
209310

311+
312+
self.mol42 = Molecule().fromAdjacencyList('''1 N u0 p1 c0 {2,T}
313+
2 N u0 p0 c+1 {1,T} {3,S}
314+
3 S u0 p2 c-1 {2,S} {4,S} {5,S}
315+
4 O u1 p2 c0 {3,S}
316+
5 O u1 p2 c0 {3,S}''')
317+
318+
210319
def atomType(self, mol, atomID):
211320
atom = mol.atoms[atomID]
212321
type = getAtomType(atom, mol.getBonds(atom))
@@ -237,10 +346,10 @@ def testNitrogenTypes(self):
237346
"""
238347
Test that getAtomType() returns appropriate nitrogen atom types.
239348
"""
240-
self.assertEqual(self.atomType(self.mol23, 3), 'N1sc')
241-
self.assertEqual(self.atomType(self.mol24, 0), 'N1s')
349+
self.assertEqual(self.atomType(self.mol40, 3), 'N1sc')
350+
self.assertEqual(self.atomType(self.mol41, 0), 'N1s')
242351
self.assertEqual(self.atomType(self.mol5, 3), 'N1d')
243-
self.assertEqual(self.atomType(self.mol22, 0), 'N2s')
352+
self.assertEqual(self.atomType(self.mol39, 0), 'N2s')
244353
self.assertEqual(self.atomType(self.mol9, 0), 'N3s')
245354
self.assertEqual(self.atomType(self.mol10, 0), 'N3s')
246355
self.assertEqual(self.atomType(self.mol11, 0), 'N3s')
@@ -252,6 +361,7 @@ def testNitrogenTypes(self):
252361
self.assertEqual(self.atomType(self.mol5, 2), 'N5d')
253362
self.assertEqual(self.atomType(self.mol14, 1), 'N5dd')
254363
self.assertEqual(self.atomType(self.mol15, 1), 'N5t')
364+
self.assertEqual(self.atomType(self.mol39, 2), 'N5t')
255365
self.assertEqual(self.atomType(self.mol18, 0), 'N5b')
256366

257367
def testOxygenTypes(self):
@@ -276,9 +386,31 @@ def testSulfurTypes(self):
276386
"""
277387
Test that getAtomType() returns appropriate sulfur atom types.
278388
"""
279-
self.assertEqual(self.atomType(self.mol4, 8), 'S2s')
280-
self.assertEqual(self.atomType(self.mol4, 10), 'S2d')
281-
self.assertEqual(self.atomType(self.mol21, 1), 'St')
389+
self.assertEqual(self.atomType(self.mol21, 0), 'S0s')
390+
self.assertEqual(self.atomType(self.mol22, 0), 'Sa')
391+
self.assertEqual(self.atomType(self.mol23, 0), 'S2s')
392+
#self.assertEqual(self.atomType(self.mol21, 1), 'S2sp')
393+
#self.assertEqual(self.atomType(self.mol42, 2), 'S2sn')
394+
self.assertEqual(self.atomType(self.mol19, 1), 'S2d')
395+
#self.assertEqual(self.atomType(self.mol24, 1), 'S2dc')
396+
self.assertEqual(self.atomType(self.mol25, 0), 'S4s')
397+
#self.assertEqual(self.atomType(self.mol23, 1), 'S4sc')
398+
self.assertEqual(self.atomType(self.mol25, 2), 'S4d')
399+
#self.assertEqual(self.atomType(self.mol26, 1), 'S4dc')
400+
#self.assertEqual(self.atomType(self.mol27, 0), 'S4b') # RMG correctly can't represent heteroatoms in aromatics. See RMG-Py issue #982
401+
self.assertEqual(self.atomType(self.mol28, 1), 'S4dd')
402+
self.assertEqual(self.atomType(self.mol38, 1), 'S4dd')
403+
self.assertEqual(self.atomType(self.mol28, 4), 'S4t')
404+
#self.assertEqual(self.atomType(self.mol29, 1), 'S4tc')
405+
self.assertEqual(self.atomType(self.mol28, 5), 'S6s')
406+
self.assertEqual(self.atomType(self.mol30, 0), 'S6d')
407+
#self.assertEqual(self.atomType(self.mol31, 1), 'S6dc')
408+
self.assertEqual(self.atomType(self.mol32, 1), 'S6dd')
409+
#self.assertEqual(self.atomType(self.mol33, 1), 'S6ddc')
410+
self.assertEqual(self.atomType(self.mol34, 1), 'S6ddd')
411+
self.assertEqual(self.atomType(self.mol35, 0), 'S6t')
412+
self.assertEqual(self.atomType(self.mol36, 0), 'S6td')
413+
self.assertEqual(self.atomType(self.mol37, 1), 'S6tt')
282414

283415
def testOtherTypes(self):
284416
"""
@@ -292,3 +424,4 @@ def testOtherTypes(self):
292424

293425
if __name__ == '__main__':
294426
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
427+

0 commit comments

Comments
 (0)