Skip to content

Biomass (Python)

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

Functions

Function Summary
BiomassComponent One component of the biomass equation (protein, carbohydrate, …).
BiomassConfig Container for the per-organism biomass layout.
rescale_pseudoreaction Multiply the substrate coefficients of one component pseudoreaction
scale_biomass Rescale a component to a new mass fraction, optionally balancing
set_gam Set GAM (and optionally NGAM) on a model in place.
sum_biomass Mass-fraction (g/gDW) per biomass component plus the total.

Reference

BiomassComponent

One component of the biomass equation (protein, carbohydrate, …).

Attributes:

Name Type Description
name str

Canonical short name — also the model.metabolites name of the metabolite that the pseudoreaction produces. Used by :func:rescale_pseudoreaction to identify the product side.

pseudoreaction_name str

model.reactions[*].name of the pseudoreaction. cobrapy reactions are looked up by name (not id) because that is how the yeast-GEM convention names them.

mass_strategy MassStrategy

How to convert the pseudoreaction's substrates into a mass fraction. See :data:MassStrategy for the choices and their offsets.

BiomassConfig

Container for the per-organism biomass layout.

Attributes:

Name Type Description
biomass_rxn str

model.reactions[*].id of the top-level biomass pseudoreaction (the one whose flux is the growth rate).

proton_met str

model.metabolites[*].id of the cytosolic H+ metabolite — used by :func:rescale_pseudoreaction to keep each pseudoreaction charge-balanced after rescaling.

components tuple[BiomassComponent, ...]

Ordered tuple of :class:BiomassComponent describing every non-top-level pseudoreaction that contributes to mass.

get

get(component_name: str) -> BiomassComponent

Look up a component by name (raises KeyError if missing).

rescale_pseudoreaction

Multiply the substrate coefficients of one component pseudoreaction by factor and rebalance H+ to preserve charge neutrality.

Ports rescalePseudoReaction.m. "Substrate" here means any metabolite whose name is not the component's product name; the component's own metabolite (e.g. protein for the protein pseudoreaction) is left untouched. After the rescaling the coefficient of config.proton_met is recomputed so the reaction's total ionic charge sums to zero.

scale_biomass

Rescale a component to a new mass fraction, optionally balancing out a second component to keep the total at 1 g/gDW.

Ports scaleBioMass.m. The rescaling factor is derived from :func:sum_biomass on the current model state, so call this with an in-place model mutation, not on a stale snapshot.

set_gam

Set GAM (and optionally NGAM) on a model in place.

Scales every metabolite participating in the biomass pseudoreaction whose name is in cofactor_met_names (e.g. ATP, ADP, H2O, H+, phosphate) to ±value, preserving the sign of its current coefficient.

If both ngam_rxn and ngam_value are given, the NGAM reaction's bounds are fixed at (ngam_value, ngam_value).

Parameters:

Name Type Description Default
model Model

cobra model to mutate.

required
value float

New GAM value (mmol ATP / gDW per growth unit).

required
biomass_rxn str

Reaction id of the biomass pseudoreaction whose stoichiometry carries the GAM coefficients.

required
cofactor_met_names Iterable[str]

Iterable of metabolite names (not ids) — every metabolite in the biomass pseudoreaction whose name is in this set will be rescaled. yeast-GEM uses {"ATP", "ADP", "H2O", "H+", "phosphate"}.

required
ngam_rxn str | None

Optional NGAM update. If both are provided, the reaction's bounds are set to (ngam_value, ngam_value) (equality constraint).

None
ngam_value str | None

Optional NGAM update. If both are provided, the reaction's bounds are set to (ngam_value, ngam_value) (equality constraint).

None

Returns:

Type Description
Model

The (mutated) model, for chaining.

sum_biomass

Mass-fraction (g/gDW) per biomass component plus the total.

Mirrors yeast-GEM's sumBioMass.m. Returns a dict keyed by each :class:BiomassComponent name plus "total". Components whose pseudoreaction is missing from the model contribute 0 (logged as a warning).

Substrate detection: in each component's pseudoreaction, the substrate side is the metabolites with negative coefficient — the same convention yeast-GEM uses.