Skip to content

Metabolic tasks (Python)

raven-toolbox objects in raven_toolbox.tasks, collected from the source of the tracked branch.

Functions

Function Summary
apply_task_constraints Apply a task's inputs/outputs/equations/bound-changes to model in place.
check_tasks Run a task list against model and return a :class:TaskResult per task.
EssentialReactionsResult Reactions a model must use to perform a task list (RAVEN essentialRxns).
find_task_essential_reactions Find the reactions a model must use to satisfy a task list.
parse_task_list Parse a task-list file into :class:Task objects.
Task One metabolic task. Bounds are (metabolite_or_reaction, lb, ub) triples.
task_name_maps Build name[comp]→[ids] and comp→[ids] lookups for a model's metabolites.
TaskResult Result of one task: passed is the verdict (accounts for should_fail).

Reference

apply_task_constraints

Apply a task's inputs/outputs/equations/bound-changes to model in place.

Sets a feasibility (zero) objective. Returns (task_metabolite_ids, error); task_metabolite_ids are the model metabolites the task references (RAVEN's essentialMetsForTasks). On error the model may be partially modified.

check_tasks

Run a task list against model and return a :class:TaskResult per task.

tasks is a parsed list of :class:Task or a path to a task-list file. With close_boundaries (default), existing exchange/sink/demand reactions are closed so inputs/outputs are defined purely by the tasks (as RAVEN assumes).

EssentialReactionsResult

Reactions a model must use to perform a task list (RAVEN essentialRxns).

reactions maps reaction id → forced flux direction (+1 forward, -1 reverse): the reaction must carry flux of that sign in every feasible solution of at least one task. per_task is the same, split by task id. task_metabolites are the model metabolites the tasks reference (RAVEN essentialMetsForTasks, protected from removal). failed_tasks are tasks that were infeasible or malformed and thus skipped (RAVEN drops these from the task list).

find_task_essential_reactions

Find the reactions a model must use to satisfy a task list.

For each task the model is constrained as in :func:check_tasks, then FVA identifies reactions whose flux can never be zero (essential) and their forced direction. This is the prepINITModel step that feeds (ft)INIT: essential reactions are kept regardless of expression score and made irreversible in their forced direction. When a reaction is essential in several tasks with conflicting directions, the majority wins (ties → forward), matching RAVEN's pos < neg.

On a genome-scale model this is slow (an FVA per task). Pass cache_path to make it resumable: each task's result is written there as it completes (atomically), and a re-run skips tasks already cached — so it survives interruptions and finishes across several sessions.

parse_task_list

Parse a task-list file into :class:Task objects.

Task

One metabolic task. Bounds are (metabolite_or_reaction, lb, ub) triples.

task_name_maps

Build name[comp]→[ids] and comp→[ids] lookups for a model's metabolites.

name[comp] maps to a list because a model can carry several metabolites with the same name and compartment; a task referencing it constrains all of them (as RAVEN does), rather than an arbitrary one.

TaskResult

Result of one task: passed is the verdict (accounts for should_fail).