def test_cost_rules(self): # prepare the cost model g1 = mnm_repr.Gene('g1') p1 = mnm_repr.Protein('p1') met1 = mnm_repr.Metabolite('met1') met2 = mnm_repr.Metabolite('met2') cplx1 = mnm_repr.Complex('cplx1') cytosol = mnm_repr.Cytosol() cond1 = mnm_repr.PresentEntity(met1, cytosol) cond2 = mnm_repr.PresentEntity(met2, cytosol) cond3 = mnm_repr.PresentEntity(p1, cytosol) cond4 = mnm_repr.PresentEntity(cplx1, cytosol) growth = mnm_repr.Growth('growth', [cond2]) r1 = mnm_repr.Reaction('r1', [cond1], [cond2]) r2 = mnm_repr.Reaction('r2', [cond3], [cond4]) entities = [g1, p1, met1, met2, cplx1] compartments = [cytosol] activities = [growth, r1, r2] setup_conds = [cond1, cond3] model = CostModel(entities, compartments, activities, setup_conds) model.set_all_basic_costs_to_1() model.calculate_derived_costs(activities) # test out = exporter.cost_rules(model) # self.assertIn('\ncost(1, 0) :- add(setup_present(met1, none, c_01)).', out) self.assertEqual(len(out), 55)
def test_export_experiment_specification_elements(self): # prepare the cost model g1 = mnm_repr.Gene('g1') p1 = mnm_repr.Protein('p1') met1 = mnm_repr.Metabolite('met1') met2 = mnm_repr.Metabolite('met2') cplx1 = mnm_repr.Complex('cplx1') cytosol = mnm_repr.Cytosol() cond1 = mnm_repr.PresentEntity(met1, cytosol) cond2 = mnm_repr.PresentEntity(met2, cytosol) cond3 = mnm_repr.PresentEntity(p1, cytosol) cond4 = mnm_repr.PresentEntity(cplx1, cytosol) growth = mnm_repr.Growth('growth', [cond2]) r1 = mnm_repr.Reaction('r1', [cond1], [cond2]) r2 = mnm_repr.Reaction('r2', [cond3], [cond4]) entities = [g1, p1, met1, met2, cplx1] compartments = [cytosol] activities = [growth, r1, r2] setup_conds = [cond1, cond3] model = CostModel(entities, compartments, activities, setup_conds) model.set_all_basic_costs_to_1() model.calculate_derived_costs(activities) # test out = exporter.export_experiment_specification_elements(model) self.assertEqual(len(out.keys()), 55) self.assertNotIn(None, out.values())
def test_modeh_replacement(self): # prepare the cost model g1 = mnm_repr.Gene('g1') p1 = mnm_repr.Protein('p1') met1 = mnm_repr.Metabolite('met1') met2 = mnm_repr.Metabolite('met2') cplx1 = mnm_repr.Complex('cplx1') cytosol = mnm_repr.Cytosol() cond1 = mnm_repr.PresentEntity(met1, cytosol) cond2 = mnm_repr.PresentEntity(met2, cytosol) cond3 = mnm_repr.PresentEntity(p1, cytosol) cond4 = mnm_repr.PresentEntity(cplx1, cytosol) growth = mnm_repr.Growth('growth', [cond2]) r1 = mnm_repr.Reaction('r1', [cond1], [cond2]) r2 = mnm_repr.Reaction('r2', [cond3], [cond4]) entities = [g1, p1, met1, met2, cplx1] compartments = [cytosol] activities = [growth, r1, r2] setup_conds = [cond1, cond3] model = CostModel(entities, compartments, activities, setup_conds) model.set_all_basic_costs_to_1() model.calculate_derived_costs(activities) # test out = exporter.modeh_replacement(model) self.assertIsInstance(out, str)
def test_export_entities_alone(self): # get one of entity types; no need to test all (they do the same thing) ent1 = mnm_repr.Gene('e1') ent2 = mnm_repr.Metabolite('e2') ent3 = mnm_repr.Protein('e3') ent4 = mnm_repr.Complex('e4') exported = exporter.export_entities([ent1, ent2, ent3, ent4]) self.assertEqual("\ngene(e1,none).", exported[0]) self.assertEqual("\nmetabolite(e2,none).", exported[1]) self.assertEqual("\nprotein(e3,none).", exported[2]) self.assertEqual("\ncomplex(e4,none).", exported[3])
def test_export_entities_properties(self): # entity with properties to test the second part of the method ent3 = mnm_repr.Protein( 'e3', 'none', 'none', [mnm_repr.Catalyses(mnm_repr.Activity('a1', None, [], []))]) ent4 = mnm_repr.Complex( 'e4', 'none', 'none', [mnm_repr.Transports(mnm_repr.Activity('a2', None, [], []))]) exported = exporter.export_entities([ent3, ent4]) self.assertEqual("\nprotein(e3,none).", exported[0]) self.assertEqual("\ncatalyses(e3,none,a1).", exported[1]) self.assertEqual("\ncomplex(e4,none).", exported[2]) self.assertEqual("\ntransports(e4,none,a2).", exported[3])