Provides functions to remove thermodynamically infeasible loops. Module Contents

cobra.flux_analysis.loopless.add_loopless(model, zero_cutoff=1e-12)[source]

Modify a model so all feasible flux distributions are loopless.

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 you model. 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.

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

Return type:



[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, fluxes)[source]

Add constraints for CycleFreeFlux.

cobra.flux_analysis.loopless.loopless_solution(model, fluxes=None)[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.

  • model (cobra.Model) – The model to which to add the constraints.
  • fluxes (dict) – A dictionary {rxn_id: flux} that assigns a flux to each reaction. If not None will use the provided flux values to obtain a close loopless solution.

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:



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


[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, reaction, solution=False, zero_cutoff=1e-06)[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

  1. the model contains an auxiliary variable called “fva_old_objective” denoting the previous objective
  • model (cobra.Model) – The model to be used.
  • reaction (cobra.Reaction) – The reaction currently minimized/maximized.
  • solution (boolean, optional) – Whether to return the entire solution or only the minimum/maximum for reaction.
  • zero_cutoff (positive float, optional) – Cutoff used for loop removal. Fluxes with an absolute value smaller than zero_cutoff are considered to be zero.

Returns the minimized/maximized flux through reaction if all_fluxes == False (default). Otherwise returns a loopless flux solution containing the minimum/maximum flux for reaction.

Return type:

single float or dict


Construct a loopless model.

This adds MILP constraints to prevent flux from proceeding in a loop, as done in http://dx.doi.org/10.1016/j.bpj.2010.12.3707 Please see the documentation for an explanation of the algorithm.

This must be solved with an MILP capable solver.