10.1.2.1.4. freeflux.core.model

Define the Model class.

10.1.2.1.4.1. Attributes

__author__

10.1.2.1.4.2. Classes

Model

Model class is the fundamental class of FreeFlux hosting operations for 13C MFA.

10.1.2.1.4.3. Module Contents

freeflux.core.model.__author__ = 'Chao Wu'[source]
class freeflux.core.model.Model(name='unnamed')[source]

Model class is the fundamental class of FreeFlux hosting operations for 13C MFA. A model can be built by adding reactions one by one or reading set of reactions from .tsv or .xlsx file.

Parameters:

name (str) – Model name.

name[source]

Model name.

Type:

str

metabolites_info[source]

Metabolite ID => list of Metabolites.

Type:

dict

reactions_info[source]

Reaction ID => Reaction.

Type:

OrderedDict

metabolites[source]

Metabolite IDs, in alphabetical order.

Type:

list

metabolites_with_atoms[source]

IDs of metabolite with atom assignment, in alphabetical order.

Type:

list

end_substrates[source]

Initial substrates of the model, in alphabetical order.

Type:

list

end_products[source]

Final products of the model, in alphabetical order.

Type:

list

reactions[source]

Reaction IDs, in order of addition.

Type:

list

n_metabolites[source]

# of metabolites.

Type:

int

n_reactions[source]

# of reactions.

Type:

int

_full_net_stoichiometric_matrix[source]

Complete stoichiometric matrix for net reaction with all metabolites in rows, net reactions in columns.

Type:

df

_full_total_stoichiometric_matrix[source]

Complete stoichiometric matrix for total reaction with all metabolites in rows, total reactions in columns.

Type:

df

metabolite_adjacency_matrix[source]

Metabolite adjacency matrix (MAM). Metabolites with atoms are in index and columns (no duplicates). List of Reactions are in cells if reactions exists between (sub, pro), [] otherwise.

Type:

df

net_fluxes_bounds[source]

Reaction ID => [lb, ub] by setting.

Type:

dict

net_fluxes_range[source]

Reaction ID => estimeted [lb, ub]. All required net fluxes are included.

Type:

dict

netfluxids[source]

Net flux IDs, alias of reactions.

Type:

list

concentrations[source]

Concentrations, metabolite ID => float.

Type:

ser

concentrations_bounds[source]

Metabolite ID => [lb, ub] by setting.

Type:

dict

concentrations_range[source]

Metabolite ID => [lb, ub]. All required concentrations are included.

Type:

dict

concids[source]

Concentration IDs (used only in computation process).

Type:

list

total_fluxes[source]

Total fluxes, fluxe ID (e.g., ‘v1_f’ or ‘v2’) => float.

Type:

ser

totalfluxids[source]

Total flux IDs.

Type:

list

target_EMUs[source]

Target EMU IDs.

Type:

list

timepoints[source]

Sorted time points for MDV simulation.

Type:

list

substrate_MDVs[source]

Substrate EMU => MDV.

Type:

dict

substrate_MDVs_der_p[source]

Substrate EMU => derivatives of substrate MDV w.r.t. variables in shape of (len(MDV), # of vars). # of vars = # of free fluxes for steady state MFA; # of vars = # of free fluxes + # of concentrations for INST MFA.

Type:

dict

initial_matrix_Xs[source]

Size => initial MDVs of EMU in matrix X, i.e., the natural MDVs. The initial MDV matrix has the same shape of matrix X.

Type:

dict

initial_matrix_Ys[source]

Size => initial MDVs of EMU in matrix Y, i.e., either natural MDVs or labeled MDVs. The initial MDV matrix has the same shape of matrix Y.

Type:

dict

initial_matrix_Xs_der_p, initial_matrix_Ys_der_p

Size => 3-D array in shape of (# of vars), X(Y).shape[0], X(Y).shape[1]) which is the initial MDV derivatives of EMUs in matrix X(Y) w.r.t. variables. # of vars = # of free fluxes + # of concentrations for INST MFA.

Type:

dict

initial_sim_MDVs[source]

EMU ID => {t0 => MDV}. MDV of target EMUs at t0.

Type:

dict

EAMs[source]

Size => EMU adjacency matrix (EAM). Cells are symbolic expression of flux.

Type:

dict of df

matrix_As, matrix_Bs

Size => [lambdified matrix A(B), [flux IDs], [EMUs]].

Type:

dict

matrix_As_der_p, matrix_Bs_der_p

Size => 3-D array in shape of (# of vars, A(B).shape[0], A(B).shape[1]) which is the derivatives of matrix A(B) w.r.t. variables. # of vars = # of free fluxes for steady state MFA; # of vars = # of free fluxes + # of concentrations for INST MFA.

Type:

dict

matrix_Ms[source]

Size => [lambdified matrix M, [metabolite IDs]].

Type:

dict

matrix_Ms_der_p[source]

Size => 3-D array in shape of (# of vars, M.shape[0], M.shape[1]), which is the derivatives of matrix M w.r.t. variables. # of vars = # of free fluxes for steady state MFA; # of vars = # of free fluxes + # of concentrations for INST MFA.

Type:

dict

label_atom[source]

Labeled atom, i.e., the base atom in MDV, currently only supprts “H”, “C” and “N”.

Type:

str

labeling_strategy[source]

Metabolite ID => [labeling_pattern(s), percentage(s), purity(s)].

Type:

dict

measured_MDVs[source]

EMU ID (metabolite ID + ‘_’ + atom NOs) => [means of MDV, SDs of MDV].

Type:

dict

measured_MDVs_inv_cov[source]

Inversed covariance matrix of measured MDVs with variances on the diagnol, other elements are zero.

Type:

array

measured_fluxes[source]

Irreversible reaction ID => [mean, SD].

Type:

dict

measured_fluxes_inv_cov[source]

Inversed covariance matrix of measured fluxes with variances on the diagnol, other elements are zero.

Type:

array

measured_fluxes_der_p[source]

Derivative of measured fluxes w.r.t. variables in shape of (# of measured fluxes, # of vars), # of vars = # of free fluxes for steady state MFA; # of vars = # of free fluxes + # of concentrations for INST MFA.

Type:

array

measured_inst_MDVs[source]

EMU ID (metabolite ID + ‘_’ + atom NOs) => {timepoint => [means of MDV, SDs of MDV]}.

Type:

dict

measured_inst_MDVs_inv_cov[source]

Inversed covariance matrix of measured concatenated MDVs with variances on the diagnol, other elements are zero. Timepoints are concatenated except t0.

Type:

array

null_space[source]

Null space of total stoichiometric matrix.

Type:

2-D array

transform_matrix[source]

Transform matrix letting vnet = transform_matrix*v.

Type:

2-D array

name = 'unnamed'[source]
reactions_info[source]
target_EMUs = [][source]
timepoints = [][source]
substrate_MDVs[source]
substrate_MDVs_der_p[source]
EAMs[source]
matrix_As[source]
matrix_Bs[source]
matrix_Ms[source]
matrix_As_der_p[source]
matrix_Bs_der_p[source]
matrix_Ms_der_p[source]
null_space = None[source]
transform_matrix = None[source]
initial_matrix_Xs[source]
initial_matrix_Ys[source]
initial_matrix_Xs_der_p[source]
initial_matrix_Ys_der_p[source]
initial_sim_MDVs[source]
label_atom = None[source]
labeling_strategy[source]
measured_MDVs[source]
measured_fluxes[source]
measured_inst_MDVs[source]
measured_MDVs_inv_cov = None[source]
measured_inst_MDVs_inv_cov = None[source]
measured_fluxes_inv_cov = None[source]
measured_fluxes_der_p = None[source]
unbalanced_metabolites[source]
net_fluxes_bounds[source]
net_fluxes_range[source]
concentrations_bounds[source]
concentrations_range[source]
total_fluxes[source]
concentrations[source]
add_reactions(reactions)[source]
Parameters:

reactions (Reaction or list of Reaction)

remove_reactions(reactions)[source]
Parameters:

reactions (Reaction or list of Reaction)

read_from_file(file)[source]
Parameters:

file (file path) –

tsv or excel file with reactions with fields “reaction_ID”, “substrate_IDs(atom)”, “product_IDs(atom)” and “reversibility”.

Header line starts with “#”, and will be skiped.

property metabolites_info[source]

returns: metabsInfo – metabolite ID => list of Metabolites :rtype: dict

property metabolites[source]
property metabolites_with_atoms[source]
property reactions[source]
property n_metabolites[source]
property n_reactions[source]
_full_net_stoichiometric_matrix(metabolites, reactions)[source]

Re-estimate stoichiometric matrix if metabolites or reactions changes.

Parameters:
  • metabolites (tuple) – metabolite IDs

  • reactions (tuple) – reaction IDs

Returns:

netS – Complete stoichiometric matrix for net reaction with all metabolites in rows and net reactions in columns.

Return type:

df

_full_total_stoichiometric_matrix(metabolites, reactions)[source]

Re-estimate stoichiometric matrix if metabolites or reactions changes.

Parameters:
  • metabolites (tuple) – metabolite IDs

  • reactions (tuple) – reaction IDs

Returns:

totalS – Complete stoichiometric matrix for total reaction with all metabolites in rows and total reactions in columns.

Return type:

df

property end_substrates[source]
property end_products[source]
get_net_stoichiometric_matrix(exclude_metabs=None, include_ends=False)[source]
Parameters:
  • exclude_metabs (list or set) – Excluded metabolites.

  • include_ends (bool) – Whether to include end metabolites (i.e., initial substrates and final products).

  • Returns

  • netS (df) – Net stoichiometric matrix with balanced metabolites in rows and net reactions in columns

get_total_stoichiometric_matrix(exclude_metabs=None, include_ends=False)[source]
Parameters:
  • exclude_metabs (list or set) – Excluded metabolites.

  • include_ends (bool) – Whether to include end metabolites (initial substrates and final products).

  • Returns

  • totalS (df) – Total stoichiometric matrix with balanced metabolites in rows and total reactions in columns

property netfluxids[source]
property totalfluxids[source]
property concids[source]
property metabolite_adjacency_matrix[source]
returns: MAM – Metabolite adjacency matrix (MAM). Metabolites with atoms are in index and columns

(no duplicates). List of Reactions are in cells if reactions exists between sub (index) and pro (columns), [] otherwise

Return type:

df

__repr__()[source]
_BFS(iniEMU)[source]
Parameters:

iniEMU (EMU) – Starting EMU of the decomposition. Metabolite of iniEMU can be any Metabolite instance with the same id.

Returns:

EAMsInfo – Size => list of [EMU, [precursor EMUs], symbolic expression of flux].

Return type:

dict of list

_get_original_EAMs(iniEMU)[source]
Parameters:

iniEMU (EMU) – Starting EMU of the decomposition.

Returns:

EAMs – Size => original EMU adjacency matrix (EAM), cells are symbolic expression of flux。

Return type:

dict of df

_replace_list_item(iterable, toReplace, value)[source]
Parameters:
  • iterable (iterable) – Iterable can be nested.

  • toReplace (scalar) – Value to be replaced.

  • value (scalar) – Value that replaces toReplace.

Returns:

newLst – New tuple with toReplace recursively replaced.

Return type:

tuple

_uniquify_dataFrame_index(df)[source]
Parameters:

df (df) – DataFrame to be uniquify.

Returns:

uniqueDf – DataFrame with duplicate rows combined (summated).

Return type:

df

_lump_linear_EMUs(EAMs, iniEMU)[source]
Parameters:
  • EAMs (dict of df) – Size => original EMU adjacency matrix (EAM), cells are symbolic expression of flux.

  • iniEMU (EMU) – Starting EMU of the decomposition.

Returns:

lumpedEAMs – Size => lumped EMU adjacency matrix (EAM), cells are symbolic expression of flux.

Return type:

dict of df

_combine_equivalent_EMUs(EAMs)[source]
Parameters:

EAMs (dict of df) – Size => original EMU adjacency matrix (EAM), cells are symbolic expression of flux.

Returns:

combinedEAMs – Size => EAM with equivalent EMUs combined, cells are symbolic expression of flux.

Return type:

dict df

get_emu_adjacency_matrices(iniEMU, lump=True)[source]
Parameters:
  • iniEMU (EMU) – Starting EMU of the decomposition.

  • lump (bool) – Whether to lump linear EMUs.

Returns:

EAMs – Size => EMU adjacency matrix (EAM) after lumping of linear EMUs and combination of equivalent EMUs. Index and columns are EMUs, cells are symbolic expression of flux.

Return type:

dict of df

Notes

EMUs in sequential reactions can not be lumped in transient MFA.

_merge_EAMs(EAM1, EAM2)[source]
Parameters:
  • EAM1 (df) – EMU adjacency matrix (EAM) to merge

  • EAM2 (df) – EMU adjacency matrix (EAM) to merge

Returns:

mergedEAM – merged EAM

Return type:

df

_merge_all_EAMs(*EAMsAll)[source]
Parameters:

EAMsAll (tuple of EAMs) – EAMs is dict of DataFrame, i.e., Size => EMU adjacency matrix (EAM).

Returns:

mergedEAMs – Size => merged EAM

Return type:

dict of df

_decompose_network(metabolites, atom_nos, lump=True, n_jobs=1)[source]
Parameters:
  • metabolites (list of str) – List of metabolite IDs from which initial EMU will be generated to start the decomposition.

  • atom_nos (list of str) – Atom NOs of corresponding metabolites, len(atom_nos) should be equal to len(metabolites).

  • lump (bool) – Whether to lump linear EMUs.

  • n_jobs (int) – # of jobs to run in parallel.

Returns:

mergedEAMs – Size => merged EMU adjacency matrix (EAM).

Return type:

dict of df

Notes

EMUs in sequential reactions can not be lumped in transient MFA.

decompose_network(ini_emus, lump=True, n_jobs=1)[source]
Parameters:
  • ini_emus (dict) – Metabolite ID => atom NOs or list of atom NOs. Atom NOs can be int list or str, e.g., {‘Ala’: [[1,2,3], ‘23’], ‘Ser’: ‘123’}

  • lump (bool) – Whether to lump linear EMUs.

  • n_jobs (int) – # of jobs to run in parallel.

Returns:

mergedEAMs – Size => merged EMU adjacency matrix (EAM)

Return type:

dict of df

Notes

EMUs in sequential reactions can not be lumped in transient MFA.

optimizer()[source]
simulator(kind)[source]
Parameters:

kind ({"ss", "inst"}) –

  • If “ss”, simulation at isotopic steady state is performed.

  • If “inst”, simulation at isotopically nonstationary state is performed.

fitter(kind)[source]
Parameters:

kind ({"ss", "inst"}) –

  • If “ss”, fitting at isotopic steady state is performed.

  • If “inst”, fitting at isotopically nonstationary state is performed.