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. This function will modify your model.
The used formulation is described in [1]_. If method is set to
“fastSNP”, it uses a faster implementation based on the Fast-SNP
algorithm [2].
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.
Parameters:
model (cobra.Model) – The model to which to add the constraints.
zero_cutoff (positive float, optional) – 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).
method (str, "original" or "fastSNP", optional) – The method to use for finding the null space. The “original” method
uses the original method from [1]_, while “fastSNP” uses a faster
implementation based on the FastSNP algorithm. The “fastSNP” method
is much faster and should be used in most cases.
reactions (list of str, optional) – The list of reaction IDs to constrain. All cycles within these
reactions will be removed. If None, all reactions will be constrained.
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.
Parameters:
model (cobra.Model) – The model to which to add the constraints.
fluxes (dict of {str, float}, optional) – 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).
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).
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.
Plugin to get a loopless FVA solution from single FVA iteration.
Assumes the following about model and reaction:
1. The model objective is set to be reaction.
2. The model has been optimized and contains the minimum/maximum flux
for reaction.
The model contains an auxiliary variable called “fva_old_objective”
denoting the previous objective.
reaction (cobra.Reaction) – The reaction currently minimized/maximized.
solution (bool, optional) – Whether to return the entire solution or only the minimum/maximum
for reaction (default False).
zero_cutoff (positive float, optional) – Cutoff used for loop removal. Fluxes with an absolute value smaller
than zero_cutoff are considered to be zero. The default is to use
model.tolerance (default None).
Returns:
single float or dict of {str – Returns the minimized/maximized flux through reaction if
solution is False. Otherwise, returns a loopless flux
solution object containing the minimum/maximum flux for reaction.