def test12Cycloaddition(self): """Test 1+2_Cycloaddition reactions""" self.loadDatabase(only_families=['1+2_Cycloaddition']) for smile in ['O1OO1' ]: structure1 = Structure(SMILES=smile) species1, isNew = makeNewSpecies(structure1) print 'Reacting species',species1 # wipe the reaction list reaction.reactionDict = {} rxns = reaction.kineticsDatabase.getReactions([species1]) for rxn in rxns: print 'Reaction family:',rxn.family print 'Reaction:',rxn print 'Kinetics:',rxn.kinetics print all_products = [] for rxn in rxns: #self.assertEqual(rxn.family.label,'Cyclic colligation',"Was trying to test 'Cyclic colligation' but made a reaction from family %s"%rxn.family) #self.assertEqual(len(rxn.reactants),1,"Reaction %s wasn't unimolecular"%rxn) #self.assertEqual(len(rxn.products),1,"Reaction %s wasn't unimolecular"%rxn) all_products.extend(rxn.products) print "All products for reacting %s:"%species1, [p.structure[0] for p in all_products] structure2 = Structure() structure2.fromAdjacencyList("O2\n1 O 0 {2,D}\n2 O 0 {1,D}\n") species2 = makeNewSpecies(structure2) structure3 = Structure() structure3.fromAdjacencyList("O\n1 O 2\n") species3 = makeNewSpecies(structure3) reaction.reactionDict = {} print "Now reacting %s with %s:"%(species2, species3) for sp in (species2, species3): print sp.toAdjacencyList() rxns = reaction.kineticsDatabase.getReactions([species2,species3]) for rxn in rxns: print 'Reaction family:',rxn.family print 'Reaction:',rxn print 'Kinetics:',rxn.kinetics self.assertEqual(len(rxns),1, "Made %d 1+2_Cycloaddition reactions instead of 1"%(len(rxns)))
def testMakeNewReaction(self): """Create a new reaction and check you can identify the reverse""" structure1 = Structure() structure1.fromAdjacencyList(""" 1 C 0 {2,D} {7,S} {8,S} 2 C 0 {1,D} {3,S} {9,S} 3 C 0 {2,S} {4,D} {10,S} 4 C 0 {3,D} {5,S} {11,S} 5 *1 C 0 {4,S} {6,S} {12,S} {13,S} 6 C 0 {5,S} {14,S} {15,S} {16,S} 7 H 0 {1,S} 8 H 0 {1,S} 9 H 0 {2,S} 10 H 0 {3,S} 11 H 0 {4,S} 12 *2 H 0 {5,S} 13 H 0 {5,S} 14 H 0 {6,S} 15 H 0 {6,S} 16 H 0 {6,S} """) structure2 = Structure() structure2.fromAdjacencyList(""" 1 *3 H 1 """) structure3 = Structure() structure3.fromAdjacencyList(""" 1 C 0 {2,D} {7,S} {8,S} 2 C 0 {1,D} {3,S} {9,S} 3 C 0 {2,S} {4,D} {10,S} 4 C 0 {3,D} {5,S} {11,S} 5 *3 C 1 {4,S} {6,S} {12,S} 6 C 0 {5,S} {13,S} {14,S} {15,S} 7 H 0 {1,S} 8 H 0 {1,S} 9 H 0 {2,S} 10 H 0 {3,S} 11 H 0 {4,S} 12 H 0 {5,S} 13 H 0 {6,S} 14 H 0 {6,S} 15 H 0 {6,S} """) structure4 = Structure() structure4.fromAdjacencyList(""" 1 *1 H 0 {2,S} 2 *2 H 0 {1,S} """) C6H10 = makeNewSpecies(structure1) H = makeNewSpecies(structure2) C6H9 = makeNewSpecies(structure3) H2 = makeNewSpecies(structure4) # wipe the reaction list reaction.reactionList=[] reaction1, isNew = makeNewReaction([C6H9, H2], [C6H10, H], \ [C6H9.structure[0], H2.structure[0]], \ [C6H10.structure[0], H.structure[0]], \ None) self.assertFalse(reaction1 is None) self.assertTrue(isNew) reaction2, isNew = makeNewReaction([C6H10, H], [C6H9, H2], \ [C6H10.structure[0], H.structure[0]], \ [C6H9.structure[0], H2.structure[0]], \ None) self.assertTrue(reaction1 is reaction2) self.assertFalse(isNew)