# 17.1.1.2.1.6. cobra.flux_analysis.loopless¶

Provide functions to remove thermodynamically infeasible loops.

## 17.1.1.2.1.6.1. Module Contents¶

### 17.1.1.2.1.6.1.1. Functions¶

 add_loopless(model: Model, zero_cutoff: Optional[float] = None) → None Modify a model so all feasible flux distributions are loopless. _add_cycle_free(model: Model, fluxes: Dict[str, float]) → None Add constraints for CycleFreeFlux. loopless_solution(model: Model, fluxes: Optional[Dict[str, float]] = None) → ‘Solution’ Convert an existing solution to a loopless one. loopless_fva_iter(model: Model, reaction: Reaction, solution: bool = False, zero_cutoff: Optional[float] = None) → Union[float, Dict[str, float]] Plugin to get a loopless FVA solution from single FVA iteration.
cobra.flux_analysis.loopless.add_loopless(model: Model, zero_cutoff: Optional[float] = None) → None[source]

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.

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).

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.

cobra.flux_analysis.loopless._add_cycle_free(model: Model, fluxes: Dict[str, float]) → None[source]

Parameters
• model (cobra.Model) – The model to operate on.

• fluxes (dict of {str: float}) – A dictionary having keys as reaction IDs and values as their flux values.

cobra.flux_analysis.loopless.loopless_solution(model: Model, fluxes: Optional[Dict[str, float]] = None) → 'Solution'[source]

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.

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).

Return type

cobra.Solution

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.

• It has an objective value close to the original one and the same objective value id the objective expression can not form 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.

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.

cobra.flux_analysis.loopless.loopless_fva_iter(model: Model, reaction: Reaction, solution: bool = False, zero_cutoff: Optional[float] = None) → Union[float, Dict[str, float]][source]

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.

1. The model contains an auxiliary variable called “fva_old_objective” denoting the previous objective.

Parameters
• model (cobra.Model) – The model to be used.

• 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.

Return type

float}