Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMICI does not handle conditions for parameters governed by rate rules #1750

Closed
matthiaskoenig opened this issue Mar 30, 2022 · 2 comments · Fixed by #1753
Closed

AMICI does not handle conditions for parameters governed by rate rules #1750

matthiaskoenig opened this issue Mar 30, 2022 · 2 comments · Fixed by #1753
Labels
enhancement PEtab PEtab-import related SBML SBML import related

Comments

@matthiaskoenig
Copy link

Hi all,
trying to load the attached PETab problem

icg_petab_v2.zip

but getting the following error.

amici.sbml_import.SBMLException: Cannot turn parameter IVDOSE_icg into a constant/fixed parameter since it either has an initial assignment or is the target of an assignment or rate rule.

This is a simple model which has the following rate rule

dIVDOSE_idg/dt = -iv_icg*Mr_icg + Ri_icg

As part of my conditions I want to set IVDOSE_icg[t=0] = value. I assume you handle parameters different then species and compartments, but this is not correct. You have to split the set of parameters in constant parameters and parameters governed by rate rules. Parameters governed by rate rules are just state variables in the ODE and everything which is allowed for species state variables and compartment state variables must also work for parameter state variables!

I.e. the more correct way for the condition table description in
https://petab.readthedocs.io/en/latest/documentation_data_format.html#condition-table
should be

The condition table specifies constant parameters, or initial values of species, compartments or parameters for specific simulation conditions (generally corresponding to different experimental conditions).

instead of

The condition table specifies parameters, or initial values of species and compartments for specific simulation conditions (generally corresponding to different experimental conditions).

Could you please support the setting of initial conditions for parameters governed by rate rules? This mathematical construct occurs in many models and it would be completely unnatural to encode such parameters as dummy species or compartments just to get PETab to work.

Code example with full error stack below.

# Import yaml
petab_problem = petab.Problem.from_yaml(yaml_file)

# compile the petab problem to an AMICI ODE model
amici_model = amici.petab_import.import_petab_problem(petab_problem)

results in

/home/mkoenig/.virtualenvs/pkdb_models/bin/python /home/mkoenig/git/pkdb_models/pkdb_models/models/icg/fit_petab/icg_amici.py
2022-03-30 16:59:37.272 - amici.petab_import - INFO - Importing model ...
2022-03-30 16:59:37.273 - amici.petab_import - INFO - Model name is 'icg_body'.
Writing model code to '/home/mkoenig/git/pkdb_models/pkdb_models/models/icg/fit_petab/amici_models/icg_body'.
2022-03-30 16:59:37.274 - amici.petab_import - INFO - Species: 12
2022-03-30 16:59:37.274 - amici.petab_import - INFO - Global parameters: 75
2022-03-30 16:59:37.274 - amici.petab_import - INFO - Reactions: 16
2022-03-30 16:59:37.329 - amici.petab_import - INFO - Observables: 5
2022-03-30 16:59:37.329 - amici.petab_import - INFO - Sigmas: 5
2022-03-30 16:59:37.333 - amici.petab_import - DEBUG - Adding output parameters to model: OrderedDict([('noiseParameter1_Cve_icg', None), ('noiseParameter1_Chv_icg', None), ('noiseParameter1_Car_icg', None), ('noiseParameter1_ER_icg', None), ('noiseParameter1_LI__ICGLI2BI', None)])
2022-03-30 16:59:37.333 - amici.petab_import - DEBUG - Adding initial assignments for []
2022-03-30 16:59:37.333 - amici.petab_import - DEBUG - Condition table: (16, 5)
2022-03-30 16:59:37.333 - amici.petab_import - DEBUG - Fixed parameters are ['BW', 'Ri_icg', 'IVDOSE_icg']
2022-03-30 16:59:37.333 - amici.petab_import - INFO - Overall fixed parameters: 3
2022-03-30 16:59:37.333 - amici.petab_import - INFO - Variable parameters: 77
2022-03-30 16:59:37.390 - amici.sbml_import - INFO - Finished gathering local SBML symbols       ++ (5.58E-02s)
Traceback (most recent call last):
  File "/home/mkoenig/git/pkdb_models/pkdb_models/models/icg/fit_petab/icg_amici.py", line 28, in <module>
    amici_model = amici.petab_import.import_petab_problem(petab_problem)
  File "/home/mkoenig/.virtualenvs/pkdb_models/lib/python3.9/site-packages/amici/petab_import.py", line 305, in import_petab_problem
    import_model_sbml(
  File "/home/mkoenig/.virtualenvs/pkdb_models/lib/python3.9/site-packages/amici/logging.py", line 194, in wrapper_timer
    rval = func(*args, **kwargs)
  File "/home/mkoenig/.virtualenvs/pkdb_models/lib/python3.9/site-packages/amici/petab_import.py", line 579, in import_model_sbml
    sbml_importer.sbml2amici(
  File "/home/mkoenig/.virtualenvs/pkdb_models/lib/python3.9/site-packages/amici/sbml_import.py", line 358, in sbml2amici
    self._process_sbml(constant_parameters)
  File "/home/mkoenig/.virtualenvs/pkdb_models/lib/python3.9/site-packages/amici/logging.py", line 194, in wrapper_timer
    rval = func(*args, **kwargs)
  File "/home/mkoenig/.virtualenvs/pkdb_models/lib/python3.9/site-packages/amici/sbml_import.py", line 408, in _process_sbml
    self._process_parameters(constant_parameters)
  File "/home/mkoenig/.virtualenvs/pkdb_models/lib/python3.9/site-packages/amici/logging.py", line 194, in wrapper_timer
    rval = func(*args, **kwargs)
  File "/home/mkoenig/.virtualenvs/pkdb_models/lib/python3.9/site-packages/amici/sbml_import.py", line 845, in _process_parameters
    raise SBMLException(
amici.sbml_import.SBMLException: Cannot turn parameter IVDOSE_icg into a constant/fixed parameter since it either has an initial assignment or is the target of an assignment or rate rule.

Process finished with exit code 1
@dweindl
Copy link
Member

dweindl commented Mar 30, 2022

Hi Matthias, thanks for reporting. Agreed that it should work as you expected. We'll fix that.

@matthiaskoenig
Copy link
Author

@dweindl thanks

@dweindl dweindl added enhancement PEtab PEtab-import related SBML SBML import related and removed new Newly created labels Apr 7, 2022
@dweindl dweindl linked a pull request Apr 7, 2022 that will close this issue
@dweindl dweindl closed this as completed in 8d19766 Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement PEtab PEtab-import related SBML SBML import related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants