Comparison (Python)#
raven-toolbox objects in raven_toolbox.comparison.
Functions#
Function |
Summary |
|---|---|
Compare N cobra models on their reactions / metabolites / genes / ec_codes / |
|
Compare two cobra models for semantic equality. |
|
Result of |
|
Tabular result of |
Reference#
compare_models#
compare_models(models: Iterable[cobra.Model], *, tasks: str | Iterable[Task] | None=None)
Compare N cobra models on their reactions / metabolites / genes / ec_codes /
metabolite_names / equations / equations_no_compartments / subsystems (and tasks, if provided).
tasks is forwarded to 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#
diff_models(a: cobra.Model, b: cobra.Model, *, stoichiometry_tol: float=1e-09, ignore_annotations: Iterable[str]=(), extra_annotations: Iterable[str]=(), max_per_category: int=50)
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 anyextra_annotations, minus anyignore_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 diff_models.
Truthy if the models are semantically equal. Iterate differences
for human-readable messages.
ModelComparison#
Tabular result of compare_models.
All matrices are indexed by id/value (reactions/metabolites/genes/ec_codes/
metabolite_names/equations/equations_no_compartments/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). tasks is the per-model task pass/fail matrix
(None unless task checking was requested); failed_tasks maps each model id to
the failure messages for the tasks it did not pass.
equations/equations_no_compartments key each reaction by a canonical string
built from its metabolites and stoichiometry: sides are sorted, and for a reversible
reaction the side containing the lexicographically-first metabolite is written as the
reactant side, so two reactions that are the same up to metabolite order or arbitrary
reversible-direction compare equal. equations keeps compartments in each
metabolite id; equations_no_compartments strips them.