freeflux.core.model =================== .. py:module:: freeflux.core.model .. autoapi-nested-parse:: Define the Model class. Attributes ---------- .. autoapisummary:: freeflux.core.model.__author__ Classes ------- .. autoapisummary:: freeflux.core.model.Model Module Contents --------------- .. py:data:: __author__ :value: 'Chao Wu' .. py:class:: Model(name='unnamed') 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. :param name: Model name. :type name: str .. attribute:: name Model name. :type: str .. attribute:: metabolites_info Metabolite ID => list of Metabolites. :type: dict .. attribute:: reactions_info Reaction ID => Reaction. :type: OrderedDict .. attribute:: metabolites Metabolite IDs, in alphabetical order. :type: list .. attribute:: metabolites_with_atoms IDs of metabolite with atom assignment, in alphabetical order. :type: list .. attribute:: end_substrates Initial substrates of the model, in alphabetical order. :type: list .. attribute:: end_products Final products of the model, in alphabetical order. :type: list .. attribute:: reactions Reaction IDs, in order of addition. :type: list .. attribute:: n_metabolites # of metabolites. :type: int .. attribute:: n_reactions # of reactions. :type: int .. attribute:: _full_net_stoichiometric_matrix Complete stoichiometric matrix for net reaction with all metabolites in rows, net reactions in columns. :type: df .. attribute:: _full_total_stoichiometric_matrix Complete stoichiometric matrix for total reaction with all metabolites in rows, total reactions in columns. :type: df .. attribute:: metabolite_adjacency_matrix 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 .. attribute:: net_fluxes_bounds Reaction ID => [lb, ub] by setting. :type: dict .. attribute:: net_fluxes_range Reaction ID => estimeted [lb, ub]. All required net fluxes are included. :type: dict .. attribute:: netfluxids Net flux IDs, alias of reactions. :type: list .. attribute:: concentrations Concentrations, metabolite ID => float. :type: ser .. attribute:: concentrations_bounds Metabolite ID => [lb, ub] by setting. :type: dict .. attribute:: concentrations_range Metabolite ID => [lb, ub]. All required concentrations are included. :type: dict .. attribute:: concids Concentration IDs (used only in computation process). :type: list .. attribute:: total_fluxes Total fluxes, fluxe ID (e.g., 'v1_f' or 'v2') => float. :type: ser .. attribute:: totalfluxids Total flux IDs. :type: list .. attribute:: target_EMUs Target EMU IDs. :type: list .. attribute:: timepoints Sorted time points for MDV simulation. :type: list .. attribute:: substrate_MDVs Substrate EMU => MDV. :type: dict .. attribute:: substrate_MDVs_der_p 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 .. attribute:: initial_matrix_Xs 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 .. attribute:: initial_matrix_Ys 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 .. attribute:: 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 .. attribute:: initial_sim_MDVs EMU ID => {t0 => MDV}. MDV of target EMUs at t0. :type: dict .. attribute:: EAMs Size => EMU adjacency matrix (EAM). Cells are symbolic expression of flux. :type: dict of df .. attribute:: matrix_As, matrix_Bs Size => [lambdified matrix A(B), [flux IDs], [EMUs]]. :type: dict .. attribute:: 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 .. attribute:: matrix_Ms Size => [lambdified matrix M, [metabolite IDs]]. :type: dict .. attribute:: matrix_Ms_der_p 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 .. attribute:: label_atom Labeled atom, i.e., the base atom in MDV, currently only supprts "H", "C" and "N". :type: str .. attribute:: labeling_strategy Metabolite ID => [labeling_pattern(s), percentage(s), purity(s)]. :type: dict .. attribute:: measured_MDVs EMU ID (metabolite ID + '_' + atom NOs) => [means of MDV, SDs of MDV]. :type: dict .. attribute:: measured_MDVs_inv_cov Inversed covariance matrix of measured MDVs with variances on the diagnol, other elements are zero. :type: array .. attribute:: measured_fluxes Irreversible reaction ID => [mean, SD]. :type: dict .. attribute:: measured_fluxes_inv_cov Inversed covariance matrix of measured fluxes with variances on the diagnol, other elements are zero. :type: array .. attribute:: measured_fluxes_der_p 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 .. attribute:: measured_inst_MDVs EMU ID (metabolite ID + '_' + atom NOs) => {timepoint => [means of MDV, SDs of MDV]}. :type: dict .. attribute:: measured_inst_MDVs_inv_cov Inversed covariance matrix of measured concatenated MDVs with variances on the diagnol, other elements are zero. Timepoints are concatenated except t0. :type: array .. attribute:: null_space Null space of total stoichiometric matrix. :type: 2-D array .. attribute:: transform_matrix Transform matrix letting vnet = transform_matrix*v. :type: 2-D array .. py:attribute:: name :value: 'unnamed' .. py:attribute:: reactions_info .. py:attribute:: target_EMUs :value: [] .. py:attribute:: timepoints :value: [] .. py:attribute:: substrate_MDVs .. py:attribute:: substrate_MDVs_der_p .. py:attribute:: EAMs .. py:attribute:: matrix_As .. py:attribute:: matrix_Bs .. py:attribute:: matrix_Ms .. py:attribute:: matrix_As_der_p .. py:attribute:: matrix_Bs_der_p .. py:attribute:: matrix_Ms_der_p .. py:attribute:: null_space :value: None .. py:attribute:: transform_matrix :value: None .. py:attribute:: initial_matrix_Xs .. py:attribute:: initial_matrix_Ys .. py:attribute:: initial_matrix_Xs_der_p .. py:attribute:: initial_matrix_Ys_der_p .. py:attribute:: initial_sim_MDVs .. py:attribute:: label_atom :value: None .. py:attribute:: labeling_strategy .. py:attribute:: measured_MDVs .. py:attribute:: measured_fluxes .. py:attribute:: measured_inst_MDVs .. py:attribute:: measured_MDVs_inv_cov :value: None .. py:attribute:: measured_inst_MDVs_inv_cov :value: None .. py:attribute:: measured_fluxes_inv_cov :value: None .. py:attribute:: measured_fluxes_der_p :value: None .. py:attribute:: unbalanced_metabolites .. py:attribute:: net_fluxes_bounds .. py:attribute:: net_fluxes_range .. py:attribute:: concentrations_bounds .. py:attribute:: concentrations_range .. py:attribute:: total_fluxes .. py:attribute:: concentrations .. py:method:: add_reactions(reactions) :param reactions: :type reactions: Reaction or list of Reaction .. py:method:: remove_reactions(reactions) :param reactions: :type reactions: Reaction or list of Reaction .. py:method:: read_from_file(file) :param file: 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. :type file: file path .. py:property:: metabolites_info returns: **metabsInfo** -- metabolite ID => list of Metabolites :rtype: dict .. py:property:: metabolites .. py:property:: metabolites_with_atoms .. py:property:: reactions .. py:property:: n_metabolites .. py:property:: n_reactions .. py:method:: _full_net_stoichiometric_matrix(metabolites, reactions) Re-estimate stoichiometric matrix if metabolites or reactions changes. :param metabolites: metabolite IDs :type metabolites: tuple :param reactions: reaction IDs :type reactions: tuple :returns: **netS** -- Complete stoichiometric matrix for net reaction with all metabolites in rows and net reactions in columns. :rtype: df .. py:method:: _full_total_stoichiometric_matrix(metabolites, reactions) Re-estimate stoichiometric matrix if metabolites or reactions changes. :param metabolites: metabolite IDs :type metabolites: tuple :param reactions: reaction IDs :type reactions: tuple :returns: **totalS** -- Complete stoichiometric matrix for total reaction with all metabolites in rows and total reactions in columns. :rtype: df .. py:property:: end_substrates .. py:property:: end_products .. py:method:: get_net_stoichiometric_matrix(exclude_metabs=None, include_ends=False) :param exclude_metabs: Excluded metabolites. :type exclude_metabs: list or set :param include_ends: Whether to include end metabolites (i.e., initial substrates and final products). :type include_ends: bool :param Returns: :param netS: Net stoichiometric matrix with balanced metabolites in rows and net reactions in columns :type netS: df .. py:method:: get_total_stoichiometric_matrix(exclude_metabs=None, include_ends=False) :param exclude_metabs: Excluded metabolites. :type exclude_metabs: list or set :param include_ends: Whether to include end metabolites (initial substrates and final products). :type include_ends: bool :param Returns: :param totalS: Total stoichiometric matrix with balanced metabolites in rows and total reactions in columns :type totalS: df .. py:property:: netfluxids .. py:property:: totalfluxids .. py:property:: concids .. py:property:: metabolite_adjacency_matrix 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 :rtype: df .. py:method:: __repr__() .. py:method:: _BFS(iniEMU) :param iniEMU: Starting EMU of the decomposition. Metabolite of iniEMU can be any Metabolite instance with the same id. :type iniEMU: EMU :returns: **EAMsInfo** -- Size => list of [EMU, [precursor EMUs], symbolic expression of flux]. :rtype: dict of list .. py:method:: _get_original_EAMs(iniEMU) :param iniEMU: Starting EMU of the decomposition. :type iniEMU: EMU :returns: **EAMs** -- Size => original EMU adjacency matrix (EAM), cells are symbolic expression of flux。 :rtype: dict of df .. py:method:: _replace_list_item(iterable, toReplace, value) :param iterable: Iterable can be nested. :type iterable: iterable :param toReplace: Value to be replaced. :type toReplace: scalar :param value: Value that replaces toReplace. :type value: scalar :returns: **newLst** -- New tuple with toReplace recursively replaced. :rtype: tuple .. py:method:: _uniquify_dataFrame_index(df) :param df: DataFrame to be uniquify. :type df: df :returns: **uniqueDf** -- DataFrame with duplicate rows combined (summated). :rtype: df .. py:method:: _lump_linear_EMUs(EAMs, iniEMU) :param EAMs: Size => original EMU adjacency matrix (EAM), cells are symbolic expression of flux. :type EAMs: dict of df :param iniEMU: Starting EMU of the decomposition. :type iniEMU: EMU :returns: **lumpedEAMs** -- Size => lumped EMU adjacency matrix (EAM), cells are symbolic expression of flux. :rtype: dict of df .. py:method:: _combine_equivalent_EMUs(EAMs) :param EAMs: Size => original EMU adjacency matrix (EAM), cells are symbolic expression of flux. :type EAMs: dict of df :returns: **combinedEAMs** -- Size => EAM with equivalent EMUs combined, cells are symbolic expression of flux. :rtype: dict df .. py:method:: get_emu_adjacency_matrices(iniEMU, lump=True) :param iniEMU: Starting EMU of the decomposition. :type iniEMU: EMU :param lump: Whether to lump linear EMUs. :type lump: bool :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. :rtype: dict of df .. rubric:: Notes EMUs in sequential reactions can not be lumped in transient MFA. .. py:method:: _merge_EAMs(EAM1, EAM2) :param EAM1: EMU adjacency matrix (EAM) to merge :type EAM1: df :param EAM2: EMU adjacency matrix (EAM) to merge :type EAM2: df :returns: **mergedEAM** -- merged EAM :rtype: df .. py:method:: _merge_all_EAMs(*EAMsAll) :param EAMsAll: EAMs is dict of DataFrame, i.e., Size => EMU adjacency matrix (EAM). :type EAMsAll: tuple of EAMs :returns: **mergedEAMs** -- Size => merged EAM :rtype: dict of df .. py:method:: _decompose_network(metabolites, atom_nos, lump=True, n_jobs=1) :param metabolites: List of metabolite IDs from which initial EMU will be generated to start the decomposition. :type metabolites: list of str :param atom_nos: Atom NOs of corresponding metabolites, len(atom_nos) should be equal to len(metabolites). :type atom_nos: list of str :param lump: Whether to lump linear EMUs. :type lump: bool :param n_jobs: # of jobs to run in parallel. :type n_jobs: int :returns: **mergedEAMs** -- Size => merged EMU adjacency matrix (EAM). :rtype: dict of df .. rubric:: Notes EMUs in sequential reactions can not be lumped in transient MFA. .. py:method:: decompose_network(ini_emus, lump=True, n_jobs=1) :param ini_emus: 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'} :type ini_emus: dict :param lump: Whether to lump linear EMUs. :type lump: bool :param n_jobs: # of jobs to run in parallel. :type n_jobs: int :returns: **mergedEAMs** -- Size => merged EMU adjacency matrix (EAM) :rtype: dict of df .. rubric:: Notes EMUs in sequential reactions can not be lumped in transient MFA. .. py:method:: optimizer() .. py:method:: simulator(kind) :param kind: * If "ss", simulation at isotopic steady state is performed. * If "inst", simulation at isotopically nonstationary state is performed. :type kind: {"ss", "inst"} .. py:method:: fitter(kind) :param kind: * If "ss", fitting at isotopic steady state is performed. * If "inst", fitting at isotopically nonstationary state is performed. :type kind: {"ss", "inst"}