コード例 #1
0
 def testAxisSymmetryNumberAllyl(self):
     """
     Test the Molecule.calculateAxisSymmetryNumber() on [CH2]C=C
     """
     spc = Species(molecule=[Molecule().fromSMILES('[CH2]C=C')])
     molecule = spc.getResonanceHybrid()
     self.assertEqual(calculateAxisSymmetryNumber(molecule), 1)
コード例 #2
0
ファイル: symmetryTest.py プロジェクト: yplitw/RMG-Py
 def testAxisSymmetryNumberAllyl(self):
     """
     Test the Molecule.calculateAxisSymmetryNumber() on [CH2]C=C
     """
     spc = Species(molecule=[Molecule().fromSMILES('[CH2]C=C')])
     molecule = spc.getResonanceHybrid()
     self.assertEqual(calculateAxisSymmetryNumber(molecule), 1)
コード例 #3
0
ファイル: speciesTest.py プロジェクト: cainja/RMG-Py
 def testGetResonanceHybrid(self):
     """
     Tests that getResonanceHybrid returns an isomorphic structure
     which has intermediate bond orders.
     
     This check is for C=C[CH]CC which has another resonance structure,
     [CH2]C=CC. When these structures are merged, the bond structure should be,
     C~C~CC, where '~' is a hybrid bond of order 1.5. 
     """
     spec = Species().fromSMILES('C=C[CH]CC')
     hybridMol = spec.getResonanceHybrid()
     
     self.assertTrue(hybridMol.toSingleBonds().isIsomorphic(spec.molecule[0].toSingleBonds()))
     
     # a rough check for intermediate bond orders
     expected_orders = [1,1.5]
     bonds = []
     # ensure all bond orders are expected
     for atom in hybridMol.atoms:
         for atom2 in atom.bonds:
             bond = hybridMol.getBond(atom,atom2)
             self.assertTrue(any([bond.isOrder(otherOrder) for otherOrder in expected_orders]), 'Unexpected bond order {}'.format(bond.getOrderNum()))
             bonds.append(bond)
             
     # ensure all expected orders are present
     for expected_order in expected_orders:
         self.assertTrue(any([bond.isOrder(expected_order) for bond in bonds]),'No bond of order {} found'.format(expected_order))
コード例 #4
0
    def testGetResonanceHybrid(self):
        """
        Tests that getResonanceHybrid returns an isomorphic structure
        which has intermediate bond orders.
        
        This check is for C=C[CH]CC which has another resonance structure,
        [CH2]C=CC. When these structures are merged, the bond structure should be,
        C~C~CC, where '~' is a hybrid bond of order 1.5. 
        """
        spec = Species().fromSMILES('C=C[CH]CC')
        hybridMol = spec.getResonanceHybrid()

        self.assertTrue(hybridMol.toSingleBonds().isIsomorphic(
            spec.molecule[0].toSingleBonds()))

        # a rough check for intermediate bond orders
        expected_orders = [1, 1.5]
        bonds = []
        # ensure all bond orders are expected
        for atom in hybridMol.atoms:
            for atom2 in atom.bonds:
                bond = hybridMol.getBond(atom, atom2)
                self.assertTrue(
                    any([
                        bond.isOrder(otherOrder)
                        for otherOrder in expected_orders
                    ]), 'Unexpected bond order {}'.format(bond.getOrderNum()))
                bonds.append(bond)

        # ensure all expected orders are present
        for expected_order in expected_orders:
            self.assertTrue(
                any([bond.isOrder(expected_order) for bond in bonds]),
                'No bond of order {} found'.format(expected_order))
コード例 #5
0
ファイル: drawTest.py プロジェクト: cainja/RMG-Py
 def testDrawNonStandardBonds(self):
     
     spec = Species().fromSMILES('[CH2]C=C[CH2]')
     hybrid = spec.getResonanceHybrid()
     try:
         from cairocffi import PDFSurface
     except ImportError:
         from cairo import PDFSurface
     surface, cr, (xoff, yoff, width, height) = self.drawer.draw(hybrid, format='pdf')
     self.assertIsInstance(surface, PDFSurface)
コード例 #6
0
ファイル: drawTest.py プロジェクト: z5476t4508/RMG-Py
 def testDrawNonStandardBonds(self):
     
     spec = Species().fromSMILES('[CH2]C=C[CH2]')
     hybrid = spec.getResonanceHybrid()
     try:
         from cairocffi import PDFSurface
     except ImportError:
         from cairo import PDFSurface
     surface, cr, (xoff, yoff, width, height) = self.drawer.draw(hybrid, format='pdf')
     self.assertIsInstance(surface, PDFSurface)
コード例 #7
0
 def testAtomSymmetryNumberAllyl(self):
     """
     Test the Molecule.calculateAtomSymmetryNumber() on [CH2]C=C
     """
     spc = Species(molecule=[Molecule().fromSMILES('[CH2]C=C')])
     molecule = spc.getResonanceHybrid()
     symmetryNumber = 1
     for atom in molecule.atoms:
         if not molecule.isAtomInCycle(atom):
             symmetryNumber *= calculateAtomSymmetryNumber(molecule, atom)
     self.assertEqual(symmetryNumber, 2)
コード例 #8
0
ファイル: symmetryTest.py プロジェクト: yplitw/RMG-Py
 def testAtomSymmetryNumberAllyl(self):
     """
     Test the Molecule.calculateAtomSymmetryNumber() on [CH2]C=C
     """
     spc = Species(molecule=[Molecule().fromSMILES('[CH2]C=C')])
     molecule = spc.getResonanceHybrid()
     symmetryNumber = 1
     for atom in molecule.atoms:
         if not molecule.isAtomInCycle(atom):
             symmetryNumber *= calculateAtomSymmetryNumber(molecule, atom)
     self.assertEqual(symmetryNumber, 2)
コード例 #9
0
 def testBondSymmetryNumberAllyl(self):
     """
     Test the Molecule.calculateBondSymmetryNumber() on [CH2]C=C
     """
     spc = Species(molecule=[Molecule().fromSMILES('[CH2]C=C')])
     molecule = spc.getResonanceHybrid()
     symmetryNumber = 1
     for atom1 in molecule.atoms:
         for atom2 in atom1.bonds:
             if molecule.atoms.index(atom1) < molecule.atoms.index(atom2):
                 symmetryNumber *= calculateBondSymmetryNumber(molecule, atom1, atom2)
     self.assertEqual(symmetryNumber, 1)
コード例 #10
0
ファイル: symmetryTest.py プロジェクト: DrDew2/RMG-Py
 def testBondSymmetryNumberAllyl(self):
     """
     Test the Molecule.calculateBondSymmetryNumber() on [CH2]C=C
     """
     spc = Species(molecule=[Molecule().fromSMILES('[CH2]C=C')])
     molecule = spc.getResonanceHybrid()
     symmetryNumber = 1
     for atom1 in molecule.atoms:
         for atom2 in atom1.bonds:
             if molecule.atoms.index(atom1) < molecule.atoms.index(atom2):
                 symmetryNumber *= calculateBondSymmetryNumber(molecule, atom1, atom2)
     self.assertEqual(symmetryNumber, 1)
コード例 #11
0
 def testEdgeCarbonAtomSymmetryNumberAllyl(self):
     """
     Test the Molecule.calculateAtomSymmetryNumber() for the edge carbons
     on [CH2]C=C
     """
     spc = Species(molecule=[Molecule().fromSMILES('[CH2]C=C')])
     molecule = spc.getResonanceHybrid()
     for atom in molecule.atoms:
         if atom.symbol =='C':
             number_carbon_bonds = sum([1 for bond in atom.bonds if bond.symbol=='C'])
             if number_carbon_bonds == 1:
                 atom.label = 'edge'
                 symmetryNumber = calculateAtomSymmetryNumber(molecule, atom)
                 self.assertEqual(symmetryNumber, 1)
コード例 #12
0
ファイル: symmetryTest.py プロジェクト: DrDew2/RMG-Py
 def testEdgeCarbonAtomSymmetryNumberAllyl(self):
     """
     Test the Molecule.calculateAtomSymmetryNumber() for the edge carbons
     on [CH2]C=C
     """
     spc = Species(molecule=[Molecule().fromSMILES('[CH2]C=C')])
     molecule = spc.getResonanceHybrid()
     for atom in molecule.atoms:
         if atom.symbol =='C':
             number_carbon_bonds = sum([1 for bond in atom.bonds if bond.symbol=='C'])
             if number_carbon_bonds == 1:
                 atom.label = 'edge'
                 symmetryNumber = calculateAtomSymmetryNumber(molecule, atom)
                 self.assertEqual(symmetryNumber, 1)
コード例 #13
0
 def testMiddleCarbonAtomSymmetryNumberAllylUsingResonanceHybrid(self):
     """
     Test the Molecule.calculateAtomSymmetryNumber() for the middle carbon
     on [CH2]C=C using the resonance hybrid structure
     """
     molecule = Molecule().fromSMILES('[CH2]C=C')
     species = Species(molecule=[molecule])
     resonanceHybrid = species.getResonanceHybrid()
     for atom in resonanceHybrid.atoms:
         if atom.symbol == 'C':
             number_carbon_bonds = sum([1 for bond in atom.bonds if bond.symbol=='C'])
             if number_carbon_bonds == 2:
                 atom.label = 'center'
                 symmetryNumber = calculateAtomSymmetryNumber(resonanceHybrid, atom)
                 self.assertEqual(symmetryNumber, 2)
                 pass
コード例 #14
0
ファイル: symmetryTest.py プロジェクト: DrDew2/RMG-Py
 def testMiddleCarbonAtomSymmetryNumberAllylUsingResonanceHybrid(self):
     """
     Test the Molecule.calculateAtomSymmetryNumber() for the middle carbon
     on [CH2]C=C using the resonance hybrid structure
     """
     molecule = Molecule().fromSMILES('[CH2]C=C')
     species = Species(molecule=[molecule])
     resonanceHybrid = species.getResonanceHybrid()
     for atom in resonanceHybrid.atoms:
         if atom.symbol == 'C':
             number_carbon_bonds = sum([1 for bond in atom.bonds if bond.symbol=='C'])
             if number_carbon_bonds == 2:
                 atom.label = 'center'
                 symmetryNumber = calculateAtomSymmetryNumber(resonanceHybrid, atom)
                 self.assertEqual(symmetryNumber, 2)
                 pass