diff --git a/xbanalysis/_version.py b/xbanalysis/_version.py index 88646c942b503d2d5b6382a0b91033a5ed23f740..8c2bc5ba96bd3e6284170b1f64898e2a465c39bb 100644 --- a/xbanalysis/_version.py +++ b/xbanalysis/_version.py @@ -1,5 +1,5 @@ """ Definition of version string. """ -__version__ = "0.3.1" +__version__ = "0.3.2" program_name = 'xbanalysis' diff --git a/xbanalysis/problems/gba_problem.py b/xbanalysis/problems/gba_problem.py index ee305403a886caa00653a25a65dfd46daa72072a..0e5dba8508b7c232a21394628971250621b85e7b 100644 --- a/xbanalysis/problems/gba_problem.py +++ b/xbanalysis/problems/gba_problem.py @@ -110,14 +110,63 @@ class GbaProblem: self.model_params['mws'] = np.array([xba_model.species[sid].mw for sid in self.var_sids]) # create functions - self.mras, self.mras_jac, self.mras_hesss = self.get_reactions(self.mr_rids, inv=False) - self.pstmas, self.pstmas_jac, self.pstmas_hesss = self.get_reactions(self.ps_rids, inv=True) - self.degradas, self.degradas_jac, self.degradas_hesss = self.get_reactions(enz_degrad_rids, inv=False) - self.enz_transas, self.enz_transas_jac, self.enz_transas_hesss = self.get_reactions(enz_trans_rids, inv=False) + self.fmras, self.fmras_jac, self.fmras_hesss = self.get_reactions(self.mr_rids, inv=False) + self.fpstmas, self.fpstmas_jac, self.fpstmas_hesss = self.get_reactions(self.ps_rids, inv=True) + self.fdegradas, self.fdegradas_jac, self.fdegradas_hesss = self.get_reactions(enz_degrad_rids, inv=False) + self.fenz_tras, self.fenz_tras_jac, self.fenz_tras_hesss = self.get_reactions(enz_trans_rids, inv=False) self.n_constraints = {'heq_mass_balance': len(self.var_metab_sids), 'heq_enz_trans': self.subenz_x_trans.shape[0], 'heq_density': 1} + # TODO implement a factory method + @cache_last + def mras(self, x): + return self.fmras(x) + + @cache_last + def mras_jac(self, x): + return self.fmras_jac(x) + + @cache_last + def mras_hesss(self, x): + return self.fmras_hesss(x) + + @cache_last + def pstmas(self, x): + return self.fpstmas(x) + + @cache_last + def pstmas_jac(self, x): + return self.fpstmas_jac(x) + + @cache_last + def pstmas_hesss(self, x): + return self.fpstmas_hesss(x) + + @cache_last + def degradas(self, x): + return self.fdegradas(x) + + @cache_last + def degradas_jac(self, x): + return self.fdegradas_jac(x) + + @cache_last + def degradas_hesss(self, x): + return self.fdegradas_hesss(x) + + @cache_last + def enz_tras(self, x): + return self.fenz_tras(x) + + @cache_last + def enz_tras_jac(self, x): + return self.fenz_tras_jac(x) + + @cache_last + def enz_tras_hesss(self, x): + return self.fenz_tras_hesss(x) + def get_stoic_matrix(self, sids, rids): """retrieve stoichiometric sub-matrix [sids x rids]. @@ -640,7 +689,7 @@ class GbaProblem: :returns: Jacobian of mass balance equations at x :rtype: numpy.ndarray (1D) with shape (len(subenz_x_trans.shape[1]), 1) """ - return self.subenz_x_trans.dot(self.enz_transas(x)) + return self.subenz_x_trans.dot(self.enz_tras(x)) @cache_last def heq_enz_trans_jac(self, x): @@ -651,7 +700,7 @@ class GbaProblem: :returns: Jacobian of mass balance equations at x :rtype: numpy.ndarray (2D) """ - return self.subenz_x_trans.dot(self.enz_transas_jac(x)) + return self.subenz_x_trans.dot(self.enz_tras_jac(x)) @cache_last def heq_enz_trans_hess(self, x): @@ -662,7 +711,7 @@ class GbaProblem: :returns: Hessians of mass balance equations at x :rtype: numpy.ndarray (3D) with shape [n,x,x] """ - return np.array([(row.reshape((-1, 1, 1)) * self.enz_transas_hesss(x)).sum(axis=0) + return np.array([(row.reshape((-1, 1, 1)) * self.enz_tras_hesss(x)).sum(axis=0) for row in self.subenz_x_trans]) @cache_last