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())
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]))
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
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
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())