Conditions (Python)#
raven-toolbox objects in raven_toolbox.conditions.
Functions#
Function |
Summary |
|---|---|
Apply a parsed condition (or a YAML file path) to |
|
Parse a condition YAML file into a plain dict. |
|
Set both bounds, bypassing cobra's |
Reference#
apply_condition#
apply_condition(model: cobra.Model, condition: dict[str, Any] | str | Path)
Apply a parsed condition (or a YAML file path) to model in place.
Returns the same model object.
Parameters
model: cobra.ModelModel to modify in place.
condition: dict or str or PathA condition already parsed into a dict, or the path of a condition YAML file that is read with
load_condition. The schema is described in the module docstring.
load_condition#
load_condition(path: str | Path)
Parse a condition YAML file into a plain dict.
Parameters
path: str or PathPath of the YAML file, in the schema described in the module docstring.
Returns
dictThe parsed condition. A file without content gives an empty dict, which
apply_conditionapplies as a condition without steps (as RAVENparseYAMLandapplyConditiondo).
Raises
FileNotFoundErrorIf
pathdoes not exist.
set_reaction_bounds#
set_reaction_bounds(rxn: cobra.Reaction, lb: float, ub: float)
Set both bounds, bypassing cobra's lb <= ub validator.
Some conditions set an infeasible state with lb > ub (for example to force
flux via a sentinel bound), which cobra's setter rejects. When lb > ub, the
function writes the private bound attributes of the reaction directly; otherwise
it uses rxn.bounds.
Parameters
rxn: cobra.ReactionReaction to modify in place.
lb: floatNew lower bound.
ub: floatNew upper bound.