Beispiel #1
0
    def setUp(self):
        self.database = DictDatabase()
        self.database.set_reaction('rxn_1', parse_reaction('=> (2) |A|'))
        self.database.set_reaction('rxn_2', parse_reaction('|A| <=> |B|'))
        self.database.set_reaction('rxn_3', parse_reaction('|A| => |D|'))
        self.database.set_reaction('rxn_4', parse_reaction('|A| => |C|'))
        self.database.set_reaction('rxn_5', parse_reaction('|C| => |D|'))
        self.database.set_reaction('rxn_6', parse_reaction('|D| =>'))

        model = MetabolicModel.load_model(self.database, self.database.reactions)
        self.model = FlipableModelView(model)
Beispiel #2
0
    def setUp(self):
        self.database = DictDatabase()
        self.database.set_reaction('rxn_1', parse_reaction('=> (2) |A|'))
        self.database.set_reaction('rxn_2', parse_reaction('|A| <=> |B|'))
        self.database.set_reaction('rxn_3', parse_reaction('|A| => |D|'))
        self.database.set_reaction('rxn_4', parse_reaction('|A| => |C|'))
        self.database.set_reaction('rxn_5', parse_reaction('|C| => |D|'))
        self.database.set_reaction('rxn_6', parse_reaction('|D| =>'))

        model = MetabolicModel.load_model(self.database, self.database.reactions)
        self.model = FlipableModelView(model)
    def setUp(self):
        # TODO use mock database instead of actual database
        self.database = DictDatabase()
        self.database.set_reaction("rxn_1", parse_reaction("=> (2) |A|"))
        self.database.set_reaction("rxn_2", parse_reaction("|A| <=> |B|"))
        self.database.set_reaction("rxn_3", parse_reaction("|A| => |D|"))
        self.database.set_reaction("rxn_4", parse_reaction("|A| => |C|"))
        self.database.set_reaction("rxn_5", parse_reaction("|C| => |D|"))
        self.database.set_reaction("rxn_6", parse_reaction("|D| =>"))

        model = MetabolicModel.load_model(self.database, self.database.reactions)
        self.model = FlipableModelView(model)
class TestMetabolicModelFlipableView(unittest.TestCase):
    def setUp(self):
        # TODO use mock database instead of actual database
        self.database = DictDatabase()
        self.database.set_reaction("rxn_1", parse_reaction("=> (2) |A|"))
        self.database.set_reaction("rxn_2", parse_reaction("|A| <=> |B|"))
        self.database.set_reaction("rxn_3", parse_reaction("|A| => |D|"))
        self.database.set_reaction("rxn_4", parse_reaction("|A| => |C|"))
        self.database.set_reaction("rxn_5", parse_reaction("|C| => |D|"))
        self.database.set_reaction("rxn_6", parse_reaction("|D| =>"))

        model = MetabolicModel.load_model(self.database, self.database.reactions)
        self.model = FlipableModelView(model)

    def test_flipable_model_view_matrix_get_item_after_flip(self):
        self.model.flip({"rxn_4"})
        self.assertEqual(self.model.matrix[Compound("A"), "rxn_1"], 2)
        self.assertEqual(self.model.matrix[Compound("A"), "rxn_2"], -1)
        self.assertEqual(self.model.matrix[Compound("A"), "rxn_4"], 1)
        self.assertEqual(self.model.matrix[Compound("C"), "rxn_4"], -1)

    def test_flipable_model_view_matrix_get_item_after_double_flip(self):
        self.model.flip({"rxn_4", "rxn_5"})
        self.model.flip({"rxn_1", "rxn_4", "rxn_2"})
        self.assertEqual(self.model.matrix[Compound("A"), "rxn_1"], -2)
        self.assertEqual(self.model.matrix[Compound("A"), "rxn_2"], 1)
        self.assertEqual(self.model.matrix[Compound("B"), "rxn_2"], -1)
        self.assertEqual(self.model.matrix[Compound("A"), "rxn_4"], -1)
        self.assertEqual(self.model.matrix[Compound("C"), "rxn_4"], 1)
        self.assertEqual(self.model.matrix[Compound("C"), "rxn_5"], 1)
        self.assertEqual(self.model.matrix[Compound("D"), "rxn_5"], -1)

    def test_flipable_model_view_limits_get_item_after_flip(self):
        self.model.flip({"rxn_1", "rxn_2"})
        self.assertEqual(self.model.limits["rxn_1"].bounds, (-1000, 0))
        self.assertEqual(self.model.limits["rxn_2"].bounds, (-1000, 1000))
        self.assertEqual(self.model.limits["rxn_3"].bounds, (0, 1000))

    def test_flipable_model_view_limits_set_item_after_flip(self):
        self.model.flip({"rxn_1"})
        self.model.limits["rxn_1"].bounds = -20, 500
        self.assertEqual(self.model.limits["rxn_1"].bounds, (-20, 500))

        self.model.flip({"rxn_1"})
        self.assertEqual(self.model.limits["rxn_1"].bounds, (-500, 20))
Beispiel #5
0
class TestMetabolicModelFlipableView(unittest.TestCase):
    def setUp(self):
        # TODO use mock database instead of actual database
        self.database = DictDatabase()
        self.database.set_reaction('rxn_1', parse_reaction('=> (2) |A|'))
        self.database.set_reaction('rxn_2', parse_reaction('|A| <=> |B|'))
        self.database.set_reaction('rxn_3', parse_reaction('|A| => |D|'))
        self.database.set_reaction('rxn_4', parse_reaction('|A| => |C|'))
        self.database.set_reaction('rxn_5', parse_reaction('|C| => |D|'))
        self.database.set_reaction('rxn_6', parse_reaction('|D| =>'))

        model = MetabolicModel.load_model(self.database, self.database.reactions)
        self.model = FlipableModelView(model)

    def test_flipable_model_view_matrix_get_item_after_flip(self):
        self.model.flip({ 'rxn_4' })
        self.assertEqual(self.model.matrix[Compound('A'), 'rxn_1'], 2)
        self.assertEqual(self.model.matrix[Compound('A'), 'rxn_2'], -1)
        self.assertEqual(self.model.matrix[Compound('A'), 'rxn_4'], 1)
        self.assertEqual(self.model.matrix[Compound('C'), 'rxn_4'], -1)

    def test_flipable_model_view_matrix_get_item_after_double_flip(self):
        self.model.flip({ 'rxn_4', 'rxn_5' })
        self.model.flip({ 'rxn_1', 'rxn_4', 'rxn_2' })
        self.assertEqual(self.model.matrix[Compound('A'), 'rxn_1'], -2)
        self.assertEqual(self.model.matrix[Compound('A'), 'rxn_2'], 1)
        self.assertEqual(self.model.matrix[Compound('B'), 'rxn_2'], -1)
        self.assertEqual(self.model.matrix[Compound('A'), 'rxn_4'], -1)
        self.assertEqual(self.model.matrix[Compound('C'), 'rxn_4'], 1)
        self.assertEqual(self.model.matrix[Compound('C'), 'rxn_5'], 1)
        self.assertEqual(self.model.matrix[Compound('D'), 'rxn_5'], -1)

    def test_flipable_model_view_limits_get_item_after_flip(self):
        self.model.flip({ 'rxn_1', 'rxn_2' })
        self.assertEqual(self.model.limits['rxn_1'].bounds, (-1000, 0))
        self.assertEqual(self.model.limits['rxn_2'].bounds, (-1000, 1000))
        self.assertEqual(self.model.limits['rxn_3'].bounds, (0, 1000))

    def test_flipable_model_view_limits_set_item_after_flip(self):
        self.model.flip({ 'rxn_1' })
        self.model.limits['rxn_1'].bounds = -20, 500
        self.assertEqual(self.model.limits['rxn_1'].bounds, (-20, 500))

        self.model.flip({ 'rxn_1' })
        self.assertEqual(self.model.limits['rxn_1'].bounds, (-500, 20))