Annotation (Python)#
raven-toolbox objects in raven_toolbox.annotation.
Functions#
Function |
Summary |
|---|---|
Assign SBO terms to metabolites and reactions in-place. |
|
Record |
|
Dump |
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
nameis inbiomass_met_namesor ends with any ofbiomass_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
namematchesbiomass_rxn_name→ SBO:0000629.The reaction whose
namematchesngam_rxn_name→ SBO:0000630.Other reactions whose
namecontains anypseudoreaction_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_detectorOptional 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'sgetTransportRxnsvia the MATLAB engine).only_last_reaction_for_pseudoBug-compatibility flag, off by default. The legacy yeast-GEM MATLAB
addSBOterms.mcontains a typo (for i = numel(...)rather thanfor i = 1:numel(...)) that causes the pseudo- reaction SBO assignments to run only on the very last reaction in the model. WhenTrue, this flag replicates that bug so callers can migrate without altering the committed model. LeaveFalsefor 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
entitiesCobra entities (
model.metabolitesormodel.reactions).pathPath to the CSV.
id_column, value_columnColumn labels in the CSV. Defaults match the yeast-GEM convention (
Var1/Var2from MATLAB'sarray2table).note_keyKey under which the value is stored on
entity.notes. Default"deltaG".verbosePrint 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).
: