def test_RevCIAddB_revise_ignoring(self): met1 = mnm_repr.Metabolite('met1') met2 = mnm_repr.Metabolite('met2') comp1 = mnm_repr.Medium() cond_subst_1 = mnm_repr.PresentEntity(met1, comp1) cond_subst_2 = mnm_repr.PresentEntity(met2, comp1) a1 = mnm_repr.Reaction('act1', [], [cond_subst_1, cond_subst_2]) a1.remove_cost = None a1.reversibility = False a2 = mnm_repr.Reaction('act1', [], [cond_subst_1]) a2.reversibility = False # model to be revised mod = mnm_repr.Model('m_0', [], [a1], []) # results des1 = exp_repr.ExperimentDescription(exp_repr.DetectionEntity('met1'), []) des2 = exp_repr.ExperimentDescription(exp_repr.DetectionEntity('met2'), []) res1 = exp_repr.Result('res_0', des1, 'false') res2 = exp_repr.Result('res_1', des2, 'true') exp1 = exp_repr.Experiment('exp_0', [res1]) exp2 = exp_repr.Experiment('exp_1', [res2]) # archive with results and parts for revision arch = Archive() arch.known_results = [exp1, exp2] arch.mnm_activities = [a1, a2] arch.mnm_entities = [met1, met2] arch.mnm_compartments = [comp1] rev = RevCIAddB(arch) out = rev.revise(mod) self.assertEqual(out[0], []) self.assertEqual(out[1], True)
def test_export_ignore_results(self): des = exp_repr.ExperimentDescription(exp_repr.DetectionEntity('e1')) res1 = exp_repr.Result('res1', des, None) res2 = exp_repr.Result('res2', des, None) out = exporter.export_ignore_results([res1, res2]) self.assertIn('\n#modeh ignored(res1) =1 @2.', out) self.assertIn('\n#modeh ignored(res2) =1 @2.', out)
def setUp(self): # models: self.g1 = Gene('g1') self.p1 = Protein('p1') self.met1 = Metabolite('met1') self.met2 = Metabolite('met2') self.cplx1 = Complex('cplx1') self.cytosol = Cytosol() self.cond1 = PresentEntity(self.met1, self.cytosol) self.cond2 = PresentEntity(self.met2, self.cytosol) self.cond3 = PresentEntity(self.p1, self.cytosol) self.cond4 = PresentEntity(self.cplx1, self.cytosol) self.growth = Growth('growth', [self.cond2]) self.growth.reversibility = False self.r1 = Reaction('r1', [self.cond1], [self.cond2]) self.r2 = Reaction('r2', [self.cond3], [self.cond4]) self.r1.reversibility = False self.r2.reversibility = False self.entities = [self.g1, self.p1, self.met1, self.met2, self.cplx1] self.compartments = [self.cytosol] self.activities = [self.growth, self.r1, self.r2] self.setup_conds = [self.cond1, self.cond3] self.mod1 = Model('m0', self.setup_conds, [self.growth, self.r1], []) self.mod2 = Model('m1', self.setup_conds, [self.growth, self.r2], []) # cost_module: self.cost_model = CostModel(self.entities, self.compartments, self.activities, self.setup_conds) self.cost_model.set_all_basic_costs_to_1() self.cost_model.calculate_derived_costs(self.activities) self.cost_model.remove_None_valued_elements() # known results (one exp, both models consistent) self.exd = exp_repr.ExperimentDescription( exp_repr.DetectionEntity('met1'), []) self.res = exp_repr.Result('res1', self.exd, 'true') self.exp = exp_repr.Experiment('exp1', [self.res]) # archive self.arch = Archive() self.arch.working_models = [self.mod1, self.mod2] self.arch.known_results = [self.exp] self.arch.mnm_compartments = self.compartments self.arch.mnm_entities = self.entities self.arch.mnm_activities = self.activities # exp module self.exp_module = ExperimentModule(self.arch, self.cost_model, False)
def test_ban_experiment(self): comp = mnm_repr.Medium() ent1 = mnm_repr.Metabolite('m1') cond1 = mnm_repr.PresentEntity(ent1, comp) inter1 = mnm_repr.Add(cond1) ent2 = mnm_repr.Metabolite('m2') cond2 = mnm_repr.PresentEntity(ent2, comp) inter2 = mnm_repr.Remove(cond2) exp_description = exp_repr.ExperimentDescription( exp_repr.DetectionEntity('ent1'), [inter1, inter2]) out = exporter.ban_experiment(exp_description) # print([out]) self.assertIn('\n:- designed(experiment(detection_entity_exp, ent1))', out) self.assertIn(',remove(setup_present(m2, none, c_01))', out) self.assertIn(',add(setup_present(m1, none, c_01))', out)
def test_check_consistency_negative(self): met1 = mnm_repr.Metabolite('met1') met2 = mnm_repr.Metabolite('met2') comp1 = mnm_repr.Medium() cond_subst_1 = mnm_repr.PresentEntity(met1, comp1) cond_subst_2 = mnm_repr.PresentEntity(met2, comp1) base_model = mnm_repr.Model('m1', [cond_subst_1, cond_subst_2], [], []) exd = exp_repr.ExperimentDescription(exp_repr.DetectionEntity('met1'), []) res = exp_repr.Result('r1', exd, 'false') exp = exp_repr.Experiment('exp1', [res]) arch = Archive() arch.mnm_entities = [met1, met2] arch.mnm_compartments = [comp1] ev1 = AdditionalModels([base_model]) ev2 = AcceptedResults(exp) arch.record(ev1) arch.record(ev2) rev = RevisionModule(arch) out = rev.check_consistency(base_model) self.assertEqual(False, out)