Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_reaction_knock_in_target(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)
with model:
knockin_target.apply(model)
assert atp_z in model.metabolites
assert reaction in model.reactions
assert atp_z not in model.metabolites
assert reaction not in model.reactions
ki_target = ReactionKnockinTarget("a", None)
ensemble_1 = EnsembleTarget("a", [modulation_target, ki_target])
ensemble_2 = EnsembleTarget("a", [ki_target, modulation_target])
assert ensemble_1.targets == ensemble_2.targets
modulation_target = ReactionModulationTarget("b", 1, 0)
swap_target = ReactionCofactorSwapTarget("b", [("nad_c", "nadh_c"), ("nadp_c", "nadph_c")])
ensemble_1 = EnsembleTarget("b", [modulation_target, swap_target])
ensemble_2 = EnsembleTarget("b", [swap_target, modulation_target])
assert ensemble_1.targets == ensemble_2.targets
ki_target = ReactionKnockinTarget("c", None)
modulation_target = ReactionModulationTarget("c", 1, 0)
swap_target = ReactionCofactorSwapTarget("c", [("nad_c", "nadh_c"), ("nadp_c", "nadph_c")])
ensemble = EnsembleTarget("c", [modulation_target, swap_target, ki_target])
assert ensemble.targets[0] == ki_target
assert ensemble.targets[1] == swap_target
assert ensemble.targets[2] == modulation_target
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):
strain_design2.__iadd__(strain_design1)
with pytest.raises(IncompatibleTargets):
EnsembleTarget("a", [ko_target, ki_target])
with pytest.raises(IncompatibleTargets):
EnsembleTarget("a", [ki_target, ko_target])
ko_target = ReactionKnockoutTarget("b")
swap_target = ReactionCofactorSwapTarget("b", [("nad_c", "nadh_c"), ("nadp_c", "nadph_c")])
with pytest.raises(IncompatibleTargets):
EnsembleTarget("b", [ko_target, swap_target])
with pytest.raises(IncompatibleTargets):
EnsembleTarget("b", [swap_target, ko_target])
modulation_target = ReactionModulationTarget("c", 0, 0)
ki_target = ReactionKnockinTarget("c", None)
with pytest.raises(IncompatibleTargets):
EnsembleTarget("c", [modulation_target, ki_target])
with pytest.raises(IncompatibleTargets):
EnsembleTarget("c", [ki_target, modulation_target])
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"
targets = DictList()
for reaction in self.reactions:
reaction = self._replace_adapted_metabolites(reaction)
if reaction.id in metanetx.mnx2all:
target = ReactionKnockinTarget(reaction.id, reaction, accession_id=reaction.id, accession_db='metanetx')
else:
target = ReactionKnockinTarget(reaction.id, reaction)
targets.append(target)
for reaction in self.exchanges:
reaction = self._replace_adapted_metabolites(reaction)
targets.append(ReactionKnockinTarget(reaction.id, reaction))
product = self._replace_adapted_metabolites(self.product)
product.lower_bound = 0
targets.append(ReactionKnockinTarget(product.id, product))
return targets
def _build_targets(self):
targets = DictList()
for reaction in self.reactions:
reaction = self._replace_adapted_metabolites(reaction)
if reaction.id in metanetx.mnx2all:
target = ReactionKnockinTarget(reaction.id, reaction, accession_id=reaction.id, accession_db='metanetx')
else:
target = ReactionKnockinTarget(reaction.id, reaction)
targets.append(target)
for reaction in self.exchanges:
reaction = self._replace_adapted_metabolites(reaction)
targets.append(ReactionKnockinTarget(reaction.id, reaction))
product = self._replace_adapted_metabolites(self.product)
product.lower_bound = 0
targets.append(ReactionKnockinTarget(product.id, product))
return targets
def _build_targets(self):
targets = DictList()
for reaction in self.reactions:
reaction = self._replace_adapted_metabolites(reaction)
if reaction.id in metanetx.mnx2all:
target = ReactionKnockinTarget(reaction.id, reaction, accession_id=reaction.id, accession_db='metanetx')
else:
target = ReactionKnockinTarget(reaction.id, reaction)
targets.append(target)
for reaction in self.exchanges:
reaction = self._replace_adapted_metabolites(reaction)
targets.append(ReactionKnockinTarget(reaction.id, reaction))
product = self._replace_adapted_metabolites(self.product)
product.lower_bound = 0
targets.append(ReactionKnockinTarget(product.id, product))
return targets