def find_exchange_rxns(model): u""" Return a list of exchange reactions. Parameters ---------- model : cobra.Model The metabolic model under investigation. Notes ----- [1] defines exchange reactions as: -- reactions that 'define the extracellular environment' -- 'unbalanced, extra-organism reactions that represent the supply to or removal of metabolites from the extra-organism "space"' -- reactions with a formula such as: 'met_e -> ' or ' -> met_e' or 'met_e <=> ' Exchange reactions differ from demand reactions in that the metabolites are removed from or added to the extracellular environment only. With this the uptake or secretion of a metabolite is modeled, respectively. References ---------- .. [1] Thiele, I., & Palsson, B. Ø. (2010, January). A protocol for generating a high-quality genome-scale metabolic reconstruction. Nature protocols. Nature Publishing Group. http://doi.org/10.1038/nprot.2009.203 """ try: extracellular = find_compartment_id_in_model(model, 'e') except KeyError: extracellular = None return find_boundary_types(model, 'exchange', extracellular)
def extend_exchanges(model, cpd_ids, ex): model_exchanges = set(find_boundary_types(model, 'exchange', external_compartment=ex)) new_ex_ids = set() for cpd in cpd_ids: cpd = model.metabolites.get_by_id(cpd) if str(cpd.compartment) != ex: continue else: if bool(set(cpd.reactions) & model_exchanges) == False: try: new_id = 'EX_' + cpd.id model.add_boundary(cpd, type='exchange', reaction_id=new_id, lb=-1000.0, ub=1000.0) new_ex_ids |= set([new_id]) except ValueError: pass return new_ex_ids
def find_demand_reactions(model): u""" Return a list of demand reactions. Parameters ---------- model : cobra.Model The metabolic model under investigation. Notes ----- [1] defines demand reactions as: -- 'unbalanced network reactions that allow the accumulation of a compound' -- reactions that are chiefly added during the gap-filling process -- as a means of dealing with 'compounds that are known to be produced by the organism [..] (i) for which no information is available about their fractional distribution to the biomass or (ii) which may only be produced in some environmental conditions -- reactions with a formula such as: 'met_c -> ' Demand reactions differ from exchange reactions in that the metabolites are not removed from the extracellular environment, but from any of the organism's compartments. References ---------- .. [1] Thiele, I., & Palsson, B. Ø. (2010, January). A protocol for generating a high-quality genome-scale metabolic reconstruction. Nature protocols. Nature Publishing Group. http://doi.org/10.1038/nprot.2009.203 """ try: extracellular = find_compartment_id_in_model(model, 'e') except KeyError: extracellular = None return find_boundary_types(model, 'demand', extracellular)
def find_sink_reactions(model): u""" Return a list of sink reactions. Parameters ---------- model : cobra.Model The metabolic model under investigation. Notes ----- [1] defines sink reactions as: -- 'similar to demand reactions' but reversible, thus able to supply the model with metabolites -- reactions that are chiefly added during the gap-filling process -- as a means of dealing with 'compounds that are produced by nonmetabolic cellular processes but that need to be metabolized' -- reactions with a formula such as: 'met_c <-> ' Sink reactions differ from exchange reactions in that the metabolites are not removed from the extracellular environment, but from any of the organism's compartments. References ---------- .. [1] Thiele, I., & Palsson, B. Ø. (2010, January). A protocol for generating a high-quality genome-scale metabolic reconstruction. Nature protocols. Nature Publishing Group. http://doi.org/10.1038/nprot.2009.203 """ try: extracellular = find_compartment_id_in_model(model, 'e') except KeyError: extracellular = None return find_boundary_types(model, 'sink', extracellular)
def demands(self): """Demand reactions in model. Irreversible reactions that accumulate or consume a metabolite in the inside of the model. """ return find_boundary_types(self, "demand", None)
def exchanges(self): """Exchange reactions in model. Reactions that exchange mass with the exterior. Uses annotations and heuristics to exclude non-exchanges such as sink reactions. """ return find_boundary_types(self, "exchange", None)
def sinks(self): """Sink reactions in model. Reversible reactions that accumulate or consume a metabolite in the inside of the model. """ return find_boundary_types(self, "sink", None)
def test_exchange(self, model): ex = model.exchanges assert all(r.id.startswith("EX_") for r in ex) ex = medium.find_boundary_types(model, "exchange", "e") assert all(r.id.startswith("EX_") for r in ex)
def test_no_boundary_reactions(self, empty_model): assert medium.find_boundary_types(empty_model, 'e', None) == []
def test_no_boundary_reactions(empty_model: Model) -> None: """Test proper identification of no boundary reactions.""" assert find_boundary_types(empty_model, "e", None) == []
def test_find_boundary_types_exchange(model: Model) -> None: """Test boundary type identification for exchanges.""" ex = model.exchanges assert all(r.id.startswith("EX_") for r in ex) ex = find_boundary_types(model, "exchange", "e") assert all(r.id.startswith("EX_") for r in ex)