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_pfba(self, core_model):
original_objective = core_model.objective
fba_solution = fba(core_model)
fba_flux_sum = sum((abs(val) for val in list(fba_solution.fluxes.values)))
pfba_solution = pfba(core_model)
pfba_flux_sum = sum((abs(val) for val in list(pfba_solution.fluxes.values)))
# looks like GLPK finds a parsimonious solution without the flux minimization objective
assert (pfba_flux_sum - fba_flux_sum) < 1e-6, \
"FBA sum is suppose to be lower than PFBA (was %f)" % (pfba_flux_sum - fba_flux_sum)
assert core_model.objective.expression == original_objective.expression
def test_pfba(self):
fba_solution = fba(self.model)
fba_flux_sum = sum((abs(val) for val in list(fba_solution.fluxes.values())))
pfba_solution = pfba(self.model)
pfba_flux_sum = sum((abs(val) for val in list(pfba_solution.fluxes.values())))
# looks like GLPK finds a parsimonious solution without the flux minimization objective
self.assertTrue((pfba_flux_sum - fba_flux_sum) < 1e-6)
def test_lmoma_with_reaction_filter(self, core_model):
original_objective = core_model.objective
pfba_solution = pfba(core_model)
solution = lmoma(core_model, reference=pfba_solution,
reactions=['EX_o2_LPAREN_e_RPAREN_', 'EX_glc_LPAREN_e_RPAREN_'])
assert len(solution.fluxes) == 2
assert core_model.objective.expression == original_objective.expression
def test_pfba_ijo1366(self, ijo1366):
original_objective = ijo1366.objective
fba_solution = fba(ijo1366)
fba_flux_sum = sum((abs(val) for val in fba_solution.fluxes.values))
pfba_solution = pfba(ijo1366)
pfba_flux_sum = sum((abs(val) for val in pfba_solution.fluxes.values))
assert (pfba_flux_sum - fba_flux_sum) < 1e-6, \
"FBA sum is suppose to be lower than PFBA (was %f)" % (pfba_flux_sum - fba_flux_sum)
assert ijo1366.objective.expression == original_objective.expression
def test_lmoma(self, core_model):
original_objective = core_model.objective
pfba_solution = pfba(core_model)
solution = lmoma(core_model, reference=pfba_solution)
distance = sum((abs(solution[v] - pfba_solution[v]) for v in pfba_solution.keys()))
assert abs(0 - distance) < 1e-6, "lmoma distance without knockouts must be 0 (was %f)" % distance
assert core_model.objective.expression == original_objective.expression
def test_room(self):
pfba_solution = pfba(self.model)
solution = room(self.model, reference=pfba_solution)
self.assertAlmostEqual(0, solution.objective_value,
delta=0.000001,
msg="room objective without knockouts must be 0 (was %f)" % solution.objective_value)
def test_pfba_with_reaction_filter(self, core_model):
original_objective = core_model.objective
pfba_solution = pfba(core_model, reactions=['EX_o2_LPAREN_e_RPAREN_', 'EX_glc_LPAREN_e_RPAREN_'])
assert len(pfba_solution.fluxes) == 2
assert core_model.objective.expression == original_objective.expression
def simulation_method(self, simulation_method):
if simulation_method in [lmoma, moma, room] and self._simulation_kwargs.get("reference", None) is None:
logger.warning("No WT reference found, generating using pfba.")
self._simulation_kwargs['reference'] = pfba(self.model).fluxes
logger.warning("Reference successfully computed.")
self._simulation_method = simulation_method
def simulation_kwargs(self, simulation_kwargs):
if self.simulation_method in [lmoma, moma, room] and simulation_kwargs.get("reference", None) is None:
logger.warning("No WT reference found, generating using pfba.")
simulation_kwargs['reference'] = pfba(self.model).fluxes
logger.warning("Reference successfully computed.")
self._simulation_kwargs = simulation_kwargs
An object containing the identified reactions and the used parameters.
References
----------
.. [1] H. S. Choi, S. Y. Lee, T. Y. Kim, and H. M. Woo, 'In silico identification of gene amplification targets
for improvement of lycopene production.,' Appl Environ Microbiol, vol. 76, no. 10, pp. 3097–3105, May 2010.
"""
model = self.model
target = get_reaction_for(model, target)
simulation_kwargs = simulation_kwargs if simulation_kwargs is not None else {}
simulation_kwargs['objective'] = self.primary_objective
if 'reference' not in simulation_kwargs:
reference = simulation_kwargs['reference'] = pfba(model, **simulation_kwargs)
else:
reference = simulation_kwargs['reference']
ndecimals = config.ndecimals
# Exclude list
exclude = list(exclude) + model.boundary
exclude_ids = [target.id]
for reaction in exclude:
if isinstance(reaction, Reaction):
exclude_ids.append(reaction.id)
else:
exclude_ids.append(reaction)
with TimeMachine() as tm: