Reactions that can only carry negative flux are examined in their reverse
orientation, which is equivalent to negating their column in the
stoichiometric matrix. Every other reaction is examined as is.
Return whether a reaction can carry flux in its reverse orientation.
Reversibility is evaluated after orienting the reaction as described in
_reaction_sign(), so a reaction restricted to negative flux counts
as irreversible.
An auxiliary variable is tied to each given reaction’s oriented flux by a
one-sided constraint, and a randomly weighted sum of those auxiliary
variables is pushed as far as the flux bounds allow. The randomized
weights break ties between reactions, so that repeated calls explore
different corners of the optimal face.
The auxiliary variables are free on the side they are pushed away from,
rather than held by a large finite bound. A finite bound would quietly
become binding on a model whose flux bounds exceed it.
Return a new model holding only the given reactions.
The model is built from the reactions that are kept rather than copied
whole and then cut down. Deleting is quadratic: each removal makes
optlang.Container._reindex rebuild the whole name-to-index map, and
the solver is updated once per reaction. Building instead is linear in
what is kept, and populates the solver in a single batch.
Parameters:
model (cobra.Model) – The model to take the subset of. It is left unchanged.
keep_ids (set of str) – The identifiers of the reactions to keep.
Returns:
A new model carrying the kept reactions and everything attached to
them, in the order the source had them.
Check consistency of a metabolic network using SPECTRA [1]_.
SPECTRA’s consistency check is a pure LP method for removing the blocked
reactions of a metabolic network. Like FASTCC it drives as many reactions
as possible towards a flux threshold at once, but it handles reversible
reactions without flipping them: the auxiliary variable of the forward LP
is unbounded from below, so a reaction that can only carry negative flux
simply does not contribute to that LP, and is picked up by the reverse LP
instead. The two LPs alternate until the set of unexplained reactions
stops shrinking. For more details, please check [1]_.
The pair of LPs used for SPECTRA is like so:
maximize: sum_{i in J} w_i z_i
s.t. : z_i in [-infty, varepsilon] forall i in J
v_i ge z_i forall i in J
Sv = 0, v in B
minimize: sum_{i in J^{rev}} w_i z_i
s.t. : z_i in [-varepsilon, infty] forall i in J^{rev}
v_i le z_i forall i in J^{rev}
Sv = 0, v in B
where \(J\) are the reactions not yet shown to carry flux,
\(J^{rev}\) the reversible ones among them, and \(w_i\) are
coefficients drawn uniformly from [1, 1.1].
A reaction is taken to be consistent as soon as it carries a flux above
zero_cutoff in any of these LPs, which is the same criterion
fastcc() applies, so both functions
agree on which reactions are blocked. The reference MATLAB implementation
instead requires a reaction to reach the flux threshold itself; pass
zero_cutoff=0.99*tol to reproduce that, at the cost of also
discarding reactions that can carry some flux but never as much as tol.