示例#1
0
    def get_interventions(self, components):
        interventions = []
        add_setup = [st for st in components if st.startswith('add(setup_')]
        add_activ = list(
            set([st for st in components if st.startswith('add')]) -
            set(add_setup))
        remove = [st for st in components if st.startswith('remove(')]
        for st in add_setup:
            splitted = st.split('add(setup_present(')[1].split(')')[0].split(
                ',')
            entity = self.archive.get_matching_element(splitted[0],
                                                       splitted[1])
            compartment = self.archive.get_matching_element(splitted[2])
            interventions.append(Add(PresentEntity(entity, compartment)))
        for st in add_activ:
            splitted = st.split('add(')[1].split(')')[0]
            activity = self.archive.get_matching_element(splitted)
            interventions.append(Add(activity))
        for st in remove:
            splitted = st.split('remove(setup_present(')[1].split(
                ')')[0].split(',')
            entity = self.archive.get_matching_element(splitted[0],
                                                       splitted[1])
            compartment = self.archive.get_matching_element(splitted[2])
            interventions.append(Remove(PresentEntity(entity, compartment)))

        # removing used stuff from components
        [components.remove(st) for st in add_setup]
        [components.remove(st) for st in add_activ]
        [components.remove(st) for st in remove]
        return interventions
示例#2
0
 def test_in_vitro_basic(self):
     met1 = Metabolite('met1')
     met2 = Metabolite('met2')
     cytosol = Cytosol()
     cond1 = PresentEntity(met1, cytosol)
     cond2 = PresentEntity(met2, cytosol)
     r1 = Reaction('r1', [cond1], [cond2])
     self.oracle = Oracle(None, [], [r1], None, [], [], [])
     expD = ExperimentDescription(ReconstructionActivity('r1'), [])
     out = self.oracle.execute_in_vitro_exp(expD)
     self.assertEqual(out.outcome, 'true')
示例#3
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)
示例#4
0
 def test_in_vitro_enz(self):
     met1 = Metabolite('met1')
     met2 = Metabolite('met2')
     cytosol = Cytosol()
     cond1 = PresentEntity(met1, cytosol)
     cond2 = PresentEntity(met2, cytosol)
     cond_enz = PresentCatalyst(cytosol)
     r1 = Reaction('r1', [cond1, cond_enz], [cond2])
     enz = Protein('p1', properties=[Catalyses(r1)])
     self.oracle = Oracle(None, [enz], [r1], None, [], [], [])
     expD = ExperimentDescription(ReconstructionEnzReaction('r1', 'p1'), [])
     out = self.oracle.execute_in_vitro_exp(expD)
     self.assertEqual(out.outcome, 'true')
示例#5
0
 def test_in_vitro_basic_SLOPPY_ORACLE_WITH_FLIP(self):
     met1 = Metabolite('met1')
     met2 = Metabolite('met2')
     cytosol = Cytosol()
     cond1 = PresentEntity(met1, cytosol)
     cond2 = PresentEntity(met2, cytosol)
     r1 = Reaction('r1', [cond1], [cond2])
     self.oracle = SloppyOracle(None, [], [r1],
                                None, [], [], [],
                                error_parameter=1.00)
     expD = ExperimentDescription(ReconstructionActivity('r1'), [])
     out = self.oracle.execute_in_vitro_exp(expD)
     self.assertEqual(out.outcome, 'false')
示例#6
0
 def test_in_vitro_transp(self):
     met1 = Metabolite('met1')
     met2 = Metabolite('met2')
     cytosol = Cytosol()
     cond1 = PresentEntity(met1, cytosol)
     cond2 = PresentEntity(met2, cytosol)
     cond_trp = PresentTransporter(cytosol)
     r1 = Reaction('r1', [cond1, cond_trp], [cond2])
     transp = Protein('p1', properties=[Transports(r1)])
     self.oracle = Oracle(None, [transp], [r1], None, [], [], [])
     expD = ExperimentDescription(
         ReconstructionTransporterRequired('r1', 'p1'), [])
     out = self.oracle.execute_in_vitro_exp(expD)
     self.assertEqual(out.outcome, 'true')
示例#7
0
    def setUp(self):
        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.r1 = Reaction('r1', [self.cond1], [self.cond2])
        self.r2 = Reaction('r2', [self.cond3], [self.cond4])

        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.model = CostModel(self.entities, self.compartments,
                               self.activities, self.setup_conds)
示例#8
0
    def setUp(self):
        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], [])

        self.archive = Archive()
        self.archive.working_models.update([self.mod1, self.mod2])
        self.archive.mnm_compartments = list(self.compartments)
        self.archive.mnm_entities = list(self.entities)
        self.archive.mnm_activities = list(self.activities)

        self.oracle = Oracle(self.archive, [], [], self.mod1, self.entities,
                             self.compartments, self.activities)