def test_one_left_to_right_reaction_set_positive_ub(self):

            model = Model("Toy Model")

            m1 = Metabolite("M1")
            d1 = Reaction("ex1")
            d1.add_metabolites({m1: -1})
            d1.upper_bound = 0
            d1.lower_bound = -1000
            model.add_reactions([d1])
            self.assertEqual(d1.reverse_variable.lb, 0)
            self.assertEqual(d1.reverse_variable.ub, 1000)
            self.assertEqual(d1._lower_bound, -1000)
            self.assertEqual(d1.lower_bound, -1000)
            self.assertEqual(d1._upper_bound, 0)
            self.assertEqual(d1.upper_bound, 0)
            self.assertEqual(d1.forward_variable.lb, 0)
            self.assertEqual(d1.forward_variable.ub, 0)
            d1.upper_bound = .1
            self.assertEqual(d1.forward_variable.lb, 0)
            self.assertEqual(d1.forward_variable.ub, .1)
            self.assertEqual(d1.reverse_variable.lb, 0)
            self.assertEqual(d1.reverse_variable.ub, 1000)
            self.assertEqual(d1._lower_bound, -1000)
            self.assertEqual(d1.upper_bound, .1)
            self.assertEqual(d1._lower_bound, -1000)
            self.assertEqual(d1.upper_bound, .1)
Example #2
0
        def test_one_left_to_right_reaction_set_positive_ub(self):

            model = Model("Toy Model")

            m1 = Metabolite("M1")
            d1 = Reaction("ex1")
            d1.add_metabolites({m1: -1})
            d1.upper_bound = 0
            d1.lower_bound = -1000
            model.add_reactions([d1])
            self.assertEqual(d1.reverse_variable.lb, 0)
            self.assertEqual(d1.reverse_variable.ub, 1000)
            self.assertEqual(d1._lower_bound, -1000)
            self.assertEqual(d1.lower_bound, -1000)
            self.assertEqual(d1._upper_bound, 0)
            self.assertEqual(d1.upper_bound, 0)
            self.assertEqual(d1.forward_variable.lb, 0)
            self.assertEqual(d1.forward_variable.ub, 0)
            d1.upper_bound = .1
            self.assertEqual(d1.forward_variable.lb, 0)
            self.assertEqual(d1.forward_variable.ub, .1)
            self.assertEqual(d1.reverse_variable.lb, 0)
            self.assertEqual(d1.reverse_variable.ub, 1000)
            self.assertEqual(d1._lower_bound, -1000)
            self.assertEqual(d1.upper_bound, .1)
            self.assertEqual(d1._lower_bound, -1000)
            self.assertEqual(d1.upper_bound, .1)
        def test_weird_left_to_right_reaction_issue(self):

            model = Model("Toy Model")

            m1 = Metabolite("M1")
            d1 = Reaction("ex1")
            d1.add_metabolites({m1: -1})
            d1.upper_bound = 0
            d1.lower_bound = -1000
            # print d1.reaction, d1.lower_bound, d1.upper_bound
            model.add_reactions([d1])
            self.assertFalse(d1.reversibility)
            self.assertEqual(d1.lower_bound, -1000)
            self.assertEqual(d1._lower_bound, -1000)
            self.assertEqual(d1.upper_bound, 0)
            self.assertEqual(d1._upper_bound, 0)
            with TimeMachine() as tm:
                d1.knock_out(time_machine=tm)
                self.assertEqual(d1.lower_bound, 0)
                self.assertEqual(d1._lower_bound, 0)
                self.assertEqual(d1.upper_bound, 0)
                self.assertEqual(d1._upper_bound, 0)
            self.assertEqual(d1.lower_bound, -1000)
            self.assertEqual(d1._lower_bound, -1000)
            self.assertEqual(d1.upper_bound, 0)
            self.assertEqual(d1._upper_bound, 0)
Example #4
0
        def test_weird_left_to_right_reaction_issue(self):

            model = Model("Toy Model")

            m1 = Metabolite("M1")
            d1 = Reaction("ex1")
            d1.add_metabolites({m1: -1})
            d1.upper_bound = 0
            d1.lower_bound = -1000
            # print d1.reaction, d1.lower_bound, d1.upper_bound
            model.add_reactions([d1])
            self.assertFalse(d1.reversibility)
            self.assertEqual(d1.lower_bound, -1000)
            self.assertEqual(d1._lower_bound, -1000)
            self.assertEqual(d1.upper_bound, 0)
            self.assertEqual(d1._upper_bound, 0)
            with TimeMachine() as tm:
                d1.knock_out(time_machine=tm)
                self.assertEqual(d1.lower_bound, 0)
                self.assertEqual(d1._lower_bound, 0)
                self.assertEqual(d1.upper_bound, 0)
                self.assertEqual(d1._upper_bound, 0)
            self.assertEqual(d1.lower_bound, -1000)
            self.assertEqual(d1._lower_bound, -1000)
            self.assertEqual(d1.upper_bound, 0)
            self.assertEqual(d1._upper_bound, 0)
 def test_make_lhs_irreversible_reversible(self):
     model = self.model
     rxn = Reaction('test')
     rxn.add_metabolites({model.metabolites[0]: -1., model.metabolites[1]: 1.})
     rxn.lower_bound = -999999.
     rxn.upper_bound = -100
     model.add_reaction(rxn)
     self.assertEqual(rxn.lower_bound, -999999.)
     self.assertEqual(rxn.upper_bound, -100.)
     self.assertEqual(rxn.forward_variable.lb, 0.)
     self.assertEqual(rxn.forward_variable.ub, 0.)
     self.assertEqual(rxn.reverse_variable.lb, 100.)
     self.assertEqual(rxn.reverse_variable.ub, 999999.)
     rxn.upper_bound = 666.
     self.assertEqual(rxn.lower_bound, -999999.)
     self.assertEqual(rxn.upper_bound, 666.)
     self.assertEqual(rxn.forward_variable.lb, 0.)
     self.assertEqual(rxn.forward_variable.ub, 666)
     self.assertEqual(rxn.reverse_variable.lb, 0.)
     self.assertEqual(rxn.reverse_variable.ub, 999999.)
Example #6
0
 def test_make_lhs_irreversible_reversible(self):
     model = self.model
     rxn = Reaction('test')
     rxn.add_metabolites({
         model.metabolites[0]: -1.,
         model.metabolites[1]: 1.
     })
     rxn.lower_bound = -999999.
     rxn.upper_bound = -100
     model.add_reaction(rxn)
     self.assertEqual(rxn.lower_bound, -999999.)
     self.assertEqual(rxn.upper_bound, -100.)
     self.assertEqual(rxn.forward_variable.lb, 0.)
     self.assertEqual(rxn.forward_variable.ub, 0.)
     self.assertEqual(rxn.reverse_variable.lb, 100.)
     self.assertEqual(rxn.reverse_variable.ub, 999999.)
     rxn.upper_bound = 666.
     self.assertEqual(rxn.lower_bound, -999999.)
     self.assertEqual(rxn.upper_bound, 666.)
     self.assertEqual(rxn.forward_variable.lb, 0.)
     self.assertEqual(rxn.forward_variable.ub, 666)
     self.assertEqual(rxn.reverse_variable.lb, 0.)
     self.assertEqual(rxn.reverse_variable.ub, 999999.)