Пример #1
0
 def setUp(self):
     # TODO use mock model instead of actual model
     self.database = DictDatabase()
     self.database.set_reaction("rxn_1", parse_reaction("=> |A|"))
     self.database.set_reaction("rxn_2", parse_reaction("(0.000001) |A| =>"))
     self.model = MetabolicModel.load_model(self.database, self.database.reactions)
     self.solver = cplex.Solver()
Пример #2
0
    def setUp(self):
        # TODO use mock model instead of actual model
        self.database = DictDatabase()
        self.database.set_reaction('rxn_1', parse_reaction(
            '|A| + |B| => |C|'))
        self.database.set_reaction('rxn_2', parse_reaction(
            '|C| + |Z| => |A| + |B|'))
        self.model = MetabolicModel.load_model(
            self.database, self.database.reactions)

        self.solver = cplex.Solver()
Пример #3
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| =>'))
     self.database.set_reaction('rxn_7', parse_reaction('|E| => |F|'))
     self.database.set_reaction('rxn_8', parse_reaction('|F| => |E|'))
     self.model = MetabolicModel.load_model(
         self.database, self.database.reactions)
     self.solver = cplex.Solver()
Пример #4
0
    def setUp(self):
        database1 = DictDatabase()
        database1.set_reaction('rxn_1', parse_reaction('|A| => |B|'))
        database1.set_reaction('rxn_2', parse_reaction('|B| => |C| + |D|'))
        database1.set_reaction('rxn_3', parse_reaction('|D| <=> |E|'))
        database1.set_reaction('rxn_4', parse_reaction('|F| => |G|'))

        database2 = DictDatabase()
        database2.set_reaction('rxn_2', parse_reaction('|B| => |C|'))
        database2.set_reaction('rxn_3', parse_reaction('|C| => |D|'))
        database2.set_reaction('rxn_4', parse_reaction('|F| <=> |G|'))
        database2.set_reaction('rxn_5', parse_reaction('|G| + |I| <=> |H|'))

        self.database = ChainedDatabase(database2, database1)
Пример #5
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[e]|'))
     self.database.set_reaction('rxn_4', parse_reaction('|A| => |C|'))
     self.database.set_reaction('rxn_5', parse_reaction('|C| => |D[e]|'))
     self.database.set_reaction('rxn_6', parse_reaction('|D[e]| =>'))
Пример #6
0
 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[e]|"))
     self.database.set_reaction("rxn_4", parse_reaction("|A| => |C|"))
     self.database.set_reaction("rxn_5", parse_reaction("|C| => |D[e]|"))
     self.database.set_reaction("rxn_6", parse_reaction("|D[e]| =>"))
     self.model = MetabolicModel.load_model(self.database, self.database.reactions)
Пример #7
0
 def setUp(self):
     # TODO use mock model instead of actual model
     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| =>"))
     self.model = MetabolicModel.load_model(self.database, self.database.reactions)
     self.solver = cplex.Solver()
Пример #8
0
    def setUp(self):
        # TODO use mock model instead of actual model
        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| =>'))
        self.model = MetabolicModel.load_model(self.database, self.database.reactions)

        self.solver = cplex.Solver()
Пример #9
0
    def setUp(self):
        self.database = DictDatabase()
        self.database.set_reaction('ex_A', parse_reaction('|A| <=>'))
        self.database.set_reaction('ex_D', parse_reaction('|D| <=>'))
        self.database.set_reaction('rxn_1', parse_reaction('|A| => |B|'))
        self.database.set_reaction('rxn_2', parse_reaction('|B| <=> |C|'))
        self.database.set_reaction('rxn_3', parse_reaction('|C| <=> |D|'))
        self.database.set_reaction('rxn_4', parse_reaction('|D| <=> |E|'))
        self.database.set_reaction('rxn_5', parse_reaction('|E| => |B|'))

        self.model = MetabolicModel.load_model(
            self.database, self.database.reactions)
        self.model.limits['ex_A'].lower = -10 # Low uptake
        self.model.limits['ex_D'].lower = 0 # No uptake

        self.solver = cplex.Solver()
Пример #10
0
 def test_modelseed_parse_with_decimal(self):
     r = modelseed.parse_reaction('|H2| + (0.5) |O2| => |H2O|')
     self.assertEquals(r, Reaction(Reaction.Right, [(Compound('H2'), 1), (Compound('O2'), Decimal('0.5'))],
                                   [(Compound('H2O'), 1)]))
Пример #11
0
 def test_get_reaction(self):
     reaction = parse_reaction('|A| => |D[e]|')
     self.assertEqual(self.database.get_reaction('rxn_3'), reaction)
Пример #12
0
 def test_fastcore_global_inconsistent(self):
     self.database.set_reaction("rxn_7", parse_reaction("|E| <=>"))
     self.model.add_reaction("rxn_7")
     with self.assertRaises(fastcore.FastcoreError):
         fastcore.fastcore(self.model, {"rxn_7"}, 0.001, solver=self.solver)
Пример #13
0
 def test_modelseed_parse_raw_compound_id_in_compartment(self):
     r = modelseed.parse_reaction('(2) cpd00001 => cpd00002[e]')
     self.assertEquals(r, Reaction(Reaction.Right,
                                   [(Compound('cpd00001'), 2)],
                                   [(Compound('cpd00002', 'e'), 1)]))
Пример #14
0
 def test_modelseed_parse_raw_compound_id_with_typo(self):
     r = modelseed.parse_reaction('(2) cpd00001 => cdp00002')
     self.assertEquals(r, Reaction(Reaction.Right,
                                   [(Compound('cpd00001'), 2)],
                                   [(Compound('cdp00002'), 1)]))
Пример #15
0
 def test_modelseed_parse_with_multichar_compartment(self):
     r = modelseed.parse_reaction('(2) |H2[C_c]| + |O2[C_c]| => (2) |H2O[C_e]|')
     self.assertEquals(r, Reaction(Reaction.Right, [(Compound('H2', compartment='C_c'), 2),
                                                     (Compound('O2', compartment='C_c'), 1)],
                                   [(Compound('H2O', compartment='C_e'), 2)]))
Пример #16
0
 def test_add_reaction_new(self):
     self.database.set_reaction("rxn_7", parse_reaction("|D[e]| => |E[e]|"))
     self.model.add_reaction("rxn_7")
     self.assertIn("rxn_7", set(self.model.reactions))
     self.assertIn(Compound("E", "e"), set(self.model.compounds))
Пример #17
0
 def test_modelseed_parse(self):
     r = modelseed.parse_reaction('|H2O| + |PPi| => (2) |Phosphate| + (2) |H+|')
     self.assertEquals(r, Reaction(Reaction.Right, [(Compound('H2O'), 1), (Compound('PPi'), 1)],
                                   [(Compound('Phosphate'), 2), (Compound('H+'), 2)]))
Пример #18
0
 def test_mass_inconsistent_is_consistent(self):
     exchange = { 'rxn_1', 'rxn_6' }
     self.database.set_reaction('rxn_7', parse_reaction('|D| => (2) |C|'))
     self.model.add_reaction('rxn_7')
     self.assertFalse(massconsistency.is_consistent(
         self.model, self.solver, exchange, set()))
Пример #19
0
 def test_add_all_database_reactions(self):
     self.database.set_reaction("rxn_7", parse_reaction("|D| => |E|"))
     added = self.model.add_all_database_reactions()
     self.assertEqual(added, {"rxn_7"})
     self.assertEqual(set(self.model.reactions), {"rxn_1", "rxn_2", "rxn_3", "rxn_4", "rxn_5", "rxn_6", "rxn_7"})
Пример #20
0
 def test_modelseed_parse_with_compartment(self):
     r = modelseed.parse_reaction('(2) |H2| + |O2| => (2) |H2O[e]|')
     self.assertEquals(r, Reaction(Reaction.Right, [(Compound('H2'), 2), (Compound('O2'), 1)],
                                   [(Compound('H2O', compartment='e'), 2)]))