def prepare_input_for_exp_design(self):
		exported = []
		exported.extend(exporter.hide_show_statements()) # export hide/show stuff
		exported.extend(exporter.export_compartments(self.archive.mnm_compartments))
		exported.extend(exporter.export_entities(self.archive.mnm_entities))
		exported.extend(exporter.export_activities(self.archive.mnm_activities + self.archive.import_activities))
		exported.extend(exporter.export_models_exp_design(self.archive.working_models)) # export models info
		exported.extend(exporter.models_nr_and_probabilities(self.archive.working_models)) # + probabilities and numbers
		exported.append(exporter.modeh_replacement(self.cost_model)) # export design elements (modeh eqiv)
		exported.extend(exporter.design_constraints_basic()) # export rules forcing and restricting exp design
		for exp in self.archive.known_results:
			exp_descriptions = [res.exp_description for res in exp.results]
			for des in exp_descriptions:
				exported.extend(exporter.ban_experiment(des)) # export ban experiment(s) (from old exps)
		exported.append(exporter.constant_for_calculating_score(self.calculate_constant_for_scores())) # calculate constant for scores and export it
		exported.extend(exporter.advanced_exp_design_rules()) # export scoring rules/optimisation
		if self.use_costs: # * export cost, and optimisation rule for that
			exported.extend(exporter.cost_rules(self.cost_model))
			exported.extend(exporter.cost_minimisation_rules())
		else:
			pass
		exported.extend(exporter.experiment_design_rules()) # export design rules
		exported.extend(exporter.interventions_rules())
		exported.extend(exporter.predictions_rules())
		exported.extend(exporter.models_rules(len(self.archive.mnm_activities + self.archive.import_activities))) 
		return exported
Example #2
0
	def prepare_input_elements(self):
		exped_entities = exporter.export_entities(self.archive.mnm_entities)
		exped_compartments = exporter.export_compartments(self.archive.mnm_compartments)
		exped_activities = exporter.export_activities(self.archive.mnm_activities + self.archive.import_activities)
		# not flattened
		output = [exped_entities, exped_compartments, exped_activities]
		# flattened
		return [val for sublist in output for val in sublist]
Example #3
0
	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])
Example #4
0
 def prepare_input_elements(self):
     exped_entities = exporter.export_entities(self.archive.mnm_entities)
     exped_compartments = exporter.export_compartments(
         self.archive.mnm_compartments)
     exped_activities = exporter.export_activities(
         self.archive.mnm_activities + self.archive.import_activities)
     # not flattened
     output = [exped_entities, exped_compartments, exped_activities]
     # flattened
     return [val for sublist in output for val in sublist]
Example #5
0
 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])
Example #6
0
	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])
Example #7
0
 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])
Example #8
0
	def prepare_input_in_vivo(self, expD):
		copied_model = copy(self.model)
		copied_model.ID = 'copied_%s' % self.model.ID
		copied_model.apply_interventions(expD.interventions)
		exported_ent = exporter.export_entities(self.all_ent)
		exported_comp = exporter.export_compartments(self.all_comp)
		exported_act = exporter.export_activities(self.all_act + self.archive.import_activities)
		exported_model = exporter.export_models_exp_design([copied_model])
		exported_model_rules = exporter.models_rules(len(copied_model.intermediate_activities))
		exported_display = exporter.export_display_for_oracle(expD)
		exported_prediction_rules = exporter.predictions_rules()
		inp = [exported_display, exported_ent, exported_comp, exported_act, exported_model, exported_prediction_rules, exported_model_rules]
		inp = [val for sublist in inp for val in sublist]
		return inp
Example #9
0
 def prepare_input_for_exp_design(self):
     exported = []
     # export hide/show stuff
     exported.extend(exporter.hide_show_statements())
     exported.extend(
         exporter.export_compartments(self.archive.mnm_compartments))
     exported.extend(exporter.export_entities(self.archive.mnm_entities))
     exported.extend(
         exporter.export_activities(self.archive.mnm_activities +
                                    self.archive.import_activities))
     # export models info
     exported.extend(
         exporter.export_models_exp_design(self.archive.working_models))
     # + probabilities and numbers
     exported.extend(
         exporter.models_nr_and_probabilities(self.archive.working_models))
     # export design elements (modeh eqiv)
     exported.append(exporter.modeh_replacement(self.cost_model))
     # export rules forcing and restricting exp design
     exported.extend(exporter.design_constraints_basic())
     for exp in self.archive.known_results:
         exp_descriptions = [res.exp_description for res in exp.results]
         for des in exp_descriptions:
             # export ban experiment(s) (from old exps)
             exported.extend(exporter.ban_experiment(des))
     # calculate constant for scores and export it
     exported.append(
         exporter.constant_for_calculating_score(
             self.calculate_constant_for_scores()))
     # export scoring rules/optimisation
     exported.extend(exporter.advanced_exp_design_rules())
     # * export cost, and optimisation rule for that
     if self.use_costs:
         exported.extend(exporter.cost_rules(self.cost_model))
         exported.extend(exporter.cost_minimisation_rules())
     else:
         pass
         # export design rules
     exported.extend(exporter.experiment_design_rules())
     exported.extend(exporter.interventions_rules())
     exported.extend(exporter.predictions_rules())
     exported.extend(
         exporter.models_rules(
             len(self.archive.mnm_activities +
                 self.archive.import_activities)))
     return exported