cobamp.algorithms package¶
Submodules¶
cobamp.algorithms.kshortest module¶
This module includes classes that implement the K-shortest EFM enumeration algorithms. Please refer to the original authors’ paper describing the method [1]. Additional improvements concerning enumeration of EFMs by size have been adapted from the methods described by Von Kamp et al. [2]
References:
[1] De Figueiredo, Luis F., et al. “Computing the shortest elementary flux modes in genome-scale metabolic networks” Bioinformatics 25.23 (2009): 3158-3165. [2] von Kamp, Axel, and Steffen Klamt. “Enumeration of smallest intervention strategies in genome-scale metabolic networks” PLoS computational biology 10.1 (2014): e1003378.
-
class
cobamp.algorithms.kshortest.
AbstractConstraint
[source]¶ Bases:
object
Object representing a constraint to be used within the intervention problem structures provided in this package.
-
from_tuple
()[source]¶ Generates a constraint from a tuple. Refer to subclasses for each specific format.
-
materialize
(n)[source]¶ Generates a matrix T 1-by-n or 2-by-n and a list b of length 1 or 2 to be used for target flux vector definition within the intervention problem framework
Parameters:
n: Number of columns to include in the target matrixReturns: Tuple with Iterable[ndarray] and list of float/int
-
-
class
cobamp.algorithms.kshortest.
DefaultFluxbound
(lb, ub, r_index)[source]¶ Bases:
cobamp.algorithms.kshortest.AbstractConstraint
Class representing bounds for a single flux with a lower and an upper bound.
-
materialize
(n)[source]¶ Generates a matrix T 1-by-n or 2-by-n and a list b of length 1 or 2 to be used for target flux vector definition within the intervention problem framework
Parameters:
n: Number of columns to include in the target matrixReturns: Tuple with Iterable[ndarray] and list of float/int
-
-
class
cobamp.algorithms.kshortest.
DefaultYieldbound
(lb, ub, numerator_index, denominator_index, deviation=0)[source]¶ Bases:
cobamp.algorithms.kshortest.AbstractConstraint
Class representing a constraint on a yield between two fluxes. Formally, this constraint can be represented as n - yd < b, assuming n and d as the numerator and denominator fluxes (yield(N,D) = N/D), y as the maximum yield and b as a deviation value.
-
from_tuple
()[source]¶ Returns a DefaultYieldbound instance from a tuple containing numerator and denominator indices, yield lower and upper bounds, a flag indicating whether it’s an upper bound and a deviation (optional) ——-
-
materialize
(n)[source]¶ Generates a matrix T 1-by-n or 2-by-n and a list b of length 1 or 2 to be used for target flux vector definition within the intervention problem framework
Parameters:
n: Number of columns to include in the target matrixReturns: Tuple with Iterable[ndarray] and list of float/int
-
-
class
cobamp.algorithms.kshortest.
InterventionProblem
(S)[source]¶ Bases:
object
Class containing functions useful when defining an problem using the intervention problem framework. References:
[1] Hädicke, O., & Klamt, S. (2011). Computing complex metabolic intervention strategies using constrained minimal cut sets. Metabolic engineering, 13(2), 204-213.-
generate_target_matrix
(constraints)[source]¶ - constraints: An iterable containing valid constraints of
- Returns a tuple (T,b) with two elements:
T is numpy 2D array with as many rows specifying individual bounds (lower and upper bounds count as two) for each reaction.
b is a numpy 1D array with the right hand side of the T.v > b inequality. This represents the value of the bound.
-
-
class
cobamp.algorithms.kshortest.
KShortestEFMAlgorithm
(configuration, verbose=True)[source]¶ Bases:
object
A higher level class to use the K-Shortest algorithms. This encompasses the standard routine for enumeration of EFMs. Requires a configuration defining an algorithms type. See <KShortestProperties>
-
enumerate
(linear_system, excluded_sets=None, forced_sets=None)[source]¶ Enumerates the elementary modes for a linear system
Parameters
linear_system: A KShortestCompatibleLinearSystem instance
excluded_sets: Iterable[Tuple[Solution/Tuple]] with solutions to exclude from the enumeration
forced_sets: Iterable[Tuple[Solution/Tuple]] with solutions to force
Returns a list with solutions encoding elementary flux modes.
-
get_enumerator
(linear_system, excluded_sets, forced_sets)[source]¶ Parameters
linear_system: A KShortestCompatibleLinearSystem instance
excluded_sets: Iterable[Tuple[Solution/Tuple]] with solutions to exclude from the enumeration
forced_sets: Iterable[Tuple[Solution/Tuple]] with solutions to force
Returns an iterator that yields one or multiple EFMs at each iteration, depending on the properties.
-
-
class
cobamp.algorithms.kshortest.
KShortestEnumerator
(linear_system, m_value=None, force_non_cancellation=True, is_efp_problem=False, n_threads=0, workmem=None)[source]¶ Bases:
object
Class implementing the k-shortest elementary flux mode algorithms. This is a lower level class implemented using the optlang solver framework.
-
ENUMERATION_METHOD_ITERATE
= 'iterate'¶
-
ENUMERATION_METHOD_POPULATE
= 'populate'¶
-
exclude_solutions
(sols)[source]¶ Excludes the supplied solutions from the search by adding them as integer cuts. Use at your own discretion as this will yield different EFMs than would be intended. This can also be used to exclude certain reactions from the search by supplying solutions with one reaction.
Parameters
sols: An Iterable containing list/tuples with active reaction combinations to exclude or Solution instances.
-
force_solutions
(sols)[source]¶ Forces a set of reactions encoded as solutions to appear in the subsequent elementary modes to be calculated.
Parameters
sols: An Iterable containing list/tuples with active reaction combinations to exclude or Solution instances.
-
populate_current_size
()[source]¶ Returns the solutions for the current size. Use the population_iterator method instead.
-
population_iterator
(max_size)[source]¶ Generates a solution iterator that yields a list of solutions. Each next call returns all EFMs for a single size starting from 1 up to max_size.
Parameters
max_size: The maximum solution size.
Returns a list of KShortestSolution instances.
-
-
class
cobamp.algorithms.kshortest.
KShortestProperties
[source]¶ Bases:
cobamp.utilities.property_management.PropertyDictionary
Class defining a configuration for the K-shortest algorithms. The following fields are mandatory: K_SHORTEST_MPROPERTY_METHOD:
- K_SHORTEST_METHOD_ITERATE : Iterative enumeration (one EFM at a time)
- K_SHORTEST_METHOD_POPULATE : Enumeration by size (EFMs of a certain size at a time)
-
cobamp.algorithms.kshortest.
decompose_list
(a)¶
-
cobamp.algorithms.kshortest.
value_map_apply
(single_fx, pair_fx, value_map, **kwargs)[source]¶ Applies functions to the elements of an ordered dictionary, using one of two functions that process, respectively, a single item or a tuple of items.
Functions must receive the dictionary key, the dictionary itself and optional arguments
Parameters: - single_fx – A function that receives a single object as argument
- pair_fx – A function that receives a tuple as argument
- value_map – An ordered dictionary mapping keys with values
- kwargs – Optional function arguments
Returns: An iterable containing the results of the applied functions
Module contents¶
Module containing elementary flux mode enumeration methods