def test_predict_with_multiple_solutions(self): """Test prediction where multiple solutions exist (TALA).""" reaction = parse_reaction( 'r5p[c] + xu5p-D[c] <=> g3p[c] + s7p[c]') formulas = { 'r5p': Formula.parse('C5H9O8P'), 'xu5p-D': Formula.parse('C5H9O8P'), 'g3p': Formula.parse('C3H5O6P'), 's7p': Formula.parse('C7H13O10P'), } solutions = list( mapmaker.predict_compound_pairs(reaction, formulas, self.solver)) self.assertEqual(len(solutions), 2) # Solution A self.assertIn({ (Compound('r5p', 'c'), Compound('s7p', 'c')): Formula.parse('C5O8P'), (Compound('xu5p-D', 'c'), Compound('g3p', 'c')): Formula.parse('C3O6P'), (Compound('xu5p-D', 'c'), Compound('s7p', 'c')): Formula.parse('C2O2'), }, solutions) # Solution B self.assertIn({ (Compound('xu5p-D', 'c'), Compound('s7p', 'c')): Formula.parse('C5O8P'), (Compound('r5p', 'c'), Compound('g3p', 'c')): Formula.parse('C3O6P'), (Compound('r5p', 'c'), Compound('s7p', 'c')): Formula.parse('C2O2'), }, solutions)
def test_predict_with_multiple_solutions(self): """Test prediction where multiple solutions exist (TALA).""" reaction = parse_reaction( 'r5p[c] + xu5p-D[c] <=> g3p[c] + s7p[c]') formulas = { 'r5p': Formula.parse('C5H9O8P'), 'xu5p-D': Formula.parse('C5H9O8P'), 'g3p': Formula.parse('C3H5O6P'), 's7p': Formula.parse('C7H13O10P'), } solutions = list( mapmaker.predict_compound_pairs(reaction, formulas, self.solver)) self.assertEqual(len(solutions), 2) # Solution A self.assertIn({ (Compound('r5p', 'c'), Compound('s7p', 'c')): Formula.parse('C5O8P'), (Compound('xu5p-D', 'c'), Compound('g3p', 'c')): Formula.parse('C3O6P'), (Compound('xu5p-D', 'c'), Compound('s7p', 'c')): Formula.parse('C2O2'), }, solutions) # Solution B self.assertIn({ (Compound('xu5p-D', 'c'), Compound('s7p', 'c')): Formula.parse('C5O8P'), (Compound('r5p', 'c'), Compound('g3p', 'c')): Formula.parse('C3O6P'), (Compound('r5p', 'c'), Compound('s7p', 'c')): Formula.parse('C2O2'), }, solutions)
def test_predict_compound_pairs(self): """Test prediction of HEX1 reaction.""" reaction = parse_reaction( 'atp[c] + glc-D[c] => adp[c] + g6p[c] + h[c]') formulas = { 'atp': Formula.parse('C10H12N5O13P3'), 'adp': Formula.parse('C10H12N5O10P2'), 'glc-D': Formula.parse('C6H12O6'), 'g6p': Formula.parse('C6H11O9P'), 'h': Formula.parse('H') } solutions = list( mapmaker.predict_compound_pairs(reaction, formulas, self.solver)) self.assertEqual(len(solutions), 1) self.assertEqual( solutions[0], { (Compound('atp', 'c'), Compound('adp', 'c')): Formula.parse('C10N5O10P2'), (Compound('glc-D', 'c'), Compound('g6p', 'c')): Formula.parse('C6O6'), (Compound('atp', 'c'), Compound('g6p', 'c')): Formula.parse('O3P'), })
def test_predict_compound_pairs_unbalanced(self): """Test prediction of (non-sense) unbalanced reaction.""" reaction = parse_reaction( 'a[c] <=> b[c] + c[c]') formulas = { 'a': Formula.parse('C10H12'), 'b': Formula.parse('C9H11'), 'c': Formula.parse('CO2'), } with self.assertRaises(mapmaker.UnbalancedReactionError): list(mapmaker.predict_compound_pairs( reaction, formulas, self.solver))
def test_predict_compound_pairs_unbalanced(self): """Test prediction of (non-sense) unbalanced reaction.""" reaction = parse_reaction( 'a[c] <=> b[c] + c[c]') formulas = { 'a': Formula.parse('C10H12'), 'b': Formula.parse('C9H11'), 'c': Formula.parse('CO2'), } with self.assertRaises(mapmaker.UnbalancedReactionError): list(mapmaker.predict_compound_pairs( reaction, formulas, self.solver))
def test_predict_compound_pairs_multiple(self): """Test prediction of reaction with multiple instances.""" reaction = parse_reaction( 'a[c] <=> (2) b[c] + c[c]') formulas = { 'a': Formula.parse('C10H13O6'), 'b': Formula.parse('C5H6O3'), 'c': Formula.parse('H'), } solutions = list( mapmaker.predict_compound_pairs(reaction, formulas, self.solver)) self.assertEqual(len(solutions), 1) self.assertEqual(solutions[0], { (Compound('a', 'c'), Compound('b', 'c')): Formula.parse('C10O6'), })
def test_predict_compound_pairs_multiple(self): """Test prediction of reaction with multiple instances.""" reaction = parse_reaction( 'a[c] <=> (2) b[c] + c[c]') formulas = { 'a': Formula.parse('C10H13O6'), 'b': Formula.parse('C5H6O3'), 'c': Formula.parse('H'), } solutions = list( mapmaker.predict_compound_pairs(reaction, formulas, self.solver)) self.assertEqual(len(solutions), 1) self.assertEqual(solutions[0], { (Compound('a', 'c'), Compound('b', 'c')): Formula.parse('C10O6'), })
def test_predict_compound_pairs(self): """Test prediction of HEX1 reaction.""" reaction = parse_reaction( 'atp[c] + glc-D[c] => adp[c] + g6p[c] + h[c]') formulas = { 'atp': Formula.parse('C10H12N5O13P3'), 'adp': Formula.parse('C10H12N5O10P2'), 'glc-D': Formula.parse('C6H12O6'), 'g6p': Formula.parse('C6H11O9P'), 'h': Formula.parse('H') } solutions = list( mapmaker.predict_compound_pairs(reaction, formulas, self.solver)) self.assertEqual(len(solutions), 1) self.assertEqual(solutions[0], { (Compound('atp', 'c'), Compound('adp', 'c')): Formula.parse('C10N5O10P2'), (Compound('glc-D', 'c'), Compound('g6p', 'c')): Formula.parse('C6O6'), (Compound('atp', 'c'), Compound('g6p', 'c')): Formula.parse('O3P'), })