How to use the cameo.core.target.ReactionKnockoutTarget function in cameo

To help you get started, we’ve selected a few cameo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github biosustain / cameo / tests / test_targets.py View on Github external
def test_hashable(self):
        knockout_target1 = ReactionKnockoutTarget("ACALD")
        knockout_target2 = ReactionKnockoutTarget("ACALD")

        assert knockout_target1 == knockout_target2
        assert hash(knockout_target1) == hash(knockout_target2)

        assert len({knockout_target1, knockout_target2}) == 1
github biosustain / cameo / tests / test_core_strain_design.py View on Github external
def test_design_to_gnomic(self, cad_reaction):
        from gnomic import Genotype
        t1 = ReactionKnockoutTarget('PGI')
        t2 = ReactionKnockoutTarget('GAPD')
        t3 = ReactionKnockinTarget("CAD", cad_reaction)

        strain_design1 = StrainDesign([t1, t2, t3])

        sd_gnomic = strain_design1.to_gnomic()

        assert isinstance(sd_gnomic, Genotype)
        assert len(sd_gnomic.added_features) == 1
        assert len(sd_gnomic.removed_features) == 2
github biosustain / cameo / tests / test_core_strain_design.py View on Github external
def test_add_strain_design(self, cad_reaction):
        t1 = ReactionKnockoutTarget('PGI')
        t2 = ReactionKnockoutTarget('GAPD')
        t3 = ReactionKnockinTarget("CAD", cad_reaction)

        strain_design1 = StrainDesign([t1, t2, t3])

        t4 = ReactionModulationTarget("PGI", 5, 1)

        strain_design2 = StrainDesign([t4])

        with pytest.raises(IncompatibleTargets):
            strain_design1.__add__(strain_design2)
        with pytest.raises(IncompatibleTargets):
            strain_design2.__add__(strain_design1)

        with pytest.raises(IncompatibleTargets):
            strain_design1.__iadd__(strain_design2)
github biosustain / cameo / tests / test_targets.py View on Github external
def test_invalid_reaction_knockout_target(self, model):
        knockout_target = ReactionKnockoutTarget("ACALDXYZ")

        with pytest.raises(KeyError):
            knockout_target.apply(model)
github biosustain / cameo / tests / test_core_strain_design.py View on Github external
def test_add_strain_design(self, cad_reaction):
        t1 = ReactionKnockoutTarget('PGI')
        t2 = ReactionKnockoutTarget('GAPD')
        t3 = ReactionKnockinTarget("CAD", cad_reaction)

        strain_design1 = StrainDesign([t1, t2, t3])

        t4 = ReactionModulationTarget("PGI", 5, 1)

        strain_design2 = StrainDesign([t4])

        with pytest.raises(IncompatibleTargets):
            strain_design1.__add__(strain_design2)
        with pytest.raises(IncompatibleTargets):
            strain_design2.__add__(strain_design1)

        with pytest.raises(IncompatibleTargets):
            strain_design1.__iadd__(strain_design2)
        with pytest.raises(IncompatibleTargets):
github biosustain / cameo / cameo / strain_design / deterministic / flux_variability_based.py View on Github external
def _generate_designs(reference, enforced_levels, reaction_results):
        for i, level in enumerate(enforced_levels):
            targets = []
            for reaction, value in reaction_results.items():
                if abs(reference[reaction.id]) > 0:
                    if value[i] == 0:
                        targets.append(ReactionKnockoutTarget(reaction.id))
                    elif value[i] > reference[reaction.id]:
                        targets.append(ReactionModulationTarget(reaction.id, value[i], reference[reaction.id]))

            yield StrainDesign(targets)
github biosustain / cameo / cameo / strain_design / deterministic / flux_variability_based.py View on Github external
Returns
        -------
        list
            A list of cameo.core.strain_design.StrainDesign for each DataFrame in solutions.
        """
        designs = []
        for _, solution in solutions.groupby(('biomass', 'production'), as_index=False, sort=False):
            targets = []
            relevant_targets = solution[
                (solution['normalized_gaps'].abs() > non_zero_flux_threshold) & (
                    ~solution['excluded']) & (
                        ~solution['free_flux'])
            ]
            # Generate all knock-out targets.
            for rid in relevant_targets.loc[relevant_targets["KO"], "reaction"]:
                targets.append(ReactionKnockoutTarget(rid))
            # Generate all flux inversion targets.
            for row in relevant_targets[
                relevant_targets["flux_reversal"]
            ].itertuples():
                rid = row.Index
                ref_lower = reference_fva.at[rid, 'lower_bound']
                ref_upper = reference_fva.at[rid, 'upper_bound']
                if ref_upper > 0:
                    # Production point is negative so closest inversion is
                    # from reference lower bound to production upper bound.
                    targets.append(ReactionInversionTarget(
                        rid,
                        value=row.upper_bound,
                        reference_value=ref_lower
                    ))
                else:
github biosustain / cameo / cameo / strain_design / deterministic / linear_programming.py View on Github external
def _generate_designs(knockouts):
        designs = []
        for knockout_design in knockouts:
            designs.append(StrainDesign([ReactionKnockoutTarget(ko for ko in knockout_design)]))

        return designs
github biosustain / cameo / cameo / core / target.py View on Github external
def __init__(self, id):
        super(ReactionKnockoutTarget, self).__init__(id, 0, None)