コード例 #1
0
ファイル: groupTest.py プロジェクト: connie/RMG-Py
    def testMakeSampleMolecule(self):
        """
        Test the Group.makeSampleMolecule method
        """

        def performSampMoleComparison(adjlist, answer_smiles):
            """
            Creates a sample molecule from the adjlist and returns if it is isomorphic to a molecule created from
            the inputted smiles
            """
            group = Group().fromAdjacencyList(adjlist)
            result = group.makeSampleMolecule()
            return (result.isIsomorphic(Molecule().fromSMILES(answer_smiles)))
########################################################################################################################
        #tests adding implicit atoms
        adjlist = """
1  *1 Cd u0
            """
        answer_smiles = 'C=C'
        self.assertTrue(performSampMoleComparison(adjlist, answer_smiles))

        #test creating implicit benzene atoms
        adjlist2 = """
1  *1 Cbf u0 {2,B}
2     Cbf u0 {1,B}
            """

        group2 = Group().fromAdjacencyList(adjlist2)
        result2 = group2.makeSampleMolecule()
        naphthaleneMolecule = Molecule().fromSMILES('C1=CC=C2C=CC=CC2=C1')
        resonanceList2=naphthaleneMolecule.generateResonanceIsomers()
        self.assertTrue(any([result2.isIsomorphic(x) for x in resonanceList2]))

        #test the creation of a positively charged species
        adjlist = """
1  *1 N5s u0
        """
        answer_smiles = '[NH4+]'
        self.assertTrue(performSampMoleComparison(adjlist, answer_smiles))

        #test the creation of a negatively charged species
        #commented out until new nitrogen atom types added in
#         adjlist = """
# 1  *1 N2s u0
#         """
#         answer_smiles = '[NH2-]'
#         self.assertTrue(performSampMoleComparison(adjlist, answer_smiles))

        #test creation of charged species when some single bonds present
        adjlist = """
1 *2 [N5s,N5d] u0 {2,S} {3,S}
2 *3 R!H       u1 {1,S}
3 *4 H         u0 {1,S}
"""
        answer_smiles = '[NH3+][CH2]'
        self.assertTrue(performSampMoleComparison(adjlist, answer_smiles))
コード例 #2
0
ファイル: groupTest.py プロジェクト: bslakman/RMG-Py
    def testMakeSampleMolecule(self):
        """
        Test the Group.makeSampleMolecule method
        """

        # result = self.group.makeSampleMolecule()
        # print result.multiplicity
        # self.assertTrue(result.isIsomorphic(Molecule().fromSMILES('OCC')))

        #tests adding implicit atoms
        adjlist1 = """
1  *1 Cd u0
            """

        group1 = Group().fromAdjacencyList(adjlist1)
        result1 = group1.makeSampleMolecule()
        self.assertTrue(result1.isIsomorphic(Molecule().fromSMILES('C=C')))

        #test creating implicit benzene atoms
        adjlist2 = """
1  *1 Cbf u0 {2,B}
2     Cbf u0 {1,B}
            """

        group2 = Group().fromAdjacencyList(adjlist2)
        result2 = group2.makeSampleMolecule()
        naphthaleneMolecule = Molecule().fromSMILES('C1=CC=C2C=CC=CC2=C1')
        resonanceList2 = naphthaleneMolecule.generateResonanceIsomers()
        self.assertTrue(any([result2.isIsomorphic(x) for x in resonanceList2]))

        #test the creation of a charged species
        adjlist3 = """
1  *1 N5s u0
        """

        group3 = Group().fromAdjacencyList(adjlist3)
        result3 = group3.makeSampleMolecule()
        self.assertTrue(result3.isIsomorphic(Molecule().fromSMILES('[NH4+]')))

        #test creation of charged species when some single bonds present
        adjlist4 = """
1 *2 [N5s,N5d] u0 {2,S} {3,S}
2 *3 R!H       u1 {1,S}
3 *4 H         u0 {1,S}
"""
        group4 = Group().fromAdjacencyList(adjlist4)
        result4 = group4.makeSampleMolecule()
        self.assertTrue(
            result4.isIsomorphic(Molecule().fromSMILES('[NH3+][CH2]')))
コード例 #3
0
ファイル: groupTest.py プロジェクト: wangyuran/RMG-Py
    def testMakeSampleMolecule(self):
        """
        Test the Group.makeSampleMolecule method
        """

        # result = self.group.makeSampleMolecule()
        # print result.multiplicity
        # self.assertTrue(result.isIsomorphic(Molecule().fromSMILES('OCC')))

        #tests adding implicit atoms
        adjlist1 = """
1  *1 Cd u0
            """

        group1 = Group().fromAdjacencyList(adjlist1)
        result1 = group1.makeSampleMolecule()
        self.assertTrue(result1.isIsomorphic(Molecule().fromSMILES('C=C')))

        #test creating implicit benzene atoms
        adjlist2 = """
1  *1 Cbf u0 {2,B}
2     Cbf u0 {1,B}
            """

        group2 = Group().fromAdjacencyList(adjlist2)
        result2 = group2.makeSampleMolecule()
        naphthaleneMolecule = Molecule().fromSMILES('C1=CC=C2C=CC=CC2=C1')
        resonanceList2=naphthaleneMolecule.generateResonanceIsomers()
        self.assertTrue(any([result2.isIsomorphic(x) for x in resonanceList2]))

        #test the creation of a charged species
        adjlist3 = """
1  *1 N5s u0
        """

        group3 = Group().fromAdjacencyList(adjlist3)
        result3 = group3.makeSampleMolecule()
        self.assertTrue(result3.isIsomorphic(Molecule().fromSMILES('[NH4+]')))

        #test creation of charged species when some single bonds present
        adjlist4 = """
1 *2 [N5s,N5d] u0 {2,S} {3,S}
2 *3 R!H       u1 {1,S}
3 *4 H         u0 {1,S}
"""
        group4 = Group().fromAdjacencyList(adjlist4)
        result4 = group4.makeSampleMolecule()
        self.assertTrue(result4.isIsomorphic(Molecule().fromSMILES('[NH3+][CH2]')))
コード例 #4
0
"""
Used to compare thermo data between high level calcs in a paper and those generated by group
additivity in RMG-Py
"""
from rmgpy.data.rmg import RMGDatabase
from rmgpy import settings
from rmgpy.molecule import Molecule
from rmgpy.species import Species
###################################
rmg_database = RMGDatabase()
rmg_database.load(settings['database.directory'],
                  kineticsFamilies='none',
                  reactionLibraries=[])

with open('/Users/belinda/Code/RMG-Py/SiH_rad_thermo_Katzer.txt',
          'r') as thermo_data:
    rad_species = thermo_data.read().split('\n\n')
    for entry in rad_species:
        label = entry.split('\n')[0]
        adj_list = ""
        for line in entry.split('\n')[1:]:
            if 'u' in line: adj_list += line + '\n'
            else: break
    # print adj_list
        H298 = entry.split('\n')[-1]
        mol = Molecule().fromAdjacencyList(adj_list)
        thermoData = rmg_database.thermo.getThermoDataFromGroups(
            Species(molecule=mol.generateResonanceIsomers()))
        print label + '\t' + H298 + '\t' + str(
            thermoData.H298.value_si / 1000) + '\t' + thermoData.comment