etfba.core.model ================ .. py:module:: etfba.core.model .. autoapi-nested-parse:: Define the Model class. Classes ------- .. autoapisummary:: etfba.core.model.Model Module Contents --------------- .. py:class:: Model(name=None) .. attribute:: metabolites A dictionary mapping metabolite IDs to corresponding Metabolite objects. :type: PrettyDict .. attribute:: reactions A dictionary mapping reaction IDs to corresponding Reaction objects. :type: PrettyDict .. attribute:: end_metabolites A dictionary mapping metabolite IDs to Metabolite objects representing initial substrates or final products within the model. :type: PrettyDict .. attribute:: 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 .. attribute:: 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 .. attribute:: transformation_matrix Matrix facilitating the conversion of total fluxes into net fluxes. :type: DataFrame .. py:attribute:: name .. py:attribute:: _metabolites .. py:attribute:: _reactions .. py:method:: load(filename) :classmethod: :param filename: Filename of the model file. The filename should end with the extension '.bin'. :type filename: str .. py:method:: save(filename) :param filename: Filename of the model to save. The filename should end with the extension '.bin'. :type filename: str .. py:method:: _set_value(value, default) :staticmethod: .. py:method:: _build_reactant(rxn, reacsStr, reackms, label) .. py:method:: read_from_excel(filename) :param filename: 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). :type filename: str .. py:method:: add_reactions(reactions) :param reactions: Reaction objects to be added into the model. :type reactions: Reaction or list of Reactions .. py:method:: remove_reactions(reactions) :param reactions: Reaction objects to be removed from the model. :type reactions: Reaction or list of Reactions .. py:property:: metabolites .. py:property:: reactions .. py:method:: _get_stoichiometric_matrix(metabolites, reactions) :param metabolites: A tuple of metabolite IDs. :type metabolites: tuple :param reactions: A tuple of reaction IDs. :type reactions: tuple .. py:property:: stoichiometric_matrix .. py:method:: _get_total_stoichiometric_matrix(metabolites, reactions) :param metabolites: A tuple of metabolite IDs. :type metabolites: tuple :param reactions: A tuple of reaction IDs. :type reactions: tuple .. py:property:: total_stoichiometric_matrix .. py:method:: _get_transformation_matrix(metabolites, reactions) :param metabolites: A tuple of metabolite IDs. :type metabolites: tuple :param reactions: A tuple of reaction IDs. :type reactions: tuple .. py:property:: transformation_matrix .. py:property:: end_metabolites .. py:method:: 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) Perform constraint-based optimization considering various constraints such as mass balance, thermodynamic, and enzyme protein allocation constraints. :param kind: 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. :type kind: {'fba', 'tfba', 'efba', 'etfba'} :param objective: 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'. :type objective: dict :param flux_bound: Lower and upper bounds of metabolic fluxes in mmol/gCDW/h. Valid in 'fba', 'tfba', 'efba' and 'etfba'. :type flux_bound: 2-tuple :param conc_bound: Lower and upper bounds of metabolite concentrations in mM. Valid in 'tfba' and 'etfba'. :type conc_bound: 2-tuple :param spec_flux_bound: 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'. :type spec_flux_bound: dict :param spec_conc_bound: Mapping of metabolite IDs to their bounds (lb, ub), where spec_conc_bound takes priority over conc_bound. Valid in 'tfba' and 'etfba'. :type spec_conc_bound: dict :param preset_flux: 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'. :type preset_flux: dict :param preset_conc: 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'. :type preset_conc: dict :param preset_conc_ratio: Mapping of ratio IDs to fixed ratios of metabolites. Ratio ID has the format "metabid:metabid". Valid in 'tfba' and 'etfba'. :type preset_conc_ratio: dict :param irr_reactions: List of irreversible reaction IDs. irr_reactions is prioritized in defining reversibilities. Valid in 'fba', 'tfba', 'efba', and 'etfba'. :type irr_reactions: list :param ex_conc: List of metabolite IDs excluded from optimization. Valid in 'tfba' and 'etfba'. :type ex_conc: list :param ex_mass_bal_cons: List of metabolite IDs excluded from mass balance constraints. Valid in 'fba', 'tfba', 'efba', and 'etfba'. :type ex_mass_bal_cons: list :param ex_thermo_cons: List of reaction IDs excluded from thermodynamics constraints. For reversible reactions, both forward and backward reactions are excluded. Valid in 'tfba' and 'etfba'. :type ex_thermo_cons: list :param inc_enz_cons: 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'. :type inc_enz_cons: list :param enz_prot_lb: Upper bound of enzyme protein fraction in g/gCDW. Valid in 'efba' and 'etfba'. :type enz_prot_lb: float :param parsimonious: 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'. :type parsimonious: bool :param slack: 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'. :type slack: float :param dgpm_conf_level: 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'. :type dgpm_conf_level: float :param use_initial_fluxes (deprecated): 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'. :type use_initial_fluxes (deprecated): dict or file (.xlsx, .tsv, .bin) or None :param use_initial_concs (deprecated): Initial values of concentrations; optimization will be performed without initials if None. Valid only in 'etfba'. :type use_initial_concs (deprecated): dict or file (.xlsx, .tsv, .bin) or None .. py:method:: 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) Perform variability analysis to assess the feasible range of derived fluxes, reaction Gibbs energies and enzyme protein costs. :param kind: 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. :type kind: {'fva', 'tfva', 'efva', 'etfva', 'tva', 'etva', 'eva', 'teva'} :param objective: 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'. :type objective: dict :param obj_value: Optimal objective of corresponding 'fba', 'tfba', 'efba', or 'etfba' analysis. :type obj_value: non-negative float :param gamma: Objective expression required to be no less than gamma*obj_value. Consider adjusting gamma if etfba encounters difficulties in finding feasible solutions. :type gamma: float in [0, 1] :param flux_bound: Lower and upper bound of metabolic fluxes in mmol/gCDW/h. Valid in 'fva', 'tfva', 'efva', 'etfva', 'tva', 'etva', 'eva', 'teva'. :type flux_bound: 2-tuple :param conc_bound: Lower and upper bound of metabolite concentrations in mM. Valid in 'tfva', 'etfva', 'tva', 'etva', and 'teva'. :type conc_bound: 2-tuple :param spec_flux_bound: 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'. :type spec_flux_bound: dict :param spec_conc_bound: 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'. :type spec_conc_bound: dict :param preset_flux: 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'. :type preset_flux: dict :param preset_conc: 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'. :type preset_conc: dict :param preset_conc_ratio: Mapping of ratio IDs to fixed ratios of metabolites. Ratio ID has the format "metabid:metabid". Valid in 'tfva', 'etfva', 'tva', 'etva' and 'teva'. :type preset_conc_ratio: dict :param irr_reactions: List of irreversible reaction IDs. irr_reactions is prioritized in defining reversibilities. Valid in 'fva', 'tfva', 'efva', 'etfva', 'tva', 'etva', 'eva', 'teva'. :type irr_reactions: list of reaction ID :param ex_conc: List of metabolite IDs excluded from optimization. Valid in 'tfva', 'etfva', 'tva', 'etva' and 'teva'. :type ex_conc: list of metabolite ID :param ex_mass_bal_cons: List of metabolite IDs excluded from mass balance constraints. Valid in 'fva', 'tfva', 'efva', 'etfva', 'tva', 'etva', 'eva', 'teva'. :type ex_mass_bal_cons: list of metabolite ID :param ex_thermo_cons: 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'. :type ex_thermo_cons: list of reaction ID :param inc_enz_cons: 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'. :type inc_enz_cons: list of reaction ID :param enz_prot_lb: Upper bound of enzyme protein fraction in g/gCDW. Valid in 'etva', 'teva', 'efva' and 'etfva'. :type enz_prot_lb: float :param dgpm_conf_level: 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'. :type dgpm_conf_level: float .. py:method:: __repr__() Return repr(self).