5. etfba

5.1. Subpackages

5.2. Submodules

5.3. Attributes

__author__

__version__

5.4. Classes

Model

Metabolite

Metabolite instances created with identical IDs, names, and all other attributes

Reaction

5.5. Package Contents

etfba.__author__ = 'Chao Wu'[source]
etfba.__version__ = '0.2.0'[source]
class etfba.Model(name=None)[source]
metabolites

A dictionary mapping metabolite IDs to corresponding Metabolite objects.

Type:

PrettyDict

reactions

A dictionary mapping reaction IDs to corresponding Reaction objects.

Type:

PrettyDict

end_metabolites

A dictionary mapping metabolite IDs to Metabolite objects representing initial substrates or final products within the model.

Type:

PrettyDict

stoichiometric_matrix

Represents the stoichiometric matrix where rows correspond to metabolites and columns correspond to net reactions. Negative values indicate substrates, while positive values denote products.

Type:

DataFrame

total_stoichiometric_matrix

Represents the stoichiometric matrix where rows correspond to metabolites and columns correspond to total reactions (reversible reactions are split into forward and backward reactions). Negative values denote substrates, while positive values denote products.

Type:

DataFrame

transformation_matrix

Matrix facilitating the conversion of total fluxes into net fluxes.

Type:

DataFrame

name
_metabolites
_reactions
classmethod load(filename)[source]
Parameters:

filename (str) – Filename of the model file. The filename should end with the extension ‘.bin’.

save(filename)[source]
Parameters:

filename (str) – Filename of the model to save. The filename should end with the extension ‘.bin’.

static _set_value(value, default)[source]
_build_reactant(rxn, reacsStr, reackms, label)[source]
read_from_excel(filename)[source]
Parameters:

filename (str) – Filename of an Excel file containing the following fields: Enzyme, Substrates, Products, Sub Kms (mM), Pro Kms (mM), Fwd kcat (1/s), Bwd kcat (1/s), MW (kDa), and ΔrG’m (kJ/mol).

add_reactions(reactions)[source]
Parameters:

reactions (Reaction or list of Reactions) – Reaction objects to be added into the model.

remove_reactions(reactions)[source]
Parameters:

reactions (Reaction or list of Reactions) – Reaction objects to be removed from the model.

property metabolites
property reactions
_get_stoichiometric_matrix(metabolites, reactions)[source]
Parameters:
  • metabolites (tuple) – A tuple of metabolite IDs.

  • reactions (tuple) – A tuple of reaction IDs.

property stoichiometric_matrix
_get_total_stoichiometric_matrix(metabolites, reactions)[source]
Parameters:
  • metabolites (tuple) – A tuple of metabolite IDs.

  • reactions (tuple) – A tuple of reaction IDs.

property total_stoichiometric_matrix
_get_transformation_matrix(metabolites, reactions)[source]
Parameters:
  • metabolites (tuple) – A tuple of metabolite IDs.

  • reactions (tuple) – A tuple of reaction IDs.

property transformation_matrix
property end_metabolites
optimize(kind, *, objective=None, flux_bound=(0, 1000), conc_bound=(0.001, 100), spec_flux_bound=None, spec_conc_bound=None, preset_flux=None, preset_conc=None, preset_conc_ratio=None, irr_reactions=None, ex_conc=None, ex_mass_bal_cons=None, ex_thermo_cons=None, inc_enz_cons=None, enz_prot_lb=None, parsimonious=False, slack=0.001, dgpm_conf_level=None)[source]

Perform constraint-based optimization considering various constraints such as mass balance, thermodynamic, and enzyme protein allocation constraints.

Parameters:
  • kind ({'fba', 'tfba', 'efba', 'etfba'}) – Type of optimization to perform: - ‘fba’: Flux Balance Analysis with mass balance constraints only. - ‘tfba’: Flux Balance Analysis with both mass balance and thermodynamic constraints. - ‘efba’: Flux Balance Analysis with both mass balance and enzyme protein cost constraints. - ‘etfba’: Flux Balance Analysis with mass balance, thermodynamics, and enzyme protein cost constraints.

  • objective (dict) – Mapping of flux IDs to coefficients in the objective expression, e.g., {‘r1’: 2, ‘r2’: -1} defines the expression “2*r1 - 1*r2”. Suffix of ‘_f’ or ‘_b’ is required to indicate forward or backward flux for reversible reactions. Valid in ‘fba’, ‘tfba’, ‘efba’, and ‘etfba’.

  • flux_bound (2-tuple) – Lower and upper bounds of metabolic fluxes in mmol/gCDW/h. Valid in ‘fba’, ‘tfba’, ‘efba’ and ‘etfba’.

  • conc_bound (2-tuple) – Lower and upper bounds of metabolite concentrations in mM. Valid in ‘tfba’ and ‘etfba’.

  • spec_flux_bound (dict) – Mapping of flux IDs to their bounds (lb, ub), where spec_flux_bound takes priority over flux_bound. Suffix of ‘_f’ or ‘_b’ is required to indicate forward or backward flux for reversible reactions. Valid in ‘fba’, ‘tfba’, ‘efba’, and ‘etfba’.

  • spec_conc_bound (dict) – Mapping of metabolite IDs to their bounds (lb, ub), where spec_conc_bound takes priority over conc_bound. Valid in ‘tfba’ and ‘etfba’.

  • preset_flux (dict) – Mapping of flux IDs to fixed metabolic fluxes, e.g., substrate update rates. preset_flux takes priority over flux_bound. Suffix of ‘_f’ or ‘_b’ is required to indicate forward or backward flux for reversible reactions. Valid in ‘fba’, ‘tfba’, ‘efba’, and ‘etfba’.

  • preset_conc (dict) – Mapping of metabolite IDs to fixed metabolite concentrations, e.g., substrate concentrations in the media. preset_conc takes priority over conc_bound. Valid in ‘tfba’ and ‘etfba’.

  • preset_conc_ratio (dict) – Mapping of ratio IDs to fixed ratios of metabolites. Ratio ID has the format “metabid:metabid”. Valid in ‘tfba’ and ‘etfba’.

  • irr_reactions (list) – List of irreversible reaction IDs. irr_reactions is prioritized in defining reversibilities. Valid in ‘fba’, ‘tfba’, ‘efba’, and ‘etfba’.

  • ex_conc (list) – List of metabolite IDs excluded from optimization. Valid in ‘tfba’ and ‘etfba’.

  • ex_mass_bal_cons (list) – List of metabolite IDs excluded from mass balance constraints. Valid in ‘fba’, ‘tfba’, ‘efba’, and ‘etfba’.

  • ex_thermo_cons (list) – List of reaction IDs excluded from thermodynamics constraints. For reversible reactions, both forward and backward reactions are excluded. Valid in ‘tfba’ and ‘etfba’.

  • inc_enz_cons (list) – List of reaction IDs included in enzyme protein cost constraints. Default values are used for missing kinetic parameters of Km, kcat, and MW. Valid in ‘efba’ and ‘etfba’.

  • enz_prot_lb (float) – Upper bound of enzyme protein fraction in g/gCDW. Valid in ‘efba’ and ‘etfba’.

  • parsimonious (bool) – Whether to further calculate parsimonious fluxes while maintaining the objective no worse than that obtained by conventional flux balance analysis. It may take longer to compute but could be useful for eliminating loops. Valid in ‘fba’, ‘tfba’, ‘efba’, and ‘etfba’.

  • slack (float) – Small nonnegative constant used to relax the objective constraint in parsimonious FBA. The objective is required to be no less than (1-slack)*opt_obj. Considering adjusting slack if parsimonious FBA encounters difficulties in finding feasible solutions. Valid in ‘fba’, ‘tfba’, ‘efba’ and ‘etfba’.

  • dgpm_conf_level (float) – If dgpm_conf_level is set, the standard reaction Gibbs energy is allowed to vary between [dgpm - z*error, dgpm + z*error], where dgpm and error are the standard reaction Gibbs energy and its error, and z is determined by dgpm_conf_level. Valid in ‘tfba’ and ‘etfba’.

  • (deprecated) (use_initial_concs) – Initial values of fluxes; optimization will be performed without initials if None. Suffix of ‘_f’ or ‘_b’ is required to indicate forward or backward flux for reversible reactions. Valid only in ‘etfba’.

  • (deprecated) – Initial values of concentrations; optimization will be performed without initials if None. Valid only in ‘etfba’.

evaluate_variability(kind, *, objective=None, obj_value=None, gamma=1, flux_bound=(0, 100), conc_bound=(0.001, 10), spec_flux_bound=None, spec_conc_bound=None, preset_flux=None, preset_conc=None, preset_conc_ratio=None, irr_reactions=None, ex_conc=None, ex_mass_bal_cons=None, ex_thermo_cons=None, inc_enz_cons=None, enz_prot_lb=None, dgpm_conf_level=None)[source]

Perform variability analysis to assess the feasible range of derived fluxes, reaction Gibbs energies and enzyme protein costs.

Parameters:
  • kind ({'fva', 'tfva', 'efva', 'etfva', 'tva', 'etva', 'eva', 'teva'}) – Type of variability analysis to perform: - ‘fva’: Flux Variability Analysis. - ‘tfva’: Thermodynamically constrained Flux Variability Analysis. - ‘efva’: Enzyme protein allocation constrained Flux Variability Analysis. - ‘etfva’: Enzyme protein allocation and thermodynamically constrained Flux Variability Analysis. - ‘tva’: Thermodynamic Variability Analysis. - ‘etva’: Enzyme protein allocation constrained Thermodynamic Variability Analysis. - ‘eva’: Enzyme Protein Variability Analysis. - ‘teva’: Thermodynamically constrained Enzyme Protein Variability Analysis.

  • objective (dict) – Objective function used in corresponding ‘fba’, ‘tfba’, ‘efba’, or ‘etfba’ analysis. Mapping of flux IDs to coefficients in the objective expression, e.g., {‘r1’: 2, ‘r2’: -1} defines the expression “2*r1 - 1*r2”. Suffix of ‘_f’ or ‘_b’ is required to indicate forward or backward flux for reversible reactions. Valid in ‘fva’, ‘tfva’, ‘efva’, ‘etfva’, ‘tva’, ‘etva’, ‘eva’, ‘teva’.

  • obj_value (non-negative float) – Optimal objective of corresponding ‘fba’, ‘tfba’, ‘efba’, or ‘etfba’ analysis.

  • gamma (float in [0, 1]) – Objective expression required to be no less than gamma*obj_value. Consider adjusting gamma if etfba encounters difficulties in finding feasible solutions.

  • flux_bound (2-tuple) – Lower and upper bound of metabolic fluxes in mmol/gCDW/h. Valid in ‘fva’, ‘tfva’, ‘efva’, ‘etfva’, ‘tva’, ‘etva’, ‘eva’, ‘teva’.

  • conc_bound (2-tuple) – Lower and upper bound of metabolite concentrations in mM. Valid in ‘tfva’, ‘etfva’, ‘tva’, ‘etva’, and ‘teva’.

  • spec_flux_bound (dict) – Mapping of flux IDs to their bounds (lb, ub), where spec_flux_bound takes priority over flux_bound. Suffix of ‘_f’ or ‘_b’ is required to indicate forward or backward flux for reversible reactions. Valid in ‘fva’, ‘tfva’, ‘efva’, ‘etfva’, ‘tva’, ‘etva’, ‘eva’, ‘teva’.

  • spec_conc_bound (dict) – Mapping of metabolite IDs to their bounds (lb, ub), where spec_conc_bound takes priority over conc_bound. Valid in ‘tfva’, ‘etfva’, ‘tva’, ‘etva’ and ‘teva’.

  • preset_flux (dict) – Mapping of flux IDs to fixed metabolic fluxes, e.g., substrate update rates. preset_flux takes priority over flux_bound. Suffix of ‘_f’ or ‘_b’ is required to indicate forward or backward flux for reversible reactions. Valid in ‘fva’, ‘tfva’, ‘efva’, ‘etfva’, ‘tva’, ‘etva’, ‘eva’, ‘teva’.

  • preset_conc (dict) – Mapping of metabolite IDs to fixed metabolite concentrations, e.g., substrate concentrations in the media. preset_conc takes priority over conc_bound. Valid in ‘tfva’, ‘etfva’, ‘tva’, ‘etva’, and ‘teva’.

  • preset_conc_ratio (dict) – Mapping of ratio IDs to fixed ratios of metabolites. Ratio ID has the format “metabid:metabid”. Valid in ‘tfva’, ‘etfva’, ‘tva’, ‘etva’ and ‘teva’.

  • irr_reactions (list of reaction ID) – List of irreversible reaction IDs. irr_reactions is prioritized in defining reversibilities. Valid in ‘fva’, ‘tfva’, ‘efva’, ‘etfva’, ‘tva’, ‘etva’, ‘eva’, ‘teva’.

  • ex_conc (list of metabolite ID) – List of metabolite IDs excluded from optimization. Valid in ‘tfva’, ‘etfva’, ‘tva’, ‘etva’ and ‘teva’.

  • ex_mass_bal_cons (list of metabolite ID) – List of metabolite IDs excluded from mass balance constraints. Valid in ‘fva’, ‘tfva’, ‘efva’, ‘etfva’, ‘tva’, ‘etva’, ‘eva’, ‘teva’.

  • ex_thermo_cons (list of reaction ID) – List of reaction IDs excluded from thermodynamics constraints. For reversible reactions, both forward and backward reactions are excluded. Valid in ‘tfva’, ‘etfva’, ‘tva’, ‘etva’ and ‘teva’.

  • inc_enz_cons (list of reaction ID) – List of reaction IDs included in enzyme protein cost constraints. Default values are used for missing kinetic parameters of Km, kcat, and MW. Valid in ‘etva’, ‘teva’, ‘efva’ and ‘etfva’.

  • enz_prot_lb (float) – Upper bound of enzyme protein fraction in g/gCDW. Valid in ‘etva’, ‘teva’, ‘efva’ and ‘etfva’.

  • dgpm_conf_level (float) – If dgpm_conf_level is set, the standard reaction Gibbs energy is allowed to vary between [dgpm - z*error, dgpm + z*error], where dgpm and error are the standard reaction Gibbs energy and its error, and z is determined by dgpm_conf_level. Valid in ‘tfva’, ‘etfva’, ‘tva’, ‘etva’ and ‘teva’.

__repr__()[source]

Return repr(self).

class etfba.Metabolite(metabid, name=None, compartment=None, *, is_h=False, is_h2o=False)[source]

Metabolite instances created with identical IDs, names, and all other attributes are treated as a singular instance.

kms

Key is the reaction ID where the metabolite is involved, value is the corresponding Km value.

Type:

PrettyDict

km

Km value of the metabolite in the host reaction.

Type:

positive float

coes

Key is the reaction ID where the metabolite is involved, value is the corresponding stoichiometric coefficient in the reaction. Negative for substrates and positive for products.

Type:

PrettyDict

coe

Stoichiometric coefficient of the metabolite in the host reaction.

Type:

positive float

is_h

Indicates whether it is a proton.

Type:

bool

is_h2o

Indicates whether it is water.

Type:

bool

is_constrained_by_mass_balance

Indicates whether it appears in the mass balance constraints.

Type:

bool

host

The host reaction of the metabolite.

Type:

Reaction

role

Role played by the metabolite in the host reaction.

Type:

{‘substrate’, ‘product’}

metabid
name
compartment
is_h
is_h2o
kms
coes
is_constrained_by_mass_balance = False
host = None
role = None
property km
property coe
__repr__()[source]

Return repr(self).

class etfba.Reaction(rxnid, enzyme_name=None, category=None, *, forward_kcat=None, backward_kcat=None, molecular_weight=None, standard_gibbs_energy=None, standard_gibbs_energy_error=None, reversible=True, is_biomass_formation=False, is_exch_reaction=False, is_h_transport=False, is_h2o_transport=False)[source]
substrates

Key is the metabolite ID, value is the Metabolite instances as substrates.

Type:

PrettyDict

products

Key is the metabolite ID, value is the Metabolite instances as products.

Type:

PrettyDict

forward_kcat/fkcat

Catalytic rate constant in the forward direction.

Type:

float

backward_kcat/bkcat

Catalytic rate constant in the backward direction .

Type:

float

molecular_weight/mw

Molecular weight of the catalytic enzyme.

Type:

float

standard_gibbs_energy/dgpm

Standard Gibbs energy of the reaction.

Type:

float

standard_gibbs_energy_error/dgpm_error

Standard error of the standard reaction Gibbs energy.

Type:

float

reversible/rev

Reaction reversibility.

Type:

bool

is_biomass_formation

Indicates if it’s the biomass formation reaction.

Type:

bool

is_exch_reaction

Indicates if it’s an exchange reaction.

Type:

bool

is_h_transport

Indicates if it’s a proton transport reaction.

Type:

bool

is_h2o_transport

Indicates if it’s a water transport reaction.

Type:

bool

is_constrained_by_thermodynamics

Indicates if it’s constrained by thermodynamics.

Type:

bool

rxnid
enzyme
category
fkcat
bkcat
mw
dgpm
dgpm_error
rev
is_biomass_formation
is_exch_reaction
is_h_transport
is_h2o_transport
_substrates
_products
is_constrained_by_thermodynamics = False
_add_reactants(coes, kms, label)[source]
add_substrates(coes, kms=None)[source]
Parameters:
  • coes (dict) – Dictionary mapping substrates to their corresponding stoichiometric coefficients (positive values). All substrates should have a provided stoichiometric coefficient.

  • kms (dict) – Dictionary mapping substrates to their corresponding Km values. Km values should only be provided as a subset of substrates present in the ‘coes’ dictionary. An empty dict is acceptable if no Km values are available.

add_products(coes, kms=None)[source]
Parameters:
  • coes (dict) – Dictionary mapping products to their corresponding stoichiometric coefficients (positive values). All products should have a provided stoichiometric coefficient.

  • kms (dict) – Dictionary mapping products to their corresponding Km values. Km values should only be provided as a subset of products present in the ‘coes’ dictionary. An empty dict is acceptable if no Km values are available.

_remove_reactants(reactants, label)[source]
remove_substrates(substrates)[source]
Parameters:

substrates (list of Metabolite) – List of substrates to be removed from the current reaction.

remove_products(products)[source]
Parameters:

products (list of Metabolites) – List of products to be removed from current reaction.

property substrates
property products
property forward_kcat
property backward_kcat
property molecular_weight
property standard_gibbs_energy
property standard_gibbs_energy_error
property reversible
__repr__()[source]

Return repr(self).