From 3118683b93e9229e03536197889c6ecc959392e5 Mon Sep 17 00:00:00 2001 From: blakeaw Date: Tue, 17 Oct 2023 18:34:42 -0500 Subject: [PATCH] Updated the dose_absorbed macro to use a precursor and first order reaction rule instead of an expression. --- src/pysb/pkpd/macros.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/pysb/pkpd/macros.py b/src/pysb/pkpd/macros.py index e3878ea..8d87ac5 100644 --- a/src/pysb/pkpd/macros.py +++ b/src/pysb/pkpd/macros.py @@ -1135,6 +1135,9 @@ def absorb_name_func(rule_expression): return "_".join([monomer_name, comp_name]) species = _check_for_monomer(species, compartment) + precursor_name = "{}_{}_precursor".format(monomer_name, comp_name) + precursor = Monomer(precursor_name) + monomers = ComponentSet([precursor]) params_created = ComponentSet() Dose = dose Vcomp = compartment.size @@ -1152,13 +1155,13 @@ def absorb_name_func(rule_expression): if not isinstance(f, Parameter): F = Parameter("F_{0}_{1}".format(monomer_name, comp_name), f) params_created.add(F) - obs_expr = Observable( - "_obs_ka_expr_{0}_{1}".format(monomer_name, comp_name), species - ) - rate_expr = Expression("expr_{0}_{1}_absorb_rate".format(monomer_name, comp_name), (dose_expr - obs_expr) * (F * ka_param) / Vcomp) - params_created.add(rate_expr) + pre_0_expr = Expression('precursor_0', (dose_expr * F)) + init_pre = Initial(precursor()**compartment, pre_0_expr) + #components.add(init_pre) + #rate_expr = Expression("expr_{0}_{1}_absorb_rate".format(monomer_name, comp_name), (dose_expr - obs_expr) * (F * ka_param) / Vcomp) + #params_created.add(rate_expr) - components = pysb.macros._macro_rule('absorb', None >> species, [rate_expr], ['ka'], + components = pysb.macros._macro_rule('absorb', precursor()**compartment >> species, [ka], ['ka'], name_func=absorb_name_func) - - return components | params_created \ No newline at end of file + + return components | params_created | monomers \ No newline at end of file