Annotation (Python)#

raven-toolbox objects in raven_toolbox.annotation.

Functions#

Function

Summary

add_sbo_terms

Assign SBO terms to metabolites and reactions in-place.

load_delta_g_csv

Record note_key on each entity from a CSV of id → value.

save_delta_g_csv

Dump entity.notes[note_key] for each entity to a CSV.

Reference#

add_sbo_terms#

add_sbo_terms(model: cobra.Model, *, biomass_met_names: Iterable[str]=DEFAULT_BIOMASS_MET_NAMES, biomass_met_suffixes: Iterable[str]=(' backbone', ' chain'), biomass_rxn_name: str=DEFAULT_BIOMASS_RXN_NAME, ngam_rxn_name: str=DEFAULT_NGAM_RXN_NAME, pseudoreaction_name_substrings: Iterable[str]=('pseudoreaction', 'SLIME rxn'), transport_detector: Callable[[cobra.Model], set[str]] | None=None, only_last_reaction_for_pseudo: bool=False)

Assign SBO terms to metabolites and reactions in-place.

Metabolite SBO assignment

  • SBO:0000649 (Biomass) for metabolites whose name is in biomass_met_names or ends with any of biomass_met_suffixes (default: " backbone" / " chain").

  • SBO:0000247 (Simple chemical) otherwise.

Reaction SBO assignment

  • SBO:0000176 (Metabolic reaction) default.

  • Single-reactant reactions (exchange / sink / demand):

    • extracellular → SBO:0000627 (exchange)

    • coefficient < 0 → SBO:0000632 (sink)

    • else → SBO:0000628 (demand)

  • Transport reactions → SBO:0000655 (default detector: same metabolite name appearing in ≥ 2 compartments).

  • The reaction whose name matches biomass_rxn_name → SBO:0000629.

  • The reaction whose name matches ngam_rxn_name → SBO:0000630.

  • Other reactions whose name contains any pseudoreaction_name_substrings → SBO:0000395.

"fill" semantic: SBO is written to annotation['sbo'] only when that key is missing or empty — mirrors RAVEN's editMiriam(..., 'fill') mode.

Parameters

transport_detector

Optional callable that takes the model and returns the set of reaction ids classified as transport. When None, the default same-met-name-in-two-compartments heuristic is used. Pass a custom detector to use a different convention (e.g. RAVEN's getTransportRxns via the MATLAB engine).

only_last_reaction_for_pseudo

Bug-compatibility flag, off by default. The legacy yeast-GEM MATLAB addSBOterms.m contains a typo (for i = numel(...) rather than for i = 1:numel(...)) that causes the pseudo- reaction SBO assignments to run only on the very last reaction in the model. When True, this flag replicates that bug so callers can migrate without altering the committed model. Leave False for new uses.

load_delta_g_csv#

load_delta_g_csv(entities: Iterable, path: str | Path, *, id_column: str='Var1', value_column: str='Var2', note_key: str='deltaG', verbose: bool=False)

Record note_key on each entity from a CSV of id → value.

Every matched value is recorded exactly as it appears in the CSV, including yeast-GEM's own "no measurement" placeholder (10000000.0, on 777 of its 4102 reaction rows) -- this function does not interpret CSV values, matching RAVEN's own loadDeltaGCSV. Callers that need to treat a particular value as absent should filter it themselves after loading.

Parameters

entities

Cobra entities (model.metabolites or model.reactions).

path

Path to the CSV.

id_column, value_column

Column labels in the CSV. Defaults match the yeast-GEM convention (Var1 / Var2 from MATLAB's array2table).

note_key

Key under which the value is stored on entity.notes. Default "deltaG".

verbose

Print a summary of unmatched entity ids.

Returns

The number of entities that were recorded (i.e. matched the CSV and :

carried a value). :

save_delta_g_csv#

save_delta_g_csv(entities: Iterable, path: str | Path, *, id_column: str='Var1', value_column: str='Var2', note_key: str='deltaG')

Dump entity.notes[note_key] for each entity to a CSV.

Entities without note_key set get NaN written, preserving one-row-per-entity ordering (mirrors MATLAB's array2table([ids, values]) behaviour).

Returns

The number of rows written (= number of entities). :