示例#1
0
 def test_lmoma_with_cache(self, core_model):
     original_objective = core_model.objective
     pfba_solution = pfba(core_model)
     essential_reactions = find_essential_reactions(core_model)
     cache = ProblemCache(core_model)
     for r in core_model.reactions:
         if r not in essential_reactions:
             with core_model:
                 r.knock_out()
                 lmoma(core_model, reference=pfba_solution, cache=cache)
                 assert any(v.name.startswith("u_") for v in core_model.solver.variables)
                 assert any(c.name.startswith("lmoma_const_") for c in core_model.solver.constraints)
     cache.reset()
     assert core_model.objective.expression == original_objective.expression
     assert not any(v.name.startswith("u_") for v in core_model.solver.variables)
     assert not any(c.name.startswith("lmoma_const_") for c in core_model.solver.constraints)
示例#2
0
 def test_lmoma_with_reaction_filter(self):
     original_objective = self.model.objective
     pfba_solution = pfba(self.model)
     solution = lmoma(self.model, reference=pfba_solution,
                      reactions=['EX_o2_LPAREN_e_RPAREN_', 'EX_glc_LPAREN_e_RPAREN_'])
     self.assertEqual(len(solution.fluxes), 2)
     self.assertIs(self.model.objective, original_objective)
 def test_lmoma(self):
     pfba_solution = pfba(self.model)
     solution = lmoma(self.model, reference=pfba_solution)
     distance = sum([abs(solution[v] - pfba_solution[v]) for v in list(pfba_solution.keys())])
     self.assertAlmostEqual(0, distance,
                            delta=1e-6,
                            msg="lmoma distance without knockouts must be 0 (was %f)" % distance)
示例#4
0
 def test_lmoma(self, core_model):
     original_objective = core_model.objective
     pfba_solution = pfba(core_model)
     solution = lmoma(core_model, reference=pfba_solution)
     distance = sum((abs(solution[v] - pfba_solution[v]) for v in pfba_solution.keys()))
     assert abs(0 - distance) < 1e-6, "lmoma distance without knockouts must be 0 (was %f)" % distance
     assert core_model.objective.expression == original_objective.expression
示例#5
0
 def test_lmoma_with_reaction_filter(self):
     original_objective = self.model.objective
     pfba_solution = pfba(self.model)
     solution = lmoma(self.model, reference=pfba_solution,
                      reactions=['EX_o2_LPAREN_e_RPAREN_', 'EX_glc_LPAREN_e_RPAREN_'])
     self.assertEqual(len(solution.fluxes), 2)
     self.assertIs(self.model.objective, original_objective)
示例#6
0
 def test_lmoma(self, core_model):
     original_objective = core_model.objective
     pfba_solution = pfba(core_model)
     solution = lmoma(core_model, reference=pfba_solution)
     distance = sum((abs(solution[v] - pfba_solution[v]) for v in pfba_solution.keys()))
     assert abs(0 - distance) < 1e-6, "lmoma distance without knockouts must be 0 (was %f)" % distance
     assert core_model.objective.expression == original_objective.expression
示例#7
0
 def test_lmoma_with_cache(self, core_model):
     original_objective = core_model.objective
     pfba_solution = pfba(core_model)
     essential_reactions = find_essential_reactions(core_model)
     cache = ProblemCache(core_model)
     for r in core_model.reactions:
         if r not in essential_reactions:
             with core_model:
                 r.knock_out()
                 lmoma(core_model, reference=pfba_solution, cache=cache)
                 assert any(v.name.startswith("u_") for v in core_model.solver.variables)
                 assert any(c.name.startswith("lmoma_const_") for c in core_model.solver.constraints)
     cache.reset()
     assert core_model.objective.expression == original_objective.expression
     assert not any(v.name.startswith("u_") for v in core_model.solver.variables)
     assert not any(c.name.startswith("lmoma_const_") for c in core_model.solver.constraints)
示例#8
0
 def test_lmoma_with_reaction_filter(self, core_model):
     original_objective = core_model.objective
     pfba_solution = pfba(core_model)
     solution = lmoma(
         core_model,
         reference=pfba_solution,
         reactions=['EX_o2_LPAREN_e_RPAREN_', 'EX_glc_LPAREN_e_RPAREN_'])
     assert len(solution.fluxes) == 2
     assert core_model.objective is original_objective
示例#9
0
 def test_lmoma(self):
     original_objective = self.model.objective
     pfba_solution = pfba(self.model)
     solution = lmoma(self.model, reference=pfba_solution)
     distance = sum((abs(solution[v] - pfba_solution[v]) for v in pfba_solution.keys()))
     self.assertAlmostEqual(0, distance,
                            delta=1e-6,
                            msg="lmoma distance without knockouts must be 0 (was %f)" % distance)
     self.assertIs(self.model.objective, original_objective)
示例#10
0
 def test_lmoma(self):
     original_objective = self.model.objective
     pfba_solution = pfba(self.model)
     solution = lmoma(self.model, reference=pfba_solution)
     distance = sum((abs(solution[v] - pfba_solution[v]) for v in pfba_solution.keys()))
     self.assertAlmostEqual(0, distance,
                            delta=1e-6,
                            msg="lmoma distance without knockouts must be 0 (was %f)" % distance)
     self.assertIs(self.model.objective, original_objective)
示例#11
0
 def test_lmoma_with_reaction_filter(self, core_model):
     original_objective = core_model.objective
     pfba_solution = pfba(core_model)
     solution = lmoma(core_model, reference=pfba_solution,
                      reactions=['EX_o2_LPAREN_e_RPAREN_', 'EX_glc_LPAREN_e_RPAREN_'])
     assert len(solution.fluxes) == 2
     assert core_model.objective.expression == original_objective.expression
     assert not any(v.name.startswith("u_") for v in core_model.solver.variables)
     assert not any(c.name.startswith("lmoma_const_") for c in core_model.solver.constraints)
示例#12
0
 def test_lmoma_with_reaction_filter(self, core_model):
     original_objective = core_model.objective
     pfba_solution = pfba(core_model)
     solution = lmoma(core_model, reference=pfba_solution,
                      reactions=['EX_o2_LPAREN_e_RPAREN_', 'EX_glc_LPAREN_e_RPAREN_'])
     assert len(solution.fluxes) == 2
     assert core_model.objective.expression == original_objective.expression
     assert not any(v.name.startswith("u_") for v in core_model.solver.variables)
     assert not any(c.name.startswith("lmoma_const_") for c in core_model.solver.constraints)
示例#13
0
 def test_lmoma_change_ref(self, core_model):
     original_objective = core_model.objective
     pfba_solution = pfba(core_model)
     fluxes = {rid: 10 * flux for rid, flux in pfba_solution.items()}
     solution = lmoma(core_model, reference=fluxes)
     distance = sum((abs(solution[v] - pfba_solution[v]) for v in pfba_solution.keys()))
     assert abs(0 - distance) > 1e-6, "lmoma distance without knockouts must be 0 (was %f)" % distance
     assert core_model.objective.expression == original_objective.expression
     assert not any(v.name.startswith("u_") for v in core_model.solver.variables)
     assert not any(c.name.startswith("lmoma_const_") for c in core_model.solver.constraints)
示例#14
0
 def test_lmoma_change_ref(self):
     original_objective = self.model.objective
     pfba_solution = pfba(self.model)
     fluxes = {rid: 10*flux for rid, flux in pfba_solution.items()}
     solution = lmoma(self.model, reference=fluxes)
     distance = sum((abs(solution[v] - pfba_solution[v]) for v in pfba_solution.keys()))
     self.assertNotAlmostEqual(0, distance,
                            delta=1e-6,
                            msg="lmoma distance without knockouts must be 0 (was %f)" % distance)
     self.assertIs(self.model.objective, original_objective)
示例#15
0
 def test_lmoma_change_ref(self, core_model):
     original_objective = core_model.objective
     pfba_solution = pfba(core_model)
     fluxes = {rid: 10 * flux for rid, flux in pfba_solution.items()}
     solution = lmoma(core_model, reference=fluxes)
     distance = sum((abs(solution[v] - pfba_solution[v]) for v in pfba_solution.keys()))
     assert abs(0 - distance) > 1e-6, "lmoma distance without knockouts must be 0 (was %f)" % distance
     assert core_model.objective.expression == original_objective.expression
     assert not any(v.name.startswith("u_") for v in core_model.solver.variables)
     assert not any(c.name.startswith("lmoma_const_") for c in core_model.solver.constraints)
示例#16
0
 def test_lmoma_change_ref(self, core_model):
     original_objective = core_model.objective
     pfba_solution = pfba(core_model)
     fluxes = {rid: 10 * flux for rid, flux in pfba_solution.items()}
     solution = lmoma(core_model, reference=fluxes)
     distance = sum((abs(solution[v] - pfba_solution[v])
                     for v in pfba_solution.keys()))
     assert abs(
         0 - distance
     ) > 1e-6, "lmoma distance without knockouts must be 0 (was %f)" % distance
     assert core_model.objective is original_objective
示例#17
0
 def test_lmoma(self):
     pfba_solution = pfba(self.model)
     solution = lmoma(self.model, reference=pfba_solution)
     distance = sum([
         abs(solution[v] - pfba_solution[v])
         for v in list(pfba_solution.keys())
     ])
     self.assertAlmostEqual(
         0,
         distance,
         delta=1e-6,
         msg="lmoma distance without knockouts must be 0 (was %f)" %
         distance)