Example #1
0
    def test_find_coupled_reactions(self, core_model):
        couples = structural.find_coupled_reactions(core_model)
        fluxes = core_model.optimize().fluxes
        for coupled_set in couples:
            coupled_set = list(coupled_set)
            assert round(abs(fluxes[coupled_set[0].id] - fluxes[coupled_set[1].id]), 7) == 0

        couples, blocked = structural.find_coupled_reactions(core_model, return_dead_ends=True)
        assert blocked == structural.find_dead_end_reactions(core_model)
        def test_find_coupled_reactions(self):
            couples = structural.find_coupled_reactions(self.model)
            fluxes = self.model.solve().fluxes
            for coupled_set in couples:
                coupled_set = list(coupled_set)
                self.assertAlmostEqual(fluxes[coupled_set[0]], fluxes[coupled_set[1]])

            couples, blocked = structural.find_coupled_reactions(self.model, return_dead_ends=True)
            self.assertEqual(blocked, structural.find_dead_end_reactions(self.model))
Example #3
0
    def test_find_coupled_reactions(self, core_model):
        couples = structural.find_coupled_reactions(core_model)
        fluxes = core_model.optimize().fluxes
        for coupled_set in couples:
            coupled_set = list(coupled_set)
            assert round(abs(fluxes[coupled_set[0].id] - fluxes[coupled_set[1].id]), 7) == 0

        couples, blocked = structural.find_coupled_reactions(core_model, return_dead_ends=True)
        assert blocked == structural.find_dead_end_reactions(core_model)
Example #4
0
        def test_find_coupled_reactions(self):
            couples = structural.find_coupled_reactions(self.model)
            fluxes = self.model.solve().fluxes
            for coupled_set in couples:
                coupled_set = list(coupled_set)
                self.assertAlmostEqual(fluxes[coupled_set[0]], fluxes[coupled_set[1]])

            couples, blocked = structural.find_coupled_reactions(self.model, return_dead_ends=True)
            self.assertEqual(blocked, structural.find_dead_end_reactions(self.model))
Example #5
0
    def test_reactions_in_group_become_blocked_if_one_is_removed(
            self, core_model):
        essential_reactions = core_model.essential_reactions()
        coupled_reactions = structural.find_coupled_reactions_nullspace(
            core_model)
        for group in coupled_reactions:
            representative = pick_one(group)
            if representative not in essential_reactions:
                with TimeMachine() as tm:
                    assert core_model == representative.model
                    tm(do=partial(core_model.remove_reactions,
                                  [representative],
                                  delete=False),
                       undo=partial(core_model.add_reactions,
                                    [representative]))
                    # # FIXME: Hack because of optlang queue issues with GLPK
                    # core_model.solver.update()
                    assert representative not in core_model.reactions
                    assert representative.forward_variable not in core_model.solver.variables
                    assert representative.reverse_variable not in core_model.solver.variables
                    assert representative not in core_model.reactions
                    assert representative.model is None
                    blocked_reactions = find_blocked_reactions(core_model)
                    assert all(r in blocked_reactions for r in group
                               if r != representative)
                assert representative in core_model.reactions

        coupled_reactions = structural.find_coupled_reactions(core_model)
        for group in coupled_reactions:
            representative = pick_one(group)
            if representative not in essential_reactions:
                with TimeMachine() as tm:
                    fwd_var_name = representative.forward_variable.name
                    rev_var_name = representative.reverse_variable.name
                    assert core_model == representative.model
                    tm(do=partial(core_model.remove_reactions,
                                  [representative],
                                  delete=False),
                       undo=partial(core_model.add_reactions,
                                    [representative]))
                    # # FIXME: Hack because of optlang queue issues with GLPK
                    # core_model.solver.update()
                    assert representative not in core_model.reactions
                    assert fwd_var_name not in core_model.solver.variables
                    assert rev_var_name not in core_model.solver.variables
                    assert representative not in core_model.reactions
                    assert representative.model is None
                    blocked_reactions = find_blocked_reactions(core_model)
                    assert representative not in core_model.reactions
                    assert all(r in blocked_reactions for r in group
                               if r != representative)
                assert representative in core_model.reactions
Example #6
0
    def test_reactions_in_group_become_blocked_if_one_is_removed(self, core_model):
        essential_reactions = find_essential_reactions(core_model)
        coupled_reactions = structural.find_coupled_reactions_nullspace(core_model)
        for group in coupled_reactions:
            representative = pick_one(group)
            if representative not in essential_reactions:
                with core_model:
                    assert core_model == representative.model
                    core_model.remove_reactions([representative])
                    # # FIXME: Hack because of optlang queue issues with GLPK
                    # core_model.solver.update()
                    assert representative not in core_model.reactions
                    assert representative.forward_variable not in core_model.solver.variables
                    assert representative.reverse_variable not in core_model.solver.variables
                    assert representative not in core_model.reactions
                    assert representative.model is None
                    blocked_reactions = find_blocked_reactions(core_model)
                    assert all(r in blocked_reactions for r in group if r != representative)
                assert representative in core_model.reactions

        coupled_reactions = structural.find_coupled_reactions(core_model)
        for group in coupled_reactions:
            representative = pick_one(group)
            if representative not in essential_reactions:
                with core_model:
                    fwd_var_name = representative.forward_variable.name
                    rev_var_name = representative.reverse_variable.name
                    assert core_model == representative.model
                    core_model.remove_reactions([representative])
                    # # FIXME: Hack because of optlang queue issues with GLPK
                    # core_model.solver.update()
                    assert representative not in core_model.reactions
                    assert fwd_var_name not in core_model.solver.variables
                    assert rev_var_name not in core_model.solver.variables
                    assert representative not in core_model.reactions
                    assert representative.model is None
                    blocked_reactions = find_blocked_reactions(core_model)
                    assert representative not in core_model.reactions
                    assert all(r in blocked_reactions for r in group if r != representative)
                assert representative in core_model.reactions