Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    def test_gnomic_integration(self, model):
        from gnomic.models import Accession, Feature, Mutation, FeatureTree
        abstract_target = Target("test")
        abstract_target_gnomic = abstract_target.to_gnomic()
        assert isinstance(abstract_target_gnomic, Accession)
        assert abstract_target_gnomic.identifier == abstract_target.id

        flux_modulation_target = FluxModulationTarget("test", 1, 0)
        flux_modulation_target_gnomic = flux_modulation_target.to_gnomic()
        flux_mod_new = flux_modulation_target_gnomic.new
        flux_mod_old = flux_modulation_target_gnomic.old
        assert isinstance(flux_modulation_target_gnomic, Mutation)
        assert isinstance(flux_mod_old, FeatureTree)
        assert isinstance(flux_mod_old[0], Feature)
        assert flux_mod_old[
            0].accession.identifier == flux_modulation_target.id
        assert flux_mod_old[0].variant is None
        assert flux_mod_old[0].type == 'flux'
        assert isinstance(flux_mod_new, FeatureTree)
        assert isinstance(flux_mod_new[0], Feature)
        assert flux_mod_new[
            0].accession.identifier == flux_modulation_target.id
        assert flux_mod_new[0].type == 'flux'
        assert flux_mod_new[
            0].variant == "over-expression(%.3f)" % flux_modulation_target.fold_change

        flux_modulation_target = FluxModulationTarget("test", 0.5, 1)
        flux_modulation_target_gnomic = flux_modulation_target.to_gnomic()
        flux_mod_new = flux_modulation_target_gnomic.new
        flux_mod_old = flux_modulation_target_gnomic.old
        assert isinstance(flux_modulation_target_gnomic, Mutation)
        assert isinstance(flux_mod_old, FeatureTree)
        assert isinstance(flux_mod_old[0], Feature)
        assert flux_mod_old[
            0].accession.identifier == flux_modulation_target.id
        assert flux_mod_old[0].variant is None
        assert flux_mod_old[0].type == 'flux'
        assert isinstance(flux_mod_new, FeatureTree)
        assert isinstance(flux_mod_new[0], Feature)
        assert flux_mod_new[
            0].accession.identifier == flux_modulation_target.id
        assert flux_mod_new[0].type == 'flux'
        assert flux_mod_new[
            0].variant == "down-regulation(%.3f)" % flux_modulation_target.fold_change

        flux_modulation_target = FluxModulationTarget("test", 0, 1)
        flux_modulation_target_gnomic = flux_modulation_target.to_gnomic()
        assert isinstance(flux_modulation_target_gnomic, Mutation)
        assert isinstance(flux_modulation_target_gnomic.old, FeatureTree)
        assert isinstance(flux_modulation_target_gnomic.old[0], Feature)
        assert flux_modulation_target_gnomic.old[
            0].accession.identifier == flux_modulation_target.id
        assert flux_modulation_target_gnomic.old[0].variant is None
        assert flux_modulation_target_gnomic.old[0].type == 'flux'
        assert flux_modulation_target_gnomic.new is None

        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 isinstance(knockin_target_gnomic, Mutation)
        assert isinstance(knockin_target_gnomic.new, FeatureTree)
        assert isinstance(knockin_target_gnomic.new[0], Feature)
        assert knockin_target_gnomic.new[
            0].accession.identifier == knockin_target.id
        assert knockin_target_gnomic.new[0].variant is None
        assert knockin_target_gnomic.new[0].type == 'reaction'
        assert knockin_target_gnomic.old is None

        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()

        assert isinstance(swap_target_gnomic, Mutation)
        assert isinstance(swap_target_gnomic.old, FeatureTree)
        assert isinstance(swap_target_gnomic.old[0], Feature)
        assert swap_target_gnomic.old[0].accession.identifier == swap_target.id
        assert swap_target_gnomic.old[0].variant is None
        assert swap_target_gnomic.old[0].type == 'reaction'
        assert isinstance(swap_target_gnomic.new, FeatureTree)
        assert isinstance(swap_target_gnomic.new[0], Feature)
        assert swap_target_gnomic.new[
            0].accession.identifier == swap_target.id + swap_target.swap_str
        assert swap_target_gnomic.new[0].variant is None
        assert swap_target_gnomic.new[0].type == 'reaction'