Skip to content

Commit

Permalink
Updated the dose_absorbed macro to use a precursor and first order re…
Browse files Browse the repository at this point in the history
…action rule instead of an expression.
  • Loading branch information
blakeaw committed Oct 17, 2023
1 parent b28ee8e commit 3118683
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/pysb/pkpd/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
return components | params_created | monomers

0 comments on commit 3118683

Please sign in to comment.