def test_calculate_max_number_activities(self): # model with activities, archive with results that have add activity in interventions a1 = mnm_repr.Activity('act1', None, ['a'], []) a2 = mnm_repr.Activity('act1', None, ['b'], []) a3 = mnm_repr.Activity('act1', None, ['c'], []) a4 = mnm_repr.Activity('act1', None, ['d'], []) base_model = mnm_repr.Model('m1', [], [a1], []) des1 = exp_repr.ExperimentDescription( None, [mnm_repr.Add(a2), mnm_repr.Add(a1)]) des2 = exp_repr.ExperimentDescription(None, [mnm_repr.Add(a3)]) des3 = exp_repr.ExperimentDescription( None, [mnm_repr.Add(a4), mnm_repr.Add(a3)]) res1 = exp_repr.Result('r1', des1, None) res2 = exp_repr.Result('r2', des2, None) res3 = exp_repr.Result('r3', des3, None) exp1 = exp_repr.Experiment('exp1', [res1]) exp2 = exp_repr.Experiment('exp2', [res2]) exp3 = exp_repr.Experiment('exp3', [res3]) arch = Archive() arch.known_results = [exp1, exp2, exp3] rev = RevisionModule(arch) out = rev.calculate_max_number_activities(base_model) self.assertEqual(out, 4)
def setUp(self): self.con1 = mnm_repr.PresentEntity('ent1', 'comp1') self.con2 = mnm_repr.PresentEntity('ent2', 'comp2') self.con3 = mnm_repr.PresentEntity('ent3', 'comp3') self.con4 = mnm_repr.PresentEntity('ent4', 'comp4') self.act1 = mnm_repr.Activity('ID1', 'name1', [self.con1], []) self.act2 = mnm_repr.Activity('ID2', 'name2', [self.con2], [])
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])
def test_export_force_new_model(self): act1 = mnm_repr.Activity('act1', None, ['a'], []) act2 = mnm_repr.Activity('act2', None, ['b'], []) base_model = mnm_repr.Model('m1', [], [], []) exm1 = mnm_repr.Model('m2', [], [act1], []) exm2 = mnm_repr.Model('m3', [], [act2], []) out = exporter.export_force_new_model(base_model, [exm1, exm2]) self.assertIn('\nexternal_model(m2).', out) self.assertIn('\nexternal_model(m3).', out) self.assertIn('\nin_model(act1,m2).', out) self.assertIn('\nin_model(act2,m3).', out) self.assertIn('\n#example different(m1, m2).', out) self.assertIn('\n#example different(m1, m3).', out)
def test_export_activity(self): # one substrate, one catalyst, one transporter; one product cond_subst = mnm_repr.PresentEntity(mnm_repr.Metabolite('met1'), mnm_repr.Medium()) cond_cat = mnm_repr.PresentCatalyst(mnm_repr.Medium()) cond_trp = mnm_repr.PresentTransporter(mnm_repr.Medium()) prod = mnm_repr.PresentEntity(mnm_repr.Metabolite('met2'), mnm_repr.Medium()) act = mnm_repr.Activity('a1', 'none', [cond_subst, cond_cat, cond_trp], [prod]) act.reversibility = True exported = exporter.export_activity(act) # forward self.assertIn('\nsubstrate(met1,none,c_01,a1).', exported) self.assertIn('\nenz_required(a1).', exported) self.assertIn('\nenz_compartment(c_01,a1).', exported) self.assertIn('\ntransp_required(a1).', exported) self.assertIn('\ntransp_compartment(c_01,a1).', exported) self.assertIn('\nproduct(met2,none,c_01,a1).', exported) # reversed self.assertIn('\nproduct(met1,none,c_01,a1_rev).', exported) self.assertIn('\nenz_required(a1_rev).', exported) self.assertIn('\nenz_compartment(c_01,a1_rev).', exported) self.assertIn('\ntransp_required(a1_rev).', exported) self.assertIn('\ntransp_compartment(c_01,a1_rev).', exported) self.assertIn('\nsubstrate(met2,none,c_01,a1_rev).', exported)
def test_export_model_specification(self): # 2 conds + 2 activ cond_subst_1 = mnm_repr.PresentEntity(mnm_repr.Metabolite('met1'), mnm_repr.Medium()) cond_subst_2 = mnm_repr.PresentEntity(mnm_repr.Metabolite('met2'), mnm_repr.Medium()) act_1 = mnm_repr.Activity('a1', None, ['1'], []) act_2 = mnm_repr.Activity('a2', None, ['2'], []) m = mnm_repr.Model('m1', [cond_subst_1, cond_subst_2], [act_1, act_2], []) exported = exporter.export_model_specification(m) self.assertIn('\nadded_to_model(setup_present(met1,none,c_01),m1).', exported) self.assertIn('\nadded_to_model(setup_present(met2,none,c_01),m1).', exported) self.assertIn('\nadded_to_model(a1,m1).', exported) self.assertIn('\nadded_to_model(a2,m1).', exported)
def test_export_remove_activities(self): a1 = mnm_repr.Activity('act1', None, ['a'], []) a2 = mnm_repr.Activity('act2', None, ['b'], []) out = exporter.export_remove_activities([a1, a2]) self.assertIn('\n#modeh remove(act1) =1 @1.', out) self.assertIn('\n#modeh remove(act2) =1 @1.', out)