:py:mod:`cobra.flux_analysis` ============================= .. py:module:: cobra.flux_analysis .. autoapi-nested-parse:: Provide functions related to Flux Analysis. Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 deletion/index.rst fastcc/index.rst gapfilling/index.rst geometric/index.rst helpers/index.rst loopless/index.rst moma/index.rst parsimonious/index.rst phenotype_phase_plane/index.rst reaction/index.rst room/index.rst variability/index.rst Package Contents ---------------- Functions ~~~~~~~~~ .. autoapisummary:: cobra.flux_analysis.double_gene_deletion cobra.flux_analysis.double_reaction_deletion cobra.flux_analysis.single_gene_deletion cobra.flux_analysis.single_reaction_deletion cobra.flux_analysis.fastcc cobra.flux_analysis.gapfill cobra.flux_analysis.geometric_fba cobra.flux_analysis.loopless_solution cobra.flux_analysis.add_loopless cobra.flux_analysis.add_moma cobra.flux_analysis.moma cobra.flux_analysis.pfba cobra.flux_analysis.find_blocked_reactions cobra.flux_analysis.find_essential_genes cobra.flux_analysis.find_essential_reactions cobra.flux_analysis.flux_variability_analysis cobra.flux_analysis.production_envelope cobra.flux_analysis.add_room cobra.flux_analysis.room .. py:function:: double_gene_deletion(model: cobra.core.Model, gene_list1: Optional[List[Union[cobra.core.Gene, str]]] = None, gene_list2: Optional[List[Union[cobra.core.Gene, str]]] = None, method: str = 'fba', solution: Optional[cobra.Solution] = None, processes: Optional[int] = None, **kwargs) -> pandas.DataFrame Knock out each gene pair from the combination of two given lists. We say 'pair' here but the order order does not matter. :param model: The metabolic model to perform deletions in. :type model: cobra.Model :param gene_list1: The first gene list to be deleted. If not passed, all the genes from the model are used (default None). :type gene_list1: list of cobra.Gene or str, optional :param gene_list2: The second gene list to be deleted. If not passed, all the genes from the model are used (default None). :type gene_list2: list of cobra.Gene or str, optional :param method: Method used to predict the growth rate (default None). :type method: {"fba", "moma", "linear moma", "room", "linear room"}, optional :param solution: A previous solution to use as a reference for (linear) MOMA or ROOM (default None). :type solution: cobra.Solution, optional :param processes: The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not passed, will be set to `configuration.processes` (default None). :type processes: int, optional :param \*\*kwargs: Keyword arguments are passed on to underlying simulation functions such as `add_room`. :returns: A representation of all combinations of gene deletions. The columns are 'growth' and 'status', where index : tuple(str) The gene identifiers that were knocked out. growth : float The growth rate of the adjusted model. status : str The solution's status. :rtype: pandas.DataFrame .. py:function:: double_reaction_deletion(model: cobra.core.Model, reaction_list1: Optional[List[Union[cobra.core.Reaction, str]]] = None, reaction_list2: Optional[List[Union[cobra.core.Reaction, str]]] = None, method: str = 'fba', solution: Optional[cobra.Solution] = None, processes: Optional[int] = None, **kwargs) -> pandas.DataFrame Knock out each reaction pair from the combinations of two given lists. We say 'pair' here but the order order does not matter. :param model: The metabolic model to perform deletions in. :type model: cobra.Model :param reaction_list1: The first reaction list to be deleted. If not passed, all the reactions from the model are used (default None). :type reaction_list1: list of cobra.Reaction or str, optional :param reaction_list2: The second reaction list to be deleted. If not passed, all the reactions from the model are used (default None). :type reaction_list2: list of cobra.Reaction or str, optional :param method: Method used to predict the growth rate (default "fba"). :type method: {"fba", "moma", "linear moma", "room", "linear room"}, optional :param solution: A previous solution to use as a reference for (linear) MOMA or ROOM (default None). :type solution: cobra.Solution, optional :param processes: The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not passed, will be set to `configuration.processes` (default None). :type processes: int, optional :param \*\*kwargs: Keyword arguments are passed on to underlying simulation functions such as `add_room`. :returns: A representation of all combinations of reaction deletions. The columns are 'growth' and 'status', where index : tuple(str) The reaction identifiers that were knocked out. growth : float The growth rate of the adjusted model. status : str The solution's status. :rtype: pandas.DataFrame .. py:function:: single_gene_deletion(model: cobra.core.Model, gene_list: Optional[List[Union[cobra.core.Gene, str]]] = None, method: str = 'fba', solution: Optional[cobra.Solution] = None, processes: Optional[int] = None, **kwargs) -> pandas.DataFrame Knock out each gene from `gene_list`. :param model: The metabolic model to perform deletions in. :type model: cobra.Model :param gene_list: The gene objects to be deleted. If not passed, all the genes from the model are used (default None). :type gene_list: list of cobra.Gene or str, optional :param method: Method used to predict the growth rate (default "fba"). :type method: {"fba", "moma", "linear moma", "room", "linear room"}, optional :param solution: A previous solution to use as a reference for (linear) MOMA or ROOM (default None). :type solution: cobra.Solution, optional :param processes: The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not passed, will be set to `configuration.processes` (default None). :type processes: int, optional :param \*\*kwargs: Keyword arguments are passed on to underlying simulation functions such as `add_room`. :returns: A representation of all single gene deletions. The columns are 'growth' and 'status', where index : tuple(str) The gene identifier that was knocked out. growth : float The growth rate of the adjusted model. status : str The solution's status. :rtype: pandas.DataFrame .. py:function:: single_reaction_deletion(model: cobra.core.Model, reaction_list: Optional[List[Union[cobra.core.Reaction, str]]] = None, method: str = 'fba', solution: Optional[cobra.Solution] = None, processes: Optional[int] = None, **kwargs) -> pandas.DataFrame Knock out each reaction from `reaction_list`. :param model: The metabolic model to perform deletions in. :type model: cobra.Model :param reaction_list: The reactions be knocked out. If not passed, all the reactions from the model are used (default None). :type reaction_list: list of cobra.Reaction or str, optional :param method: Method used to predict the growth rate (default "fba"). :type method: {"fba", "moma", "linear moma", "room", "linear room"}, optional :param solution: A previous solution to use as a reference for (linear) MOMA or ROOM (default None). :type solution: cobra.Solution, optional :param processes: The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not passed, will be set to `configuration.processes` (default None). :type processes: int, optional :param \*\*kwargs: Keyword arguments are passed on to underlying simulation functions such as `add_room`. :returns: A representation of all single reaction deletions. The columns are 'growth' and 'status', where index : tuple(str) The reaction identifier that was knocked out. growth : float The growth rate of the adjusted model. status : str The solution's status. :rtype: pandas.DataFrame .. py:function:: fastcc(model: cobra.core.Model, flux_threshold: float = 1.0, zero_cutoff: Optional[float] = None) -> cobra.core.Model Check consistency of a metabolic network using FASTCC [1]_. FASTCC (Fast Consistency Check) is an algorithm for rapid and efficient consistency check in metabolic networks. FASTCC is a pure LP implementation and is low on computation resource demand. FASTCC also circumvents the problem associated with reversible reactions for the purpose. Given a global model, it will generate a consistent global model i.e., remove blocked reactions. For more details on FASTCC, please check [1]_. :param model: The model to operate on. :type model: cobra.Model :param flux_threshold: The flux threshold to consider (default 1.0). :type flux_threshold: float, optional :param zero_cutoff: The cutoff to consider for zero flux (default model.tolerance). :type zero_cutoff: float, optional :returns: The consistent model. :rtype: cobra.Model .. rubric:: Notes The LP used for FASTCC is like so: maximize: \sum_{i \in J} z_i s.t. : z_i \in [0, \varepsilon] \forall i \in J, z_i \in \mathbb{R}_+ v_i \ge z_i \forall i \in J Sv = 0 v \in B .. rubric:: References .. [1] Vlassis N, Pacheco MP, Sauter T (2014) Fast Reconstruction of Compact Context-Specific Metabolic Network Models. PLoS Comput Biol 10(1): e1003424. doi:10.1371/journal.pcbi.1003424 .. py:function:: gapfill(model: cobra.core.Model, universal: Optional[cobra.core.Model] = None, lower_bound: float = 0.05, penalties: Optional[Dict[str, cobra.Reaction]] = None, demand_reactions: bool = True, exchange_reactions: bool = False, iterations: int = 1) Perform gap filling on a model. :param model: The model to perform gap filling on. :type model: cobra.Model :param universal: A universal model with reactions that can be used to complete the model. Only gapfill considering demand and exchange reactions if left missing (default None). :type universal: cobra.Model, optional :param lower_bound: The minimally accepted flux for the objective in the filled model. (default 0.05). :type lower_bound: float, optional :param penalties: A dictionary with keys being 'universal' (all reactions included in the universal model), 'exchange' and 'demand' (all additionally added exchange and demand reactions) for the three reaction types. Can also have reaction identifiers for reaction specific costs. Defaults are 1, 100 and 1 respectively (default None). :type penalties: dict, optional :param exchange_reactions: Consider adding exchange (uptake) reactions for all metabolites in the model (default False). :type exchange_reactions: bool, optional :param demand_reactions: Consider adding demand reactions for all metabolites (default True). :type demand_reactions: bool, optional :param iterations: The number of rounds of gap filling to perform. For every iteration, the penalty for every used reaction increases linearly. This way, the algorithm is encouraged to search for alternative solutions which may include previously used reactions i.e., with enough iterations pathways including 10 steps will eventually be reported even if the shortest pathway is a single reaction (default 1). :type iterations: int, optional :returns: A list of lists with on set of reactions that completes the model per requested iteration. :rtype: list of list of cobra.Reaction .. rubric:: Examples >>> from cobra.io import load_model >>> from cobra import Model >>> from cobra.flux_analysis import gapfill >>> model = load_model("iYS1720") >>> universal = Model("universal") >>> universal.add_reactions([model.reactions.GF6PTA.copy()]) >>> model.remove_reactions([model.reactions.GF6PTA]) >>> gapfill(model, universal) [[]] .. py:function:: geometric_fba(model: cobra.Model, epsilon: float = 1e-06, max_tries: int = 200, processes: Optional[int] = None) -> cobra.Solution Perform geometric FBA to obtain a unique, centered flux distribution. Geometric FBA [1]_ formulates the problem as a polyhedron and then solves it by bounding the convex hull of the polyhedron. The bounding forms a box around the convex hull which reduces with every iteration and extracts a unique solution in this way. :param model: The model to perform geometric FBA on. :type model: cobra.Model :param epsilon: The convergence tolerance of the model (default 1E-06). :type epsilon: float, optional :param max_tries: Maximum number of iterations (default 200). :type max_tries: int, optional :param processes: The number of parallel processes to run. If not explicitly passed, will be set from the global configuration singleton (default None). :type processes: int, optional :returns: The solution object containing all the constraints required for geometric FBA. :rtype: cobra.Solution :raises RuntimeError: If iteration count becomes equal to `max_tries`. .. rubric:: References .. [1] Smallbone, Kieran & Simeonidis, Vangelis. (2009). Flux balance analysis: A geometric perspective. Journal of theoretical biology.258. 311-5. 10.1016/j.jtbi.2009.01.027. .. py:function:: loopless_solution(model: cobra.Model, fluxes: Optional[Dict[str, float]] = None) -> cobra.Solution Convert an existing solution to a loopless one. Removes as many loops as possible (see Notes). Uses the method from CycleFreeFlux [1]_ and is much faster than `add_loopless` and should therefore be the preferred option to get loopless flux distributions. :param model: The model to which to add the constraints. :type model: cobra.Model :param fluxes: A dictionary having keys as reaction IDs and values as their flux values. If not None will use the provided flux values to obtain a close loopless solution (default None). :type fluxes: dict of {str, float}, optional :returns: A solution object containing the fluxes with the least amount of loops possible or None if the optimization failed (usually happening if the flux distribution in `fluxes` is infeasible). :rtype: cobra.Solution .. rubric:: Notes The returned flux solution has the following properties: - It contains the minimal number of loops possible and no loops at all if all flux bounds include zero and the objective is not in a cycle. - It has the same objective value as the original flux solution and assumes that the objective does not participate in a cycle (which is usually true since it consumes metabolites). - It has the same exact exchange fluxes as the previous solution. - All fluxes have the same sign (flow in the same direction) as the previous solution. When providing fluxes to the method, please note that those have to come from the exact same model that you provided, meaning that no bounds or coefficients have been changed, and the optimum has remained the same. .. rubric:: References .. [1] CycleFreeFlux: efficient removal of thermodynamically infeasible loops from flux distributions. Desouki AA, Jarre F, Gelius-Dietrich G, Lercher MJ. Bioinformatics. 2015 Jul 1;31(13):2159-65. doi: 10.1093/bioinformatics/btv096. .. py:function:: add_loopless(model: cobra.Model, zero_cutoff: Optional[float] = None) -> None Modify a model so all feasible flux distributions are loopless. It adds variables and constraints to a model which will disallow flux distributions with loops. The used formulation is described in [1]_. This function *will* modify your model. In most cases you probably want to use the much faster `loopless_solution`. May be used in cases where you want to add complex constraints and objecives (for instance quadratic objectives) to the model afterwards or use an approximation of Gibbs free energy directions in your model. :param model: The model to which to add the constraints. :type model: cobra.Model :param zero_cutoff: Cutoff used for null space. Coefficients with an absolute value smaller than `zero_cutoff` are considered to be zero. The default uses the `model.tolerance` (default None). :type zero_cutoff: positive float, optional .. rubric:: References .. [1] Elimination of thermodynamically infeasible loops in steady-state metabolic models. Schellenberger J, Lewis NE, Palsson BO. Biophys J. 2011 Feb 2;100(3):544-53. doi: 10.1016/j.bpj.2010.12.3707. Erratum in: Biophys J. 2011 Mar 2;100(5):1381. .. py:function:: add_moma(model: cobra.core.Model, solution: Optional[cobra.core.Solution] = None, linear: bool = True) -> None Add MOMA constraints and objective representing to the `model`. This adds variables and constraints for the minimization of metabolic adjustment (MOMA) to the model. :param model: The model to add MOMA constraints and objective to. :type model: cobra.Model :param solution: A previous solution to use as a reference. If no solution is given, one will be computed using pFBA (default None). :type solution: cobra.Solution, optional :param linear: Whether to use the linear MOMA formulation or not (default True). :type linear: bool, optional .. rubric:: Notes In the original MOMA [1]_ specification, one looks for the flux distribution of the deletion (v^d) closest to the fluxes without the deletion (v). In math this means: minimize: \sum_i (v^d_i - v_i)^2 s.t. : Sv^d = 0 lb_i \le v^d_i \le ub_i Here, we use a variable transformation v^t := v^d_i - v_i. Substituting and using the fact that Sv = 0 gives: minimize: \sum_i (v^t_i)^2 s.t. : Sv^d = 0 v^t = v^d_i - v_i lb_i \le v^d_i \le ub_i So, basically we just re-center the flux space at the old solution and then find the flux distribution closest to the new zero (center). This is the same strategy as used in cameo. In the case of linear MOMA [2]_, we instead minimize \sum_i abs(v^t_i). The linear MOMA is typically significantly faster. Also, quadratic MOMA tends to give flux distributions in which all fluxes deviate from the reference fluxes a little bit whereas linear MOMA tends to give flux distributions where the majority of fluxes are the same reference with few fluxes deviating a lot (typical effect of L2 norm vs L1 norm). The former objective function is saved in the optlang solver interface as ``"moma_old_objective"`` and this can be used to immediately extract the value of the former objective after MOMA optimization. .. seealso:: :obj:`pfba` parsimonious FBA .. rubric:: References .. [1] Segrè, Daniel, Dennis Vitkup, and George M. Church. “Analysis of Optimality in Natural and Perturbed Metabolic Networks.” Proceedings of the National Academy of Sciences 99, no. 23 (November 12, 2002): 15112. https://doi.org/10.1073/pnas.232349399. .. [2] Becker, Scott A, Adam M Feist, Monica L Mo, Gregory Hannum, Bernhard Ø Palsson, and Markus J Herrgard. “Quantitative Prediction of Cellular Metabolism with Constraint-Based Models: The COBRA Toolbox.” Nature Protocols 2 (March 29, 2007): 727. .. py:function:: moma(model: cobra.core.Model, solution: Optional[cobra.core.Solution] = None, linear: bool = True) -> cobra.core.Solution Compute a single solution based on (linear) MOMA. Compute a new flux distribution that is at a minimal distance to a previous reference solution `solution`. Minimization of metabolic adjustment (MOMA) is generally used to assess the impact of knock-outs. Thus, the typical usage is to provide a wild-type flux distribution as reference and a model in knock-out state. :param model: The model state to compute a MOMA-based solution for. :type model: cobra.Model :param solution: A (wild-type) reference solution (default None). :type solution: cobra.Solution, optional :param linear: Whether to use the linear MOMA formulation or not (default True). :type linear: bool, optional :returns: A flux distribution that is at a minimal distance compared to the reference solution. :rtype: cobra.Solution .. seealso:: :obj:`add_moma` add MOMA constraints and objective .. py:function:: pfba(model: cobra.Model, fraction_of_optimum: float = 1.0, objective: Union[Dict, optlang.interface.Objective, None] = None, reactions: Optional[List[cobra.Reaction]] = None) -> cobra.Solution Perform basic pFBA (parsimonious Enzyme Usage Flux Balance Analysis). pFBA [1] adds the minimization of all fluxes the the objective of the model. This approach is motivated by the idea that high fluxes have a higher enzyme turn-over and that since producing enzymes is costly, the cell will try to minimize overall flux while still maximizing the original objective function, e.g. the growth rate. :param model: The model to perform pFBA on. :type model: cobra.Model :param fraction_of_optimum: The fraction of optimum which must be maintained. The original objective reaction is constrained to be greater than maximal value times the `fraction_of_optimum` (default 1.0). :type fraction_of_optimum: float, optional :param objective: A desired objective to use during optimization in addition to the pFBA objective. Dictionaries (reaction as key, coefficient as value) can be used for linear objectives (default None). :type objective: dict or cobra.Model.objective, optional :param reactions: List of cobra.Reaction. Implies `return_frame` to be true. Only return fluxes for the given reactions. Faster than fetching all fluxes if only a few are needed (default None). :type reactions: list of cobra.Reaction, optional :returns: The solution object to the optimized model with pFBA constraints added. :rtype: cobra.Solution .. rubric:: References .. [1] Lewis, N. E., Hixson, K. K., Conrad, T. M., Lerman, J. A., Charusanti, P., Polpitiya, A. D., Palsson, B. O. (2010). Omic data from evolved E. coli are consistent with computed optimal growth from genome-scale models. Molecular Systems Biology, 6, 390. doi:10.1038/msb.2010.47 .. py:function:: find_blocked_reactions(model: cobra.Model, reaction_list: Optional[List[Union[cobra.Reaction, str]]] = None, zero_cutoff: Optional[float] = None, open_exchanges: bool = False, processes: Optional[int] = None) -> List[cobra.Reaction] Find reactions that cannot carry any flux. The question whether or not a reaction is blocked is highly dependent on the current exchange reaction settings for a COBRA model. Hence an argument is provided to open all exchange reactions. :param model: The model to analyze. :type model: cobra.Model :param reaction_list: List of reactions to consider, the default includes all model reactions (default None). :type reaction_list: list of cobra.Reaction or str, optional :param zero_cutoff: Flux value which is considered to effectively be zero. The default is set to use `model.tolerance` (default None). :type zero_cutoff: float, optional :param open_exchanges: Whether or not to open all exchange reactions to very high flux ranges (default False). :type open_exchanges: bool, optional :param processes: The number of parallel processes to run. Can speed up the computations if the number of reactions is large. If not explicitly passed, it will be set from the global configuration singleton (default None). :type processes: int, optional :returns: List with the identifiers of blocked reactions. :rtype: list of cobra.Reaction .. rubric:: Notes Sink and demand reactions are left untouched. Please modify them manually. .. py:function:: find_essential_genes(model: cobra.Model, threshold: Optional[float] = None, processes: Optional[int] = None) -> Set[cobra.Gene] Return a set of essential genes. A gene is considered essential if restricting the flux of all reactions that depend on it to zero causes the objective, e.g., the growth rate, to also be zero, below the threshold, or infeasible. :param model: The model to find the essential genes for. :type model: cobra.Model :param threshold: Minimal objective flux to be considered viable. By default this is 1% of the maximal objective (default None). :type threshold: float, optional :param processes: The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not explicitly passed, it will be set from the global configuration singleton (default None). :type processes: int, optional :returns: Set of essential genes. :rtype: set of cobra.Gene .. py:function:: find_essential_reactions(model: cobra.Model, threshold: Optional[float] = None, processes: Optional[int] = None) -> Set[cobra.Reaction] Return a set of essential reactions. A reaction is considered essential if restricting its flux to zero causes the objective, e.g., the growth rate, to also be zero, below the threshold, or infeasible. :param model: The model to find the essential reactions for. :type model: cobra.Model :param threshold: Minimal objective flux to be considered viable. By default this is 1% of the maximal objective (default None). :type threshold: float, optional :param processes: The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not explicitly passed, it will be set from the global configuration singleton (default None). :type processes: int, optional :returns: Set of essential reactions. :rtype: set of cobra.Reaction .. py:function:: flux_variability_analysis(model: cobra.Model, reaction_list: Optional[List[Union[cobra.Reaction, str]]] = None, loopless: bool = False, fraction_of_optimum: float = 1.0, pfba_factor: Optional[float] = None, processes: Optional[int] = None) -> pandas.DataFrame Determine the minimum and maximum flux value for each reaction. :param model: The model for which to run the analysis. It will *not* be modified. :type model: cobra.Model :param reaction_list: The reactions for which to obtain min/max fluxes. If None will use all reactions in the model (default None). :type reaction_list: list of cobra.Reaction or str, optional :param loopless: Whether to return only loopless solutions. This is significantly slower. Please also refer to the notes (default False). :type loopless: bool, optional :param fraction_of_optimum: Must be <= 1.0. Requires that the objective value is at least the fraction times maximum objective value. A value of 0.85 for instance means that the objective has to be at least at 85% percent of its maximum (default 1.0). :type fraction_of_optimum: float, optional :param pfba_factor: Add an additional constraint to the model that requires the total sum of absolute fluxes must not be larger than this value times the smallest possible sum of absolute fluxes, i.e., by setting the value to 1.1 the total sum of absolute fluxes must not be more than 10% larger than the pFBA solution. Since the pFBA solution is the one that optimally minimizes the total flux sum, the `pfba_factor` should, if set, be larger than one. Setting this value may lead to more realistic predictions of the effective flux bounds (default None). :type pfba_factor: float, optional :param processes: The number of parallel processes to run. If not explicitly passed, will be set from the global configuration singleton (default None). :type processes: int, optional :returns: A data frame with reaction identifiers as the index and two columns: - maximum: indicating the highest possible flux - minimum: indicating the lowest possible flux :rtype: pandas.DataFrame .. rubric:: Notes This implements the fast version as described in [1]_. Please note that the flux distribution containing all minimal/maximal fluxes does not have to be a feasible solution for the model. Fluxes are minimized/maximized individually and a single minimal flux might require all others to be sub-optimal. Using the loopless option will lead to a significant increase in computation time (about a factor of 100 for large models). However, the algorithm used here (see [2]_) is still more than 1000x faster than the "naive" version using `add_loopless(model)`. Also note that if you have included constraints that force a loop (for instance by setting all fluxes in a loop to be non-zero) this loop will be included in the solution. .. rubric:: References .. [1] Computationally efficient flux variability analysis. Gudmundsson S, Thiele I. BMC Bioinformatics. 2010 Sep 29;11:489. doi: 10.1186/1471-2105-11-489, PMID: 20920235 .. [2] CycleFreeFlux: efficient removal of thermodynamically infeasible loops from flux distributions. Desouki AA, Jarre F, Gelius-Dietrich G, Lercher MJ. Bioinformatics. 2015 Jul 1;31(13):2159-65. doi: 10.1093/bioinformatics/btv096. .. py:function:: production_envelope(model: cobra.Model, reactions: List[cobra.Reaction], objective: Union[Dict, optlang.interface.Objective, None] = None, carbon_sources: Optional[List[cobra.Reaction]] = None, points: int = 20, threshold: Optional[float] = None) -> pandas.DataFrame Calculate the objective value conditioned on all flux combinations. The production envelope can be used to analyze a model's ability to produce a given compound conditional on the fluxes for another set of reactions, such as the uptake rates. The model is alternately optimized with respect to minimizing and maximizing the objective and the obtained fluxes are recorded. Ranges to compute production is set to the effective bounds, i.e., the minimum / maximum fluxes that can be obtained given current reaction bounds. :param model: The model to compute the production envelope for. :type model: cobra.Model :param reactions: A list of reaction objects. :type reactions: list of cobra.Reaction :param objective: The objective (reaction) to use for the production envelope. Use the model's current objective if left missing (default None). :type objective: dict or cobra.Model.objective, optional :param carbon_sources: One or more reactions that are the source of carbon for computing carbon (mol carbon in output over mol carbon in input) and mass yield (gram product over gram output). Only objectives with a carbon containing input and output metabolite is supported. Will identify active carbon sources in the medium if none are specified (default None). :type carbon_sources: list of cobra.Reaction, optional :param points: The number of points to calculate production for (default 20). :type points: int, optional :param threshold: A cut-off under which flux values will be considered to be zero. If not specified, it defaults to `model.tolerance` (default None). :type threshold: float, optional :returns: A DataFrame with fixed columns as: - carbon_source : identifiers of carbon exchange reactions - flux_maximum : maximum objective flux - flux_minimum : minimum objective flux - carbon_yield_maximum : maximum yield of a carbon source - carbon_yield_minimum : minimum yield of a carbon source - mass_yield_maximum : maximum mass yield of a carbon source - mass_yield_minimum : minimum mass yield of a carbon source and variable columns (for each input `reactions`) as: - reaction_id : flux at each given point :rtype: pandas.DataFrame :raises ValueError: If model's objective is comprised of multiple reactions. .. rubric:: Examples >>> import cobra.io >>> from cobra.flux_analysis import production_envelope >>> model = cobra.io.load_model("textbook") >>> production_envelope(model, ["EX_glc__D_e", "EX_o2_e"]) carbon_source flux_minimum carbon_yield_minimum mass_yield_minimum ... 0 EX_glc__D_e 0.0 0.0 NaN ... 1 EX_glc__D_e 0.0 0.0 NaN ... 2 EX_glc__D_e 0.0 0.0 NaN ... 3 EX_glc__D_e 0.0 0.0 NaN ... 4 EX_glc__D_e 0.0 0.0 NaN ... .. ... ... ... ... ... 395 EX_glc__D_e NaN NaN NaN ... 396 EX_glc__D_e NaN NaN NaN ... 397 EX_glc__D_e NaN NaN NaN ... 398 EX_glc__D_e NaN NaN NaN ... 399 EX_glc__D_e NaN NaN NaN ... [400 rows x 9 columns] .. py:function:: add_room(model: cobra.Model, solution: Optional[cobra.Solution] = None, linear: bool = False, delta: float = 0.03, epsilon: float = 0.001) -> None Add constraints and objective for ROOM. This function adds variables and constraints for applying regulatory on/off minimization (ROOM) to the model. :param model: The model to add ROOM constraints and objective to. :type model: cobra.Model :param solution: A previous solution to use as a reference. If no solution is given, one will be computed using pFBA (default None). :type solution: cobra.Solution, optional :param linear: Whether to use the linear ROOM formulation or not (default False). :type linear: bool, optional :param delta: The relative tolerance range which is additive in nature (default 0.03). :type delta: float, optional :param epsilon: The absolute range of tolerance which is multiplicative (default 0.001). :type epsilon: float, optional .. rubric:: Notes The formulation used here is the same as stated in the original paper [1]_. The mathematical expression is given below: minimize: \sum_{i=1}^m y^i s.t. : Sv = 0 v_min \le v \le v_max v_j = 0 j \in A for 1 \le i \le m v_i - y_i(v_{max,i} - w_i^u) \le w_i^u (1) v_i - y_i(v_{min,i} - w_i^l) \le w_i^l (2) y_i \in {0,1} (3) w_i^u = w_i + \delta|w_i| + \epsilon w_i^l = w_i - \delta|w_i| - \epsilon So, for the linear version of the ROOM , constraint (3) is relaxed to 0 \le y_i \le 1. .. seealso:: :obj:`pfba` parsimonious FBA .. rubric:: References .. [1] Tomer Shlomi, Omer Berkman and Eytan Ruppin, "Regulatory on/off minimization of metabolic flux changes after genetic perturbations", PNAS 2005 102 (21) 7695-7700; doi:10.1073/pnas.0406346102 .. py:function:: room(model: cobra.Model, solution: Optional[cobra.Solution] = None, linear: bool = False, delta: float = 0.03, epsilon: float = 0.001) -> cobra.Solution Compute a solution based on regulatory on/off minimization (ROOM). Compute a new flux distribution that minimizes the number of active reactions needed to accommodate a previous reference solution. Regulatory on/off minimization (ROOM) is generally used to assess the impact of knock-outs. Thus, the typical usage is to provide a wild-type flux distribution as reference and a `model` in knock-out state. :param model: The model state to compute a ROOM-based solution for. :type model: cobra.Model :param solution: A (wild-type) reference solution (default None). :type solution: cobra.Solution, optional :param linear: Whether to use the linear ROOM formulation or not (default False). :type linear: bool, optional :param delta: The relative tolerance range (additive) (default 0.03). :type delta: float, optional :param epsilon: The absolute tolerance range (multiplicative) (default 0.001). :type epsilon: float, optional :returns: A flux distribution with minimal active reaction changes compared to the reference. :rtype: cobra.Solution .. seealso:: :obj:`add_room` add ROOM constraints and objective