:mod:`memote.support.consistency_helpers` ========================================= .. py:module:: memote.support.consistency_helpers .. autoapi-nested-parse:: Helper functions for stoichiometric consistency checks. .. !! processed by numpydoc !! Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: memote.support.consistency_helpers.stoichiometry_matrix memote.support.consistency_helpers.nullspace .. function:: stoichiometry_matrix(metabolites, reactions) Return the stoichiometry matrix representation of a set of reactions. The reactions and metabolites order is respected. All metabolites are expected to be contained and complete in terms of the reactions. :Parameters: **reactions** : iterable A somehow ordered list of unique reactions. **metabolites** : iterable A somehow ordered list of unique metabolites. :Returns: numpy.array The 2D array that represents the stoichiometry matrix. dict A dictionary mapping metabolites to row indexes. dict A dictionary mapping reactions to column indexes. .. !! processed by numpydoc !! .. function:: nullspace(matrix, atol=1e-13, rtol=0.0) Compute an approximate basis for the null space (kernel) of a matrix. The algorithm used by this function is based on the singular value decomposition of the given matrix. :Parameters: **matrix** : ndarray The matrix should be at most 2-D. A 1-D array with length k will be treated as a 2-D with shape (1, k) **atol** : float The absolute tolerance for a zero singular value. Singular values smaller than ``atol`` are considered to be zero. **rtol** : float The relative tolerance for a zero singular value. Singular values less than the relative tolerance times the largest singular value are considered to be zero. :Returns: ndarray If ``matrix`` is an array with shape (m, k), then the returned nullspace will be an array with shape ``(k, n)``, where n is the estimated dimension of the nullspace. .. rubric:: Notes If both `atol` and `rtol` are positive, the combined tolerance is the maximum of the two; that is:: tol = max(atol, rtol * smax) Singular values smaller than ``tol`` are considered to be zero. .. rubric:: References Adapted from: https://scipy.github.io/old-wiki/pages/Cookbook/RankNullspace.html .. only:: latex .. !! processed by numpydoc !!