Skip to content

Comparison (Python)

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

Functions

Function Summary
compare_models Compare N cobra models on their reactions / metabolites / genes / subsystems
diff_models Compare two cobra models for semantic equality.
DiffReport Result of :func:diff_models.
ModelComparison Tabular result of :func:compare_models.

Reference

compare_models

Compare N cobra models on their reactions / metabolites / genes / subsystems (and tasks, if provided).

tasks is forwarded to :func:raven_toolbox.tasks.check_tasks on each model; pass a file path or a parsed task list. When omitted, ModelComparison.tasks is None.

Models are identified by model.id (with a fallback to model_<i> if missing or duplicated).

diff_models

Compare two cobra models for semantic equality.

Checks:

  • reaction, metabolite and gene id sets (exact)
  • stoichiometry per shared reaction (within stoichiometry_tol)
  • lower/upper bounds and objective coefficients (exact)
  • GPR rules (whitespace- and case-insensitive string comparison)
  • metabolite formula, charge, compartment (exact)
  • a default set of annotation keys (see DEFAULT_ANNOTATION_KEYS) plus any extra_annotations, minus any ignore_annotations

max_per_category caps the per-category diff list so a wholesale mismatch produces a digestible report rather than 10,000 lines.

DiffReport

Result of :func:diff_models.

Truthy if the models are semantically equal. Iterate differences for human-readable messages.

ModelComparison

Tabular result of :func:compare_models.

All matrices are indexed by id (reactions/metabolites/genes/subsystems) with one column per model. presence matrices are 0/1; subsystems is the per-model reaction count per subsystem. similarity is the model × model Jaccard on the reaction set (1 = identical, 0 = disjoint).