예제 #1
0
파일: reactTest.py 프로젝트: yplitw/RMG-Py
    def testReactStoreIndices(self):
        """
        Test that reaction generation keeps track of the original species indices.
        """

        indices = {'[OH]': 1, 'CC': 2, '[CH3]': 3}

        # make it bidirectional so that we can look-up indices as well:
        revd = dict([reversed(i) for i in indices.items()])
        indices.update(revd)

        spcA = Species(index=indices['[OH]']).fromSMILES('[OH]')
        spcs = [
            Species(index=indices['CC']).fromSMILES('CC'),
            Species(index=indices['[CH3]']).fromSMILES('[CH3]')
        ]

        spcTuples = [(spcA, spc) for spc in spcs]

        reactionList = list(react(*spcTuples))
        self.assertIsNotNone(reactionList)
        self.assertEquals(len(reactionList), 3)
        for rxn in reactionList:
            for i, reactant in enumerate(rxn.reactants):
                rxn.reactants[i] = Molecule().fromSMILES(indices[reactant])
            self.assertTrue(rxn.isBalanced())
예제 #2
0
    def testReact(self):
        """
        Test that reaction generation from the available families works.
        """
        spcA = Species().fromSMILES('[OH]')
        spcs = [Species().fromSMILES('CC'), Species().fromSMILES('[CH3]')]

        reactionList = list(react(spcA, spcs))
        self.assertIsNotNone(reactionList)
        self.assertTrue(all([isinstance(rxn, TemplateReaction) for rxn in reactionList]))
예제 #3
0
    def testReact(self):
        """
        Test that reaction generation from the available families works.
        """
        spcA = Species().fromSMILES('[OH]')
        spcs = [Species().fromSMILES('CC'), Species().fromSMILES('[CH3]')]

        reactionList = list(react(spcA, spcs))
        self.assertIsNotNone(reactionList)
        self.assertTrue(all([isinstance(rxn, TemplateReaction) for rxn in reactionList]))
예제 #4
0
파일: parreactTest.py 프로젝트: nyee/RMG-Py
def generate():
    """
    Test that reaction generation from the available families works.
    """
    load()
    spcA = Species().fromSMILES('[OH]')
    spcs = [Species().fromSMILES('CC'), Species().fromSMILES('[CH3]')]

    reactionList = list(react(spcA, spcs))

    if not reactionList: return False

    for rxn in reactionList:
        if not isinstance(rxn, TemplateReaction): return False

    return True
예제 #5
0
def generate():
    """
    Test that reaction generation from the available families works.
    """
    load()
    spcA = Species().fromSMILES('[OH]')
    spcs = [Species().fromSMILES('CC'), Species().fromSMILES('[CH3]')]

    reactionList = list(react(spcA, spcs))

    if not reactionList: return False

    for rxn in reactionList:
        if not isinstance(rxn, TemplateReaction): return False

    return True
예제 #6
0
def generate():
    """
    Test that reaction generation from the available families works.
    """
    load()
    spcA = Species().fromSMILES('[OH]')
    spcs = [Species().fromSMILES('CC'), Species().fromSMILES('[CH3]')]
    spcTuples = [(spcA, spc) for spc in spcs]
    procnum = 2

    reactionList = list(
        itertools.chain.from_iterable(react(spcTuples, procnum)))

    if not reactionList: return False

    for rxn in reactionList:
        if not isinstance(rxn, TemplateReaction): return False

    return True
예제 #7
0
    def testReactStoreIndices(self):
        """
        Test that reaction generation keeps track of the original species indices.
        """

        indices = {'[OH]':1, 'CC':2, '[CH3]':3}

        # make it bidirectional so that we can look-up indices as well:
        revd=dict([reversed(i) for i in indices.items()])
        indices.update(revd)

        spcA = Species(index=indices['[OH]']).fromSMILES('[OH]')
        spcs = [Species(index=indices['CC']).fromSMILES('CC'),
                Species(index=indices['[CH3]']).fromSMILES('[CH3]')]

        reactionList = list(react(spcA, spcs))
        self.assertIsNotNone(reactionList)
        self.assertEquals(len(reactionList), 3)
        for rxn in reactionList:
            for i, reactant in enumerate(rxn.reactants):
                rxn.reactants[i] = Molecule().fromSMILES(indices[reactant])
            self.assertTrue(rxn.isBalanced())