Conditions (Python)#

raven-toolbox objects in raven_toolbox.conditions.

Functions#

Function

Summary

apply_condition

Apply a parsed condition (or a YAML file path) to model in place.

load_condition

Parse a condition YAML file into a plain dict.

set_reaction_bounds

Set both bounds, bypassing cobra's lb <= ub validator.

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 for chaining.

load_condition#

load_condition(path: str | Path)

Parse a condition YAML file into a plain dict.

set_reaction_bounds#

set_reaction_bounds(rxn: cobra.Reaction, lb: float, ub: float)

Set both bounds, bypassing cobra's lb <= ub validator.

Some conditions intentionally land on an infeasible lb > ub state (e.g. forcing flux via a sentinel bound). cobra's setter rejects that. This helper writes the underlying private attributes when needed so the model can match the caller's exact intent.