def test_gnomic_integration_FluxModulationTarget(self, model): # with pytest.raises(ValueError): # FluxModulationTarget("test", 0, 0) # TODO: this should really not be possible flux_modulation_target = FluxModulationTarget("test", 1, 0) flux_modulation_target_gnomic = flux_modulation_target.to_gnomic() expected = "flux.test(value=1)" assert genotype_to_string(Genotype([flux_modulation_target_gnomic])) == expected flux_modulation_target = FluxModulationTarget("PGK", 0.5, 1, accession_id="PGK", accession_db="bigg") flux_modulation_target_gnomic = flux_modulation_target.to_gnomic() expected = "flux.PGK#bigg:PGK(value=0.5)" assert genotype_to_string(Genotype([flux_modulation_target_gnomic])) == expected
def test_gnomic_integration_ReactionKnockinTarget(self, model): reaction = Reaction(id="atpzase", name="Cosmic ATP generator") atp_z = Metabolite(id="atp_z", name="Cosmic ATP", compartment="c") reaction.add_metabolites({model.metabolites.atp_c: 1, atp_z: -1}) knockin_target = ReactionKnockinTarget("atpzase", reaction) knockin_target_gnomic = knockin_target.to_gnomic() assert genotype_to_string(Genotype([knockin_target_gnomic])) == "+reaction.atpzase" reaction.add_metabolites({model.metabolites.atp_c: 1, atp_z: -1}) knockin_target = ReactionKnockinTarget("atpzase", reaction, accession_id='atpzase', accession_db='unicorn') knockin_target_gnomic = knockin_target.to_gnomic() assert genotype_to_string(Genotype([knockin_target_gnomic])) == "+reaction.atpzase#unicorn:atpzase"
def test_gnomic_integration_ReactionCofactorSwapTarget(self, model): cofactor_id_swaps = [("nad_c", "nadh_c"), ("nadp_c", "nadph_c")] swap_pairs = ([model.metabolites.get_by_id(m) for m in cofactor_id_swaps[0]], [model.metabolites.get_by_id(m) for m in cofactor_id_swaps[1]]) swap_target = ReactionCofactorSwapTarget("GAPD", swap_pairs) swap_target_gnomic = swap_target.to_gnomic() expected = "reaction.GAPD(cofactors=nadp_c,nadph_c)" assert genotype_to_string(Genotype([swap_target_gnomic])) == expected
def test_gene_knockout_target(self, model): gene = "b4025" knockout_target = GeneKnockoutTarget(gene, accession_id=gene, accession_db='bigg') knockout_target_gnomic = knockout_target.to_gnomic() assert genotype_to_string(Genotype([knockout_target_gnomic])) == "-b4025#bigg:b4025" with model: knockout_target.apply(model) assert model.reactions.PGI.lower_bound == 0 assert model.reactions.PGI.upper_bound == 0 assert abs(model.optimize().f - 0.8631) < 0.0001 assert model.reactions.PGI.lower_bound == -1000 assert model.reactions.PGI.upper_bound == 1000
def _repr_html_(self): return genotype_to_text(Genotype([self.to_gnomic()]))
def __str__(self): return genotype_to_string(Genotype([self.to_gnomic()]))