cobra.flux_analysis.find_cyclic_reactions
=========================================

.. py:module:: cobra.flux_analysis.find_cyclic_reactions

.. autoapi-nested-parse::

   Provides a function to find cyclic reactions in a metabolic model.



Functions
---------

.. autoapisummary::

   cobra.flux_analysis.find_cyclic_reactions._create_find_cyclic_reactions_problem
   cobra.flux_analysis.find_cyclic_reactions.find_cyclic_reactions


Module Contents
---------------

.. py:function:: _create_find_cyclic_reactions_problem(solver: optlang.interface, s_int: numpy.ndarray, directions_int: numpy.ndarray, zero_cutoff: float, bound: float) -> Tuple[optlang.interface.Model, List[optlang.interface.Variable]]

   Create an optimization problem to find cyclic reactions.

   This optimization problem includes only internal reactions, assumes
   steady-state constraints, and enforces reaction directions.


.. py:function:: find_cyclic_reactions(model: cobra.Model, zero_cutoff: Optional[float] = None, bound: float = 10000.0, method: str = 'optimized', required_stop_checks_num: int = 3) -> Tuple[List[str], List[Tuple[bool, bool]]]

   Find reactions, that can be in a loop in a steady state flux distribution.

   :param model: The metabolic model to analyze.
   :type model: cobra.Model
   :param zero_cutoff: The cutoff value to consider a flux as zero.
                       The default uses the `model.tolerance` (default None).
   :type zero_cutoff: float, optional
   :param bound: The bound for the reaction fluxes in the optimization problem.
                 (default is 1e4).
   :type bound: float, optional
   :param method: The method to use for finding cyclic reactions.
                  Options are "optimized" (default) or "basic".
                  See notes for details.
   :type method: str, optional
   :param required_stop_checks_num: This parameter is used only for the "optimized" method.
                                    The number of random checks to pass to prove that all cyclic
                                    reactions were found. (default is 3).
   :type required_stop_checks_num: int, optional

   :returns:

             - A list of reaction IDs that can be part of a loop.
             - A list of tuples indicating the possible directions of
               reactions from the first list in the loop.
               Each tuple contains two boolean values: (can_be_negative, can_be_positive).
   :rtype: A tuple containing two lists

   .. rubric:: Notes

   This function considers only the stoichiometric matrix and reaction directions.
   Any other constraints present in the model are ignored.
   * If a reaction is identified as cyclic, there may still be no feasible loop
     when taking into account all bounds and additional constraints.
   * However, if a reaction is identified as non-cyclic, it cannot participate
     in any loop in a steady-state flux distribution.

   The "basic" method for each reaction and direction checks if it can be a part of
   a loop by optimizing linear programming problem.

   The "optimized" method uses a faster randomized approach to firstly find all
   reactions that can be part of a loop and then checks their directions. This method
   usually works at least 2 times faster than the "basic" method.
   The `required_stop_checks_num` parameter is used to descrease the probability
   of missing some cyclic reactions.


