:mod:`geckopy.experimental.relaxation` ====================================== .. py:module:: geckopy.experimental.relaxation .. autoapi-nested-parse:: Relax experimental constraints. Usually, the experimental constraints produce an infeashible model. The relaxation methods aim to remove the smallest subset of experimental measurements to allow growth. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: geckopy.experimental.relaxation.Objective_rule Functions ~~~~~~~~~ .. autoapisummary:: geckopy.experimental.relaxation.apply_proteomics_relaxation geckopy.experimental.relaxation.apply_proteomics_elastic_relaxation geckopy.experimental.relaxation.get_upper_relaxation geckopy.experimental.relaxation.elastic_upper_relaxation geckopy.experimental.relaxation.relax_proteomics_greedy .. class:: Objective_rule Bases: :class:`enum.Enum` Objective to minimize for relaxation. - Objective_rule.MIN_ELASTIC_SUM: :math:`\sum_{v \in \text{elastic vars}} v_{flux}` (LP). - Objective_rule.MIN_ELASTIC_SUM_OBJECTIVE: :math:`\sum_{e \in \text{elastic vars}} + \text{prev objective}` (LP). - Objective_rule.MIN_MILP_COUNT: :math:`\sum_i^{N} e_i` where e is a binary variable (MILP). .. attribute:: MIN_ELASTIC_SUM :annotation: = 1 .. attribute:: MIN_MILP_COUNT :annotation: = 2 .. attribute:: MIN_ELASTIC_SUM_OBJECTIVE :annotation: = 3 .. function:: apply_proteomics_relaxation(original_model: geckopy.model.Model, objective_rule: geckopy.experimental.relaxation.Objective_rule = Objective_rule.MIN_ELASTIC_SUM_OBJECTIVE) -> Tuple[(Model, Set)] Relax the problem by relaxing the protein concentration constraints. The relaxed problems will contain elastic variables, returning the model a non-unique infeashible contraint set. :param original_model: Geckopy model. It won't be modified but copied. :type original_model: geckopy.Model :param objective_rule: The IIS is selected by minimizing an objective as defined in :class:`Objective_rule`. :type objective_rule: Objective_rule :returns: **tuple** -- copy of the model with the relaxed variables applied and the sets :rtype: (geckopy.Model, set) .. function:: apply_proteomics_elastic_relaxation(original_model: geckopy.model.Model, objective_rule: geckopy.experimental.relaxation.Objective_rule = Objective_rule.MIN_ELASTIC_SUM_OBJECTIVE) -> Tuple[(Model, Set)] Relax the problem by relaxing the protein concentration constraints. The relaxed problems will be determined via Elastic filtering, returning the model and a irreducibly inconsistent set of functional constraints ( [Chinnek and Dravnieks, 1990] (https://pubsonline.informs.org/doi/abs/10.1287/ijoc.3.2.157)). :param original_model: Geckopy model. It won't be modified but copied. :type original_model: geckopy.Model :param objective_rule: The IIS is selected by minimizing an objective as defined in :class:`Objective_rule`. :type objective_rule: Objective_rule :returns: **tuple** -- copy of the model with the relaxed variables applied and the sets :rtype: (geckopy.Model, set) .. function:: get_upper_relaxation(model: cobra.Model, candidates: List[str], objective_rule: geckopy.experimental.relaxation.Objective_rule = Objective_rule.MIN_ELASTIC_SUM_OBJECTIVE) -> Tuple[(Set, str)] Get one IIS of upper bounds of the `candidates`. .. function:: elastic_upper_relaxation(original_model: cobra.Model, elastic_candidates: List[str], objective_rule: geckopy.experimental.relaxation.Objective_rule = Objective_rule.MIN_ELASTIC_SUM_OBJECTIVE) -> Set Convert constrains to elastic constraints until the problem is feashible. It assumes that the elastic candidates are all subject to a <= constraint. Based on Brown and Graves, 1975: - Q <- original problem - E <- set of variables, candidates to be relaxed - V <- set of variables that relax the problem - relax(:math:`e_i`) <- Add constraint :math:`e - v` - Z <- :math:`\sum_{v \in V} v` IIS <- irreducibly infeashible set of variables 1. relax(:math:`e_i`) for each :math:`e_i` in :math:`E` 2. min :math:`Z`, s.t. :math:`E, Q, v \ge 0 \forall V` 3. Get :math:`R = v \in V \lt 0` 4. If infeashible: STOP 5. Else: 5.1. :math:`E = E - R` 5.2. :math:`IIS = IIS \cup R` Go to 1 6. return IIS :param original_model: :type original_model: cobra.Model :param elastic_candidates: :type elastic_candidates: list[str] :param objective_rule: The IIS is selected by minimizing an objective as defined in :class:`Objective_rule`. :type objective_rule: Objective_rule .. function:: relax_proteomics_greedy(model: geckopy.model.Model, minimal_growth: float, protein_set: Optional[List[str]] = None) -> Tuple[(Dict, List[Dict])] Remove proteomics measurements with a set that enables the model to grow. Proteins are removed from the set iteratively based on sensitivity analysis (shadow prices). Adapted from https://github.com/DD-DeCaF/simulations/blob/devel/src/simulations/modeling/driven.py :param model: The enzyme-constrained model. :type model: cobra.Model :param minimal_growth_rate: Minimal growth rate to enforce. :type minimal_growth_rate: float :param protein_set: If a list of ids is provided, the search will be applied to only these proteins. :type protein_set: Optional[List[str]] :returns: * **growth_rate** (*dict*) -- New growth rate (will change if the model couldn't grow at the inputted value). * **proteomics** (*list(dict)*) -- Filtered list of proteomics.