def find_metabolites_consumed_with_closed_bounds(model): """ Return metabolites that can be consumed when boundary reactions are closed. Reverse case from 'find_metabolites_produced_with_closed_bounds', just like metabolites should not be produced from nothing, mass should not simply be removed from the model. Parameters ---------- model : cobra.Model The metabolic model under investigation. """ mets_consumed = list() helpers.close_boundaries_sensibly(model) for met in model.metabolites: with model: exch = model.add_boundary(met, type='irrex', reaction_id='IRREX', lb=-1, ub=0) if helpers.run_fba(model, exch.id, direction='min') < 0: mets_consumed.append(met) return mets_consumed
def find_metabolites_not_consumed_with_open_bounds(model): """ Return metabolites that cannot be consumed with open boundary reactions. Reverse case from 'find_metabolites_not_produced_with_open_bounds', just like metabolites should all be produced with open exchanges, they should also all be consumed with open exchanges. Parameters ---------- model : cobra.Model The metabolic model under investigation. """ mets_not_consumed = list() helpers.open_boundaries(model) for met in model.metabolites: with model: exch = model.add_boundary(met, type="irrex", reaction_id="IRREX", lb=-1, ub=0) solution = helpers.run_fba(model, exch.id, direction="min") if solution is np.nan or solution == 0: mets_not_consumed.append(met) return mets_not_consumed
def find_blocked_biomass_precursors(reaction, model): """ Return a list of all biomass precursors that cannot be produced. Parameters ---------- reaction : cobra.core.reaction.Reaction The biomass reaction of the model under investigation. model : cobra.Model The metabolic model under investigation. Returns ------- list Metabolite objects that are reactants of the biomass reaction excluding ATP and H2O that cannot be produced by flux balance analysis. """ LOGGER.debug("Finding blocked biomass precursors") precursors = find_biomass_precursors(model, reaction) blocked_precursors = list() _, ub = helpers.find_bounds(model) for precursor in precursors: with model: dm_rxn = model.add_boundary(precursor, type="safe-demand", reaction_id="safe_demand", lb=0, ub=ub) flux = helpers.run_fba(model, dm_rxn.id, direction='max') if np.isnan(flux) or abs(flux) < 1E-08: blocked_precursors.append(precursor) return blocked_precursors
def find_blocked_biomass_precursors(reaction, model): """ Return a list of all biomass precursors that cannot be produced. Parameters ---------- reaction : cobra.core.reaction.Reaction The biomass reaction of the model under investigation. model : cobra.Model The metabolic model under investigation. Returns ------- list Metabolite objects that are reactants of the biomass reaction excluding ATP and H2O that cannot be produced by flux balance analysis. """ LOGGER.debug("Finding blocked biomass precursors") precursors = find_biomass_precursors(model, reaction) blocked_precursors = list() _, ub = helpers.find_bounds(model) for precursor in precursors: with model: dm_rxn = model.add_boundary( precursor, type="safe-demand", reaction_id="safe_demand", lb=0, ub=ub ) flux = helpers.run_fba(model, dm_rxn.id, direction='max') if np.isnan(flux) or abs(flux) < 1E-08: blocked_precursors.append(precursor) return blocked_precursors
def test_biomass_default_production(model, reaction_id): """ Expect biomass production in default medium. Using flux balance analysis this test optimizes the model for growth in the medium that is set by default. Any non-zero growth rate is accepted to pass this test. """ ann = test_biomass_default_production.annotation ann["data"][reaction_id] = helpers.run_fba(model, reaction_id) ann["message"][reaction_id] = wrapper.fill( """Using the biomass reaction {} this is the growth rate that can be achieved when the model is simulated on the provided default medium: {} """.format(reaction_id, ann["data"][reaction_id])) assert ann["data"][reaction_id] > 0.0, ann["message"][reaction_id]
def test_fast_growth_default(model, reaction_id): """ Expect the predicted growth rate for each BOF to be below 10.3972. The growth rate of a metabolic model should not be faster than that of the fastest growing organism. This is based on lowest doubling time reported here: http://www.pnnl.gov/science/highlights/highlight.asp?id=879 """ ann = test_fast_growth_default.annotation ann["data"][reaction_id] = helpers.run_fba(model, reaction_id) ann["message"][reaction_id] = wrapper.fill( """Using the biomass reaction {} and when the model is simulated on the provided default medium the growth rate amounts to {}""".format( reaction_id, ann["data"][reaction_id])) assert ann["data"][reaction_id] <= 10.3972, ann["message"][reaction_id]
def test_biomass_open_production(model, reaction_id): """ Expect biomass production in complete medium. Using flux balance analysis this test optimizes the model for growth using a complete medium i.e. unconstrained boundary reactions. Any non-zero growth rate is accepted to pass this test. """ ann = test_biomass_open_production.annotation helpers.open_boundaries(model) ann["data"][reaction_id] = helpers.run_fba(model, reaction_id) ann["metric"][reaction_id] = 1.0 # Placeholder value. ann["message"][reaction_id] = wrapper.fill( """Using the biomass reaction {} this is the growth rate that can be achieved when the model is simulated on a complete medium i.e. with all the boundary reactions unconstrained: {} """.format(reaction_id, ann["data"][reaction_id])) assert ann["data"][reaction_id] > 0.0, ann["message"][reaction_id]
def find_metabolites_produced_with_closed_bounds(model): """ Return metabolites that can be produced when boundary reactions are closed. Parameters ---------- model : cobra.Model The metabolic model under investigation. """ mets_produced = list() helpers.close_boundaries_sensibly(model) for met in model.metabolites: with model: exch = model.add_boundary(met, type='irrex', reaction_id='IRREX', lb=0, ub=1) if helpers.run_fba(model, exch.id) > 0: mets_produced.append(met) return mets_produced
def test_fast_growth_default(model, reaction_id): u""" Expect the predicted growth rate for each BOF to be below 2.81. The growth rate of a metabolic model should not be faster than that of the fastest growing organism. This is based on a doubling time of Vibrio natriegens which was reported to be 14.8 minutes by: Henry H. Lee, Nili Ostrov, Brandon G. Wong, Michaela A. Gold, Ahmad S. Khalil, George M. Church in https://www.biorxiv.org/content/biorxiv/early/2016/06/12/058487.full.pdf The calculation ln(2)/(14.8/60) ~ 2.81 yields the corresponding growth rate. Implementation: Calculate the solution of FBA with the biomass reaction set as objective function and a model's default constraints. Then check if the objective value is higher than 2.81. """ ann = test_fast_growth_default.annotation outcome = helpers.run_fba(model, reaction_id) > 2.81 ann["data"][reaction_id] = outcome ann["metric"][reaction_id] = 1.0 - float(outcome) if ann["data"][reaction_id]: ann["message"][reaction_id] = wrapper.fill( """Using the biomass reaction {} and when the model is simulated on the provided default medium the growth rate is *higher* than that of the fastest bacteria. This could be due to inconsistencies in the network or missing constraints.""".format(reaction_id)) else: ann["message"][reaction_id] = wrapper.fill( """Using the biomass reaction {} and when the model is simulated on the provided default medium the growth rate is *lower* than that of the fastest bacteria. This is to be expected for a majority of organisms.""".format(reaction_id)) assert outcome, ann["message"][reaction_id]
def test_biomass_default_production(model, reaction_id): """ Expect biomass production in default medium. Using flux balance analysis this test optimizes the model for growth in the medium that is set by default. Any non-zero growth rate is accepted to pass this test. Implementation: Calculate the solution of FBA with the biomass reaction set as objective function and the model's default constraints. """ ann = test_biomass_default_production.annotation ann["data"][reaction_id] = helpers.run_fba(model, reaction_id) outcome = ann["data"][reaction_id] > 1E-07 ann["metric"][reaction_id] = 1.0 - float(outcome) ann["message"][reaction_id] = wrapper.fill( """Using the biomass reaction {} this is the growth rate (1/h) that can be achieved when the model is simulated on the provided default medium: {} """.format(reaction_id, ann["data"][reaction_id])) assert outcome, ann["message"][reaction_id]
def test_biomass_open_production(model, reaction_id): """ Expect biomass production in complete medium. Using flux balance analysis this test optimizes the model for growth using a complete medium i.e. unconstrained boundary reactions. Any non-zero growth rate is accepted to pass this test. Implementation: Calculate the solution of FBA with the biomass reaction set as objective function and after removing any constraints from all boundary reactions. """ ann = test_biomass_open_production.annotation helpers.open_boundaries(model) ann["data"][reaction_id] = helpers.run_fba(model, reaction_id) outcome = ann["data"][reaction_id] > 1E-07 ann["metric"][reaction_id] = 1.0 - float(outcome) ann["message"][reaction_id] = wrapper.fill( """Using the biomass reaction {} this is the growth rate that can be achieved when the model is simulated on a complete medium i.e. with all the boundary reactions unconstrained: {} """.format(reaction_id, ann["data"][reaction_id])) assert outcome, ann["message"][reaction_id]