src.model_balancing.model_balancing_cvx ======================================= .. py:module:: src.model_balancing.model_balancing_cvx .. autoapi-nested-parse:: A module for performing convex model balancing (using CVXPY). Module Contents --------------- .. py:class:: ModelBalancingConvex(S: numpy.array, fluxes: numpy.array, A_act: numpy.array, A_inh: numpy.array, metabolite_names: List[str], reaction_names: List[str], state_names: List[str], rate_law: str = 'CM', solver: str = 'MOSEK', beta: float = 0.0, **kwargs) Bases: :py:obj:`object` A class for performing Convex Model Balancing (using CVXPY). All input parameters are provided through the constructor. Then running .solve() will find the (global) optimum and the result will be stored in the cvxpy.Variable objects that represent the independent variables: .ln_Km .ln_Ka .ln_Ki .ln_Keq .ln_kcatf .ln_conc_met and also in the two dependent cvxpy.Expression objects: .ln_kcatr .ln_conc_enz Use the .value to get the solution for any of these Variables/Expressions. Alternatively, .to_model_sbtab and .to_state_sbtab return SBtab objects containing the state (met_conc, enz_conc) and the model (Km, Ki, Ka, Keq, kcatf, kcatr) values respectively. .. py:attribute:: S .. py:attribute:: fluxes .. py:attribute:: A_act .. py:attribute:: A_inh .. py:attribute:: metabolite_names .. py:attribute:: reaction_names .. py:attribute:: state_names .. py:attribute:: rate_law :value: 'CM' .. py:attribute:: beta :value: 0.0 .. py:attribute:: solver :value: 'MOSEK' .. py:attribute:: Ncond .. py:attribute:: ln_geom_mean .. py:attribute:: z2_scores .. py:attribute:: ln_lower_bound .. py:attribute:: ln_upper_bound .. py:attribute:: total_z2_scores .. py:property:: driving_forces :type: cvxpy.Expression Calculates the driving forces of all reactions. .. py:property:: ln_kcatr :type: cvxpy.Expression Calculate the kcat-reverse based on Haldane relationship constraint. .. py:property:: ln_eta_thermodynamic :type: cvxpy.Expression Calculate the thermodynamic term of the enzyme :math:`\eta^{thr}`. .. py:property:: ln_eta_kinetic :type: cvxpy.Expression Calculate the kinetic (saturation) term of the enzyme :math:`\eta^{kin}`. .. py:property:: ln_eta_regulation :type: cvxpy.Expression Calculate the regulation (allosteric) term of the enzyme :math:`\eta^{reg}`. .. py:property:: ln_conc_enz :type: cvxpy.Expression Calculate the required enzyme levels based on fluxes and rate laws. .. py:method:: penalty_term_beta(ln_Km: Union[numpy.array, cvxpy.Expression], ln_conc_met: Union[numpy.array, cvxpy.Expression]) -> cvxpy.Expression Calculate the penalty term for c/Km. .. py:method:: is_gmean_feasible() -> bool Check if the gmean is a thermodynamically feasible solution. This is useful because we sometimes would like to initialize the optimization with the geometric means, but that can only be done if that point is feasible (otherwise, the dependent parameter conc_enz is not defined). .. py:method:: initialize_with_gmeans() -> None Initialize the independent parameters with their gmeans. Note that the dependent parameters (kcatr and ln_conc_enz) can both be very far from their gmeans, and that the system might not be thermodynamically feasible. .. py:method:: solve(verbose: bool = False) -> str Use CVXPY to find the global optimum that minimizes all z-scores. .. py:method:: find_inner_point(verbose: bool = False) -> Any Find a point insize the feasible thermodynamic space. If the geometric mean is not a feasible solution, we will need this function in order to initialize the solver with a point inside the thermodynamically feasible space. .. py:property:: objective_value :type: float Get the objective value (i.e. the sum of squares of all z-scores). .. py:method:: get_z_scores() -> Dict[str, numpy.array] .. py:method:: print_z_scores(precision: int = 2) -> None Print the z-score values for all variables. .. py:method:: print_status() -> None Print a status report based on the current solution. .. py:method:: to_state_sbtab() -> sbtab.SBtab.SBtabDocument Create a state SBtab. The state SBtab contains the values of the state-dependent variables, i.e. flux, concentrations of metabolites, concentrations of enzymes, and the ΔG' values. .. py:method:: to_model_sbtab() -> sbtab.SBtab.SBtabDocument Create a model SBtab. The model SBtab contains the values of the state-independent variables, i.e. kcatf, kcatr, Km, Ka, and Ki.