Skip to content

Commit

Permalink
Add unit test for heteroatom+aromatic resonance structure generation
Browse files Browse the repository at this point in the history
Also update work-in-progress test
  • Loading branch information
mliu49 committed May 14, 2019
1 parent 1e6b733 commit 7e3aa31
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions rmgpy/molecule/resonanceTest.py
Expand Up @@ -258,13 +258,37 @@ def testAromaticWithLonePairResonance(self):
molList = generate_resonance_structures(Molecule(SMILES="c1ccccc1CC=N[O]"))
self.assertEqual(len(molList), 4)

@work_in_progress
def testAromaticWithNResonance(self):
"""Test resonance structure generation for aromatic species with N5ddc <=> N5tc resonance"""
# WIP: currently generate_N5dc_resonance_structures does not apply for aromatic structures
"""Test resonance structure generation for aromatic species with lone pair resonance"""
molList = generate_resonance_structures(Molecule(SMILES="c1ccccc1CCN=[N+]=[N-]"))
self.assertEqual(len(molList), 4)
# TODO: this test cannot be run because RDKit (which checks for aromaticity) cannot process hyper-valence N
self.assertEqual(len(molList), 2)

def testAromaticWithONResonance(self):
"""Test resonance structure generation for aromatic species with heteroatoms
This test was specifically designed to recreate RMG-Py issue #1598.
Key conditions: having heteroatoms, starting with aromatic structure, and keep_isomorphic=True
"""
molList = generate_resonance_structures(Molecule().fromAdjacencyList("""
multiplicity 2
1 O u0 p2 c0 {4,S} {16,S}
2 O u1 p2 c0 {4,S}
3 O u0 p3 c-1 {4,S}
4 N u0 p0 c+1 {1,S} {2,S} {3,S} {5,S}
5 C u0 p0 c0 {4,S} {6,B} {7,B}
6 C u0 p0 c0 {5,B} {8,B} {11,S}
7 C u0 p0 c0 {5,B} {10,B} {15,S}
8 C u0 p0 c0 {6,B} {9,B} {12,S}
9 C u0 p0 c0 {8,B} {10,B} {13,S}
10 C u0 p0 c0 {7,B} {9,B} {14,S}
11 H u0 p0 c0 {6,S}
12 H u0 p0 c0 {8,S}
13 H u0 p0 c0 {9,S}
14 H u0 p0 c0 {10,S}
15 H u0 p0 c0 {7,S}
16 H u0 p0 c0 {1,S}
"""), keep_isomorphic=True)
self.assertEqual(len(molList), 1)

def testNoClarStructures(self):
"""Test that we can turn off Clar structure generation."""
Expand Down

0 comments on commit 7e3aa31

Please sign in to comment.