diff --git a/rmgpy/molecule/molecule.py b/rmgpy/molecule/molecule.py index cd1cac7104..9e69e06a38 100644 --- a/rmgpy/molecule/molecule.py +++ b/rmgpy/molecule/molecule.py @@ -567,6 +567,8 @@ def applyAction(self, action): self.incrementOrder() elif action[2] == -1: self.decrementOrder() + elif action[2] == 'B': + self.order = 'B' else: raise ActionError('Unable to update Bond due to CHANGE_BOND action: Invalid order "{0}".'.format(action[2])) else: diff --git a/rmgpy/molecule/symmetry.py b/rmgpy/molecule/symmetry.py index c9dd35e0f2..e938e06dc9 100644 --- a/rmgpy/molecule/symmetry.py +++ b/rmgpy/molecule/symmetry.py @@ -343,9 +343,12 @@ def calculateCyclicSymmetryNumber(molecule): Get the symmetry number correction for cyclic regions of a molecule. For complicated fused rings the smallest set of smallest rings is used. """ - + from rdkit.Chem.rdmolops import SanitizeMol + from rdkit.Chem.rdchem import Mol + mcopy = molecule.toRDKitMol(removeHs=True, returnMapping=False) + SanitizeMol(mcopy) symmetryNumber = 1 - + # Get symmetry number for each ring in structure rings = molecule.getSmallestSetOfSmallestRings() for ring0 in rings: @@ -353,7 +356,18 @@ def calculateCyclicSymmetryNumber(molecule): # Make copy of structure structure = molecule.copy(True) ring = [structure.atoms[molecule.atoms.index(atom)] for atom in ring0] - + # Figure out which atoms and bonds are aromatic and reassign appropriately: + for i, atom1 in enumerate(ring0): + for atom2 in ring0[i+1:]: + if molecule.hasBond(atom1, atom2): + if str(mcopy.GetBondBetweenAtoms(i,i+1)) != 'None': + if str(mcopy.GetBondBetweenAtoms(i,i+1).GetBondType()) == 'AROMATIC': + bond = molecule.getBond(atom1, atom2) + bond.applyAction(['CHANGE_BOND', atom1, 'B', atom2]) + atom1.atomType.label = 'Cb' + atom2.atomType.label = 'Cb' + else: + pass # Remove bonds of ring from structure for i, atom1 in enumerate(ring): for atom2 in ring[i+1:]: diff --git a/rmgpy/molecule/symmetryTest.py b/rmgpy/molecule/symmetryTest.py index 953a857d9c..533f3750d4 100644 --- a/rmgpy/molecule/symmetryTest.py +++ b/rmgpy/molecule/symmetryTest.py @@ -244,7 +244,6 @@ def testCyclicSymmetryNumberCyclohexane(self): symmetryNumber = calculateCyclicSymmetryNumber(molecule) self.assertEqual(symmetryNumber, 12) - @work_in_progress def testCyclicSymmetryNumberBenzene(self): """ Test the Molecule.calculateCyclicSymmetryNumber() method.