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"and" chain").SBO:0000247 (simple chemical) otherwise.
Reaction SBO assignment
SBO:0000176 (metabolic reaction) by default.
Single-metabolite reactions (exchange, sink or demand):
extracellular: SBO:0000627 (exchange)
coefficient < 0: SBO:0000632 (sink)
otherwise: SBO:0000628 (demand)
Transport reactions: SBO:0000655 (default detector: the same metabolite name appears in at least 2 compartments).
The reaction whose
namematchesbiomass_rxn_name: SBO:0000629.The reaction whose
namematchesngam_rxn_name: SBO:0000630.Other reactions whose
namecontains any ofpseudoreaction_name_substrings: SBO:0000395.
The SBO term is written to annotation['sbo'] only when that key is missing or
empty, as in RAVEN's editMiriam(..., 'fill') mode.
Parameters
model: cobra.ModelModel to annotate. It is modified in place and returned.
biomass_met_names: Iterable[str]Metabolite names that receive SBO:0000649. Default
DEFAULT_BIOMASS_MET_NAMES(biomass,DNA,RNA,protein,carbohydrate,lipid,cofactorandion). Names are matched exactly.biomass_met_suffixes: Iterable[str]Name suffixes that mark a metabolite as biomass. Default
(" backbone", " chain").biomass_rxn_name: strName of the biomass pseudoreaction, which receives SBO:0000629. The match is exact. Default
"biomass pseudoreaction".ngam_rxn_name: strName of the non-growth associated maintenance reaction, which receives SBO:0000630. The match is exact. Default
"non-growth associated maintenance reaction".pseudoreaction_name_substrings: Iterable[str]Reactions that are not the biomass or NGAM reaction and whose name contains any of these substrings receive SBO:0000395. Default
("pseudoreaction", "SLIME rxn").transport_detectorOptional callable that takes the model and returns the set of reaction ids classified as transport. When
None, the default heuristic is used: a reaction is transport when one metabolite name occurs in at least 2 compartments. A custom detector replaces this convention (for example RAVEN'sgetTransportRxnsvia the MATLAB engine).only_last_reaction_for_pseudoIf True, the biomass, NGAM and pseudoreaction terms are assigned to the last reaction only, as in yeast-GEM's
addSBOterms.m, whose loop headerfor i = numel(...)lacks1:. Default False.
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 as the string of the value read from 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; a caller that treats
a particular value as absent filters it 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 (
Var1andVar2from MATLAB'sarray2table).note_keyKey under which the value is stored on
entity.notes. Default"deltaG".verbosePrint a summary of unmatched entity ids.
Returns
intThe number of entities that were recorded (that is, 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, or with a string value that cannot be converted to a
float, get NaN written, which keeps one row per entity in entity order (mirrors MATLAB's
array2table([ids, values]) behaviour). A value of another type that float rejects
(for example a list) raises TypeError.
Parameters
entities: IterableCobra entities (
model.metabolitesormodel.reactions). One CSV row is written per entity, in iteration order.path: str or PathPath of the CSV file to write. An existing file is overwritten. The file has a header row and no index column.
id_column: strHeader of the identifier column. Default
"Var1".value_column: strHeader of the value column. Default
"Var2".note_key: strKey read from
entity.notes. Default"deltaG".
Returns
intThe number of rows written (the number of entities).