コード例 #1
0
ファイル: revision_module_test.py プロジェクト: robaki/huginn
    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)
コード例 #2
0
ファイル: revision_module_test.py プロジェクト: robaki/huginn
    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)
コード例 #3
0
ファイル: archive_test.py プロジェクト: robaki/huginn
	def test_record_InitialResults(self):
		exp1 = exp_repr.Experiment('exp1')
		exp2 = exp_repr.Experiment('exp2')
		event = archive.InitialResults([exp1, exp2])
		self.archive.record(event)
		self.assertIn(event, self.archive.development_history)
		self.assertIn(exp1, self.archive.known_results)
		self.assertIn(exp2, self.archive.known_results)
コード例 #4
0
ファイル: archive_test.py プロジェクト: robaki/huginn
	def test_get_model_origin_event(self):
		mod1 = 'mod1'
		mod2 = 'mod2'
		exp1 = exp_repr.Experiment('exp1', ['res1'])
		exp2 = exp_repr.Experiment('exp2', ['res2'])
		adit = archive.AdditionalModels([mod1, mod2])
		self.archive.development_history.extend([adit, archive.NewResults(exp1), archive.NewResults(exp2)])
		origin_event = self.archive.get_model_origin_event(mod1)
		self.assertEqual(origin_event, adit)
コード例 #5
0
ファイル: archive_test.py プロジェクト: robaki/huginn
	def test_get_results_after_model(self):
		mod1 = 'mod1'
		mod2 = 'mod2'
		exp1 = exp_repr.Experiment('exp1', ['res1'])
		exp2 = exp_repr.Experiment('exp2', ['res2'])
		self.archive.development_history.extend([archive.AdditionalModels([mod1, mod2]), archive.NewResults(exp1), archive.NewResults(exp2)])
		res = self.archive.get_results_after_model(mod1)
		self.assertIn('res1', res)
		self.assertIn('res2', res)
コード例 #6
0
ファイル: archive_test.py プロジェクト: robaki/huginn
	def test_get_events_after_event(self):
		mod1 = 'mod1'
		mod2 = 'mod2'
		exp1 = exp_repr.Experiment('exp1', ['res1'])
		exp2 = exp_repr.Experiment('exp2', ['res2'])
		res1 = archive.NewResults(exp1)
		res2 = archive.NewResults(exp2)
		self.archive.development_history.extend([archive.AdditionalModels([mod1, mod2]), res1, res2])
		origin_event = self.archive.get_model_origin_event(mod1)
		events = self.archive.get_events_after_event(origin_event)
		self.assertIn(res1, events)
		self.assertIn(res2, events)
コード例 #7
0
    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)
コード例 #8
0
ファイル: revision_module_test.py プロジェクト: robaki/huginn
    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)
コード例 #9
0
ファイル: archive_test.py プロジェクト: robaki/huginn
	def test_record_Results(self):
		res = exp_repr.Experiment('res')
		event = archive.AcceptedResults(res)
		self.archive.record(event)
		self.assertIn(event, self.archive.development_history)
		self.assertIn(res, self.archive.known_results)