diff --git a/.github/workflows/test_petab_test_suite.yml b/.github/workflows/test_petab_test_suite.yml index df188e7abe..9b48f21d95 100644 --- a/.github/workflows/test_petab_test_suite.yml +++ b/.github/workflows/test_petab_test_suite.yml @@ -72,7 +72,7 @@ jobs: run: | source ./build/venv/bin/activate \ && pytest --cov-report=xml:coverage.xml \ - --cov=./ python/tests/test_*petab*.py + --cov=./ python/tests/test_*petab*.py python/tests/petab/ # run test models - name: Run PEtab test suite diff --git a/python/examples/example_petab/petab.ipynb b/python/examples/example_petab/petab.ipynb index 3e8c523829..afc4b2a38e 100644 --- a/python/examples/example_petab/petab.ipynb +++ b/python/examples/example_petab/petab.ipynb @@ -6,303 +6,90 @@ "source": [ "# Using PEtab\n", "\n", - "This notebook illustrates how to use [PEtab](https://github.com/petab-dev/petab) with AMICI." + "This notebook illustrates how to run model simulations based on [PEtab](https://github.com/petab-dev/petab) problems with AMICI.\n", + "\n", + "PEtab is a format for specifying parameter estimation problems in systems biology. It is based on [SBML](http://sbml.org/) and [TSV](https://en.wikipedia.org/wiki/Tab-separated_values) files. (AMICI also supports PySB-based PEtab problems, that will be covered by PEtab v2). The Python package [pyPESTO](https://pypesto.readthedocs.io/) provides a convenient interface for parameter estimation with PEtab problems and uses AMICI as a backend. However, AMICI can also be used directly to simulate PEtab problems. This is illustrated in this notebook." ] }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "from amici.petab.petab_import import import_petab_problem\n", - "from amici.petab.simulations import simulate_petab\n", "import petab\n", "\n", - "import os" + "from amici import runAmiciSimulation\n", + "from amici.petab.petab_import import import_petab_problem\n", + "from amici.petab.petab_problem import PetabProblem\n", + "from amici.petab.simulations import simulate_petab\n", + "from amici.plotting import plot_state_trajectories" ] }, { "cell_type": "markdown", - "metadata": {}, "source": [ - "We use an example model from the [benchmark collection](https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab):" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Cloning into 'tmp/benchmark-models'...\n", - "remote: Enumerating objects: 142, done.\u001B[K\n", - "remote: Counting objects: 100% (142/142), done.\u001B[K\n", - "remote: Compressing objects: 100% (122/122), done.\u001B[K\n", - "remote: Total 142 (delta 41), reused 104 (delta 18), pack-reused 0\u001B[K\n", - "Receiving objects: 100% (142/142), 648.29 KiB | 1.23 MiB/s, done.\n", - "Resolving deltas: 100% (41/41), done.\n" - ] - } - ], - "source": [ - "!git clone --depth 1 https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab.git tmp/benchmark-models || (cd tmp/benchmark-models && git pull)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "total 68\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Alkan_SciSignal2018\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Beer_MolBioSystems2014\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Boehm_JProteomeRes2014\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Borghans_BiophysChem1997\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Brannmark_JBC2010\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Bruno_JExpBio2016\r\n", - "-rwxr-xr-x 1 yannik yannik 654 Mär 17 15:27 checkBenchmarkModels.py\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Chen_MSB2009\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Crauste_CellSystems2017\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Elowitz_Nature2000\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Fiedler_BMC2016\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Fujita_SciSignal2010\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Perelson_Science1996\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Rahman_MBS2016\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Sneyd_PNAS2002\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Weber_BMC2015\r\n", - "drwxr-xr-x 2 yannik yannik 4096 Mär 17 15:27 Zheng_PNAS2012\r\n" - ] - } + "## Importing a PEtab problem" ], - "source": [ - "folder_base = \"tmp/benchmark-models/Benchmark-Models/\"\n", - "!ls -l $folder_base" - ] + "metadata": { + "collapsed": false + } }, { "cell_type": "markdown", "metadata": {}, "source": [ - "We import a model to PEtab from a provided yaml file:" + "We use the [Boehm_JProteomeRes2014](https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab/tree/master/Benchmark-Models/Boehm_JProteomeRes2014) example model from the [benchmark collection](https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab):" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model_name = \"Boehm_JProteomeRes2014\"\n", - "yaml_file = os.path.join(folder_base, model_name, model_name + \".yaml\")\n", - "petab_problem = petab.Problem.from_yaml(yaml_file)" + "# local path or URL to the yaml file for the PEtab problem\n", + "petab_yaml = f\"https://raw.githubusercontent.com/Benchmarking-Initiative/Benchmark-Models-PEtab/master/Benchmark-Models/{model_name}/{model_name}.yaml\"\n", + "# load the problem using the PEtab library\n", + "petab_problem = petab.Problem.from_yaml(petab_yaml)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Next, we import the model to amici, compile it and obtain a function handle:" + "\n", + "Next, we import the model to amici using `import_petab_problem`. `import_petab_problem` has many options to choose between faster importer or more flexible or faster model simulations. We import the model with default settings, and we obtain an AMICI model instance:" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2020-03-17 15:27:27.586 - amici.petab_import - INFO - Importing model ...\n", - "2020-03-17 15:27:27.593 - amici.petab_import - INFO - Model name is 'Boehm_JProteomeRes2014'. Writing model code to '/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014'.\n", - "2020-03-17 15:27:27.598 - amici.petab_import - INFO - Species: 8\n", - "2020-03-17 15:27:27.599 - amici.petab_import - INFO - Global parameters: 9\n", - "2020-03-17 15:27:27.599 - amici.petab_import - INFO - Reactions: 9\n", - "2020-03-17 15:27:27.715 - amici.petab_import - INFO - Observables: 3\n", - "2020-03-17 15:27:27.715 - amici.petab_import - INFO - Sigmas: 3\n", - "2020-03-17 15:27:27.722 - amici.petab_import - DEBUG - Adding output parameters to model: OrderedDict([('noiseParameter1_pSTAT5A_rel', None), ('noiseParameter1_pSTAT5B_rel', None), ('noiseParameter1_rSTAT5A_rel', None)])\n", - "2020-03-17 15:27:27.725 - amici.petab_import - DEBUG - Condition table: (1, 1)\n", - "2020-03-17 15:27:27.726 - amici.petab_import - DEBUG - Fixed parameters are []\n", - "2020-03-17 15:27:27.728 - amici.petab_import - INFO - Overall fixed parameters: 0\n", - "2020-03-17 15:27:27.729 - amici.petab_import - INFO - Variable parameters: 12\n", - "2020-03-17 15:27:27.735 - amici.sbml_import - INFO - Finished processing SBML parameters (1.25E-03s)\n", - "2020-03-17 15:27:27.749 - amici.sbml_import - INFO - Finished processing SBML species (1.26E-02s)\n", - "2020-03-17 15:27:27.829 - amici.sbml_import - INFO - Finished processing SBML reactions (7.41E-02s)\n", - "2020-03-17 15:27:27.833 - amici.sbml_import - INFO - Finished processing SBML compartments (4.23E-04s)\n", - "2020-03-17 15:27:27.898 - amici.sbml_import - INFO - Finished processing SBML rules (6.47E-02s)\n", - "2020-03-17 15:27:28.012 - amici.sbml_import - INFO - Finished processing SBML observables (6.77E-02s)\n", - "2020-03-17 15:27:28.139 - amici.ode_export - INFO - Finished writing J.cpp (1.14E-01s)\n", - "2020-03-17 15:27:28.160 - amici.ode_export - INFO - Finished writing JB.cpp (2.04E-02s)\n", - "2020-03-17 15:27:28.167 - amici.ode_export - INFO - Finished writing JDiag.cpp (6.41E-03s)\n", - "2020-03-17 15:27:28.187 - amici.ode_export - INFO - Finished writing JSparse.cpp (1.91E-02s)\n", - "2020-03-17 15:27:28.217 - amici.ode_export - INFO - Finished writing JSparseB.cpp (2.73E-02s)\n", - "2020-03-17 15:27:28.236 - amici.ode_export - INFO - Finished writing Jy.cpp (1.65E-02s)\n", - "2020-03-17 15:27:28.344 - amici.ode_export - INFO - Finished writing dJydsigmay.cpp (1.07E-01s)\n", - "2020-03-17 15:27:28.389 - amici.ode_export - INFO - Finished writing dJydy.cpp (3.99E-02s)\n", - "2020-03-17 15:27:28.466 - amici.ode_export - INFO - Finished writing dwdp.cpp (7.61E-02s)\n", - "2020-03-17 15:27:28.473 - amici.ode_export - INFO - Finished writing dwdx.cpp (5.87E-03s)\n", - "2020-03-17 15:27:28.497 - amici.ode_export - INFO - Finished writing dxdotdw.cpp (2.32E-02s)\n", - "2020-03-17 15:27:28.533 - amici.ode_export - INFO - Finished writing dxdotdp_explicit.cpp (3.38E-02s)\n", - "2020-03-17 15:27:28.756 - amici.ode_export - INFO - Finished writing dydx.cpp (1.98E-01s)\n", - "2020-03-17 15:27:28.910 - amici.ode_export - INFO - Finished writing dydp.cpp (1.53E-01s)\n", - "2020-03-17 15:27:28.926 - amici.ode_export - INFO - Finished writing dsigmaydp.cpp (1.40E-02s)\n", - "2020-03-17 15:27:28.931 - amici.ode_export - INFO - Finished writing sigmay.cpp (2.46E-03s)\n", - "2020-03-17 15:27:28.950 - amici.ode_export - INFO - Finished writing w.cpp (1.55E-02s)\n", - "2020-03-17 15:27:28.967 - amici.ode_export - INFO - Finished writing x0.cpp (1.57E-02s)\n", - "2020-03-17 15:27:28.975 - amici.ode_export - INFO - Finished writing x0_fixedParameters.cpp (4.78E-03s)\n", - "2020-03-17 15:27:29.027 - amici.ode_export - INFO - Finished writing sx0.cpp (5.01E-02s)\n", - "2020-03-17 15:27:29.069 - amici.ode_export - INFO - Finished writing sx0_fixedParameters.cpp (3.14E-02s)\n", - "2020-03-17 15:27:29.104 - amici.ode_export - INFO - Finished writing xdot.cpp (3.43E-02s)\n", - "2020-03-17 15:27:29.129 - amici.ode_export - INFO - Finished writing y.cpp (2.16E-02s)\n", - "2020-03-17 15:27:29.136 - amici.ode_export - INFO - Finished writing x_rdata.cpp (4.95E-03s)\n", - "2020-03-17 15:27:29.138 - amici.ode_export - INFO - Finished writing total_cl.cpp (6.59E-04s)\n", - "2020-03-17 15:27:29.147 - amici.ode_export - INFO - Finished writing x_solver.cpp (7.72E-03s)\n", - "2020-03-17 15:27:29.166 - amici.ode_export - INFO - Finished generating cpp code (1.14E+00s)\n", - "2020-03-17 15:27:46.200 - amici.ode_export - INFO - Finished compiling cpp code (1.70E+01s)\n", - "2020-03-17 15:27:46.204 - amici.petab_import - INFO - Finished Importing PEtab model (1.86E+01s)\n", - "2020-03-17 15:27:46.209 - amici.petab_import - INFO - Successfully loaded model Boehm_JProteomeRes2014 from /home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "running build_ext\n", - "building 'Boehm_JProteomeRes2014._Boehm_JProteomeRes2014' extension\n", - "swigging swig/Boehm_JProteomeRes2014.i to swig/Boehm_JProteomeRes2014_wrap.cpp\n", - "swig -python -c++ -modern -outdir Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/swig -I/home/yannik/amici/python/sdist/amici/include -o swig/Boehm_JProteomeRes2014_wrap.cpp swig/Boehm_JProteomeRes2014.i\n", - "creating build\n", - "creating build/temp.linux-x86_64-3.7\n", - "creating build/temp.linux-x86_64-3.7/swig\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c swig/Boehm_JProteomeRes2014_wrap.cpp -o build/temp.linux-x86_64-3.7/swig/Boehm_JProteomeRes2014_wrap.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dxdotdw.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdw.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_total_cl.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_total_cl.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_x_rdata.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_x_rdata.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dxdotdp_implicit_colptrs.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdp_implicit_colptrs.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dsigmaydp.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dsigmaydp.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_y.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_y.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dydp.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dydp.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_w.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_w.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_JSparseB_rowvals.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JSparseB_rowvals.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dxdotdw_rowvals.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdw_rowvals.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dwdx_rowvals.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dwdx_rowvals.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_x0.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_x0.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dwdx.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dwdx.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dJydy_colptrs.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dJydy_colptrs.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_JSparseB.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JSparseB.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_JSparseB_colptrs.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JSparseB_colptrs.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dxdotdp_explicit_colptrs.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdp_explicit_colptrs.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_sx0_fixedParameters.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_sx0_fixedParameters.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_JSparse_rowvals.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JSparse_rowvals.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dxdotdp_explicit.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdp_explicit.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dJydy.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dJydy.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dwdp_colptrs.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dwdp_colptrs.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_x0_fixedParameters.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_x0_fixedParameters.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dxdotdw_colptrs.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdw_colptrs.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dJydsigmay.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dJydsigmay.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dxdotdp_implicit_rowvals.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdp_implicit_rowvals.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dwdp.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dwdp.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_sx0.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_sx0.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_JB.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JB.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dwdx_colptrs.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dwdx_colptrs.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c wrapfunctions.cpp -o build/temp.linux-x86_64-3.7/wrapfunctions.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_x_solver.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_x_solver.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_JSparse.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JSparse.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_xdot.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_xdot.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dJydy_rowvals.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dJydy_rowvals.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dwdp_rowvals.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dwdp_rowvals.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_JSparse_colptrs.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JSparse_colptrs.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_J.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_J.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dydx.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dydx.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_JDiag.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JDiag.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_Jy.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_Jy.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_sigmay.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_sigmay.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "gcc -pthread -B /home/yannik/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014 -I/home/yannik/amici/python/sdist/amici/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/gsl -I/home/yannik/amici/python/sdist/amici/ThirdParty/sundials/include -I/home/yannik/amici/python/sdist/amici/ThirdParty/SuiteSparse/include -I/usr/include/hdf5/serial -I/home/yannik/anaconda3/include/python3.7m -c Boehm_JProteomeRes2014_dxdotdp_explicit_rowvals.cpp -o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdp_explicit_rowvals.o -std=c++14\n", - "cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++\n", - "g++ -pthread -shared -B /home/yannik/anaconda3/compiler_compat -L/home/yannik/anaconda3/lib -Wl,-rpath=/home/yannik/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.7/swig/Boehm_JProteomeRes2014_wrap.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdw.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_total_cl.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_x_rdata.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdp_implicit_colptrs.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dsigmaydp.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_y.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dydp.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_w.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JSparseB_rowvals.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdw_rowvals.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dwdx_rowvals.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_x0.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dwdx.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dJydy_colptrs.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JSparseB.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JSparseB_colptrs.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdp_explicit_colptrs.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_sx0_fixedParameters.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JSparse_rowvals.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdp_explicit.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dJydy.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dwdp_colptrs.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_x0_fixedParameters.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdw_colptrs.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dJydsigmay.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdp_implicit_rowvals.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dwdp.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_sx0.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JB.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dwdx_colptrs.o build/temp.linux-x86_64-3.7/wrapfunctions.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_x_solver.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JSparse.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_xdot.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dJydy_rowvals.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dwdp_rowvals.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JSparse_colptrs.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_J.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dydx.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_JDiag.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_Jy.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_sigmay.o build/temp.linux-x86_64-3.7/Boehm_JProteomeRes2014_dxdotdp_explicit_rowvals.o -L/usr/lib/x86_64-linux-gnu/hdf5/serial -L/home/yannik/amici/python/sdist/amici/libs -lamici -lsundials -lsuitesparse -lcblas -lhdf5_hl_cpp -lhdf5_hl -lhdf5_cpp -lhdf5 -o /home/yannik/amici/python/examples/amici_models/Boehm_JProteomeRes2014/Boehm_JProteomeRes2014/_Boehm_JProteomeRes2014.cpython-37m-x86_64-linux-gnu.so\n" - ] - } - ], + "outputs": [], "source": [ - "amici_model = import_petab_problem(petab_problem)" + "amici_model = import_petab_problem(petab_problem, verbose=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "That's it. Now, we can use the model to perform simulations. For more involved purposes, consider using the objective function provided by [pyPESTO](https://github.com/icb-dcm/pypesto). For simple simulations, a function `simulate_petab` is available:" + "That's it. Now, we can use the model to perform simulations.\n", + "\n", + "## Simulating a PEtab problem\n", + "\n", + "For simple simulations, a function `simulate_petab` is available. This function will simulate the model for all conditions specified in the PEtab problem and compute the objective value (and if requested, the gradient). `simulate_petab` is mostly useful for running individual simulations. If large numbers of model simulations are required, there are more efficient means. In particular, for parameter estimation, consider using the optimized objective function provided by [pyPESTO](https://github.com/icb-dcm/pypesto).\n", + "\n", + "We use the `simulate_petab` function to simulate the model at the nominal parameters (i.e., the parameters specified in the PEtab problem in the `nominalValue` column of the parameter table):" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'llh': -138.22199570334107,\n", - " 'sllh': None,\n", - " 'rdatas': []}" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "simulate_petab(petab_problem, amici_model)" ] @@ -311,31 +98,21 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This performs a simulation at the nominal parameters. Parameters can also be directly specified, both scaled and unscaled:" + " Parameters can also be directly specified, both scaled and unscaled:" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'llh': -138.22199570334107,\n", - " 'sllh': None,\n", - " 'rdatas': []}" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "parameters = {\n", " x_id: x_val\n", " for x_id, x_val in zip(petab_problem.x_ids, petab_problem.x_nominal_scaled)\n", + " # Fixed parameters cannot be changed in `simulate_petab`, unless we explicitly pass\n", + " # a `parameter_mapping` that was generated with `fill_fixed_parameters=False`\n", + " if x_id not in amici_model.getFixedParameterIds()\n", "}\n", "simulate_petab(\n", " petab_problem,\n", @@ -349,8 +126,60 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "For further information, see the [documentation](https://amici.readthedocs.io/en/latest/)." + "## Working with PEtab-defined simulation conditions\n", + "\n", + "`simulate_petab` is convenient for quickly simulating PEtab-based problems, but for certain applications it may be too inflexible.\n", + "For example, it is not easily possible to obtain model outputs for time points other than the measurement timepoints specified in the PEtab problem. In such a case, the `PetabProblem` class can be used to easily generate AMICI `ExpData` objects representing PEtab-defined simulation conditions:" ] + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "app = PetabProblem(petab_problem)\n", + "\n", + "# ExpData for all conditions:\n", + "app.get_edatas()\n", + "\n", + "# ExpData for a single condition:\n", + "edata = app.get_edata(\"model1_data1\")" + ], + "metadata": { + "collapsed": false + }, + "execution_count": null + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "rdata = runAmiciSimulation(amici_model, solver=amici_model.getSolver(), edata=edata)\n", + "rdata" + ], + "metadata": { + "collapsed": false + }, + "execution_count": null + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "plot_state_trajectories(rdata)" + ], + "metadata": { + "collapsed": false + }, + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "For further information, check out the [AMICI documentation](https://amici.readthedocs.io/en/latest/)." + ], + "metadata": { + "collapsed": false + } } ], "metadata": { diff --git a/python/sdist/amici/petab/conditions.py b/python/sdist/amici/petab/conditions.py index 3347b35ab8..34dd44cbcb 100644 --- a/python/sdist/amici/petab/conditions.py +++ b/python/sdist/amici/petab/conditions.py @@ -396,7 +396,11 @@ def create_edatas( if PREEQUILIBRATION_CONDITION_ID in simulation_conditions: measurement_groupvar.append(petab.PREEQUILIBRATION_CONDITION_ID) measurement_dfs = dict( - list(petab_problem.measurement_df.groupby(measurement_groupvar)) + list( + petab_problem.measurement_df.fillna( + {PREEQUILIBRATION_CONDITION_ID: ""} + ).groupby(measurement_groupvar) + ) ) edatas = [] @@ -405,10 +409,11 @@ def create_edatas( if PREEQUILIBRATION_CONDITION_ID in condition: measurement_index = ( condition.get(SIMULATION_CONDITION_ID), - condition.get(PREEQUILIBRATION_CONDITION_ID), + condition.get(PREEQUILIBRATION_CONDITION_ID) or "", ) else: measurement_index = (condition.get(SIMULATION_CONDITION_ID),) + edata = create_edata_for_condition( condition=condition, amici_model=amici_model, diff --git a/python/sdist/amici/petab/petab_problem.py b/python/sdist/amici/petab/petab_problem.py new file mode 100644 index 0000000000..8ea177ad03 --- /dev/null +++ b/python/sdist/amici/petab/petab_problem.py @@ -0,0 +1,275 @@ +"""PEtab-problem based simulations.""" +import copy +from typing import Optional, Union + +import amici +import pandas as pd +import petab +from petab.C import PREEQUILIBRATION_CONDITION_ID, SIMULATION_CONDITION_ID + +from .conditions import create_edatas, fill_in_parameters +from .parameter_mapping import create_parameter_mapping + + +class PetabProblem: + """Manage experimental conditions based on a PEtab problem definition. + + Create :class:`ExpData` objects from a PEtab problem definition, and handle + parameter scales and parameter mapping. + + :param petab_problem: PEtab problem definition. + :param amici_model: AMICI model + :param problem_parameters: Problem parameters to use for simulation + (default: PEtab nominal values and model values). + :param scaled_parameters: Whether the provided parameters are on PEtab + `parameterScale` or not. + :param simulation_conditions: Simulation conditions to use for simulation. + It can be used to subset the conditions in the PEtab problem. + All subsequent operations will only be performed on that subset. + By default, all conditions are used. + :param store_edatas: Whether to create and store all `ExpData` objects for + all conditions upfront. If set to ``False``, `ExpData` objects will be + created and disposed of on the fly during simulation. The latter saves + memory if the given PEtab problem comprises many simulation conditions. + """ + + def __init__( + self, + petab_problem: petab.Problem, + amici_model: Optional[amici.Model] = None, + problem_parameters: Optional[dict[str, float]] = None, + scaled_parameters: bool = False, + simulation_conditions: Union[pd.DataFrame, list[dict]] = None, + store_edatas: bool = True, + ): + self._petab_problem = copy.deepcopy(petab_problem) + + if amici_model is not None: + self._amici_model = amici_model + else: + from .petab_import import import_petab_problem + + self._amici_model = import_petab_problem(petab_problem) + + self._scaled_parameters = scaled_parameters + + self._simulation_conditions = simulation_conditions or ( + petab_problem.get_simulation_conditions_from_measurement_df() + ) + if not isinstance(self._simulation_conditions, pd.DataFrame): + self._simulation_conditions = pd.DataFrame( + self._simulation_conditions + ) + if ( + preeq_id := PREEQUILIBRATION_CONDITION_ID + ) in self._simulation_conditions: + self._simulation_conditions[ + preeq_id + ] = self._simulation_conditions[preeq_id].fillna("") + + if problem_parameters is None: + # Use PEtab nominal values as default + self._problem_parameters = self._default_parameters() + if scaled_parameters: + raise NotImplementedError( + "scaled_parameters=True in combination with default " + "parameters is not implemented yet." + ) + else: + self._problem_parameters = problem_parameters + + if store_edatas: + self._parameter_mapping = create_parameter_mapping( + petab_problem=self._petab_problem, + simulation_conditions=self._simulation_conditions, + scaled_parameters=self._scaled_parameters, + amici_model=self._amici_model, + ) + self._create_edatas() + else: + self._parameter_mapping = None + self._edatas = None + + def set_parameters( + self, + problem_parameters: dict[str, float], + scaled_parameters: bool = False, + ): + """Set problem parameters. + + :param problem_parameters: Problem parameters to use for simulation. + This may be a subset of all parameters. + :param scaled_parameters: Whether the provided parameters are on PEtab + `parameterScale` or not. + """ + if scaled_parameters != self._scaled_parameters and self._parameter_mapping is not None: + # redo parameter mapping if scale changed + self._parameter_mapping = create_parameter_mapping( + petab_problem=self._petab_problem, + simulation_conditions=self._simulation_conditions, + scaled_parameters=scaled_parameters, + amici_model=self._amici_model, + ) + + if set(self._problem_parameters) - set(problem_parameters): + # not all parameters are provided - update + # bring previously set parameters to the same scale if necessary + if scaled_parameters and not self._scaled_parameters: + self._problem_parameters = ( + self._petab_problem.scale_parameters( + self._problem_parameters, + ) + ) + elif not scaled_parameters and self._scaled_parameters: + self._problem_parameters = ( + self._petab_problem.unscale_parameters( + self._problem_parameters, + ) + ) + self._problem_parameters |= problem_parameters + else: + self._problem_parameters = problem_parameters + + self._scaled_parameters = scaled_parameters + + if self._edatas: + fill_in_parameters( + edatas=self._edatas, + problem_parameters=self._problem_parameters, + scaled_parameters=self._scaled_parameters, + parameter_mapping=self._parameter_mapping, + amici_model=self._amici_model, + ) + + def get_edata( + self, condition_id: str, preequilibration_condition_id: str = None + ) -> amici.ExpData: + """Get ExpData object for a given condition. + + NOTE: If ``store_edatas=True`` was passed to the constructor and the + returned object is modified, the changes will be reflected in the + internal `ExpData` objects. Also, if parameter values of + `PetabProblem` are changed, all `ExpData` objects will be updated. + Create a deep copy if you want to avoid this. + + :param condition_id: PEtab condition ID + :param preequilibration_condition_id: PEtab preequilibration condition ID + :return: ExpData object + """ + # exists or has to be created? + if self._edatas: + edata_id = condition_id + if preequilibration_condition_id: + edata_id += "+" + preequilibration_condition_id + + for edata in self._edatas: + if edata.id == edata_id: + return edata + + return self._create_edata(condition_id, preequilibration_condition_id) + + def get_edatas(self): + """Get all ExpData objects. + + NOTE: If ``store_edatas=True`` was passed to the constructor and the + returned objects are modified, the changes will be reflected in the + internal `ExpData` objects. Also, if parameter values of + `PetabProblem` are changed, all `ExpData` objects will be updated. + Create a deep copy if you want to avoid this. + + :return: List of ExpData objects + """ + if self._edatas: + # shallow copy + return self._edatas.copy() + + # not storing edatas - create and return + self._parameter_mapping = create_parameter_mapping( + petab_problem=self._petab_problem, + simulation_conditions=self._simulation_conditions, + scaled_parameters=self._scaled_parameters, + amici_model=self._amici_model, + ) + self._create_edatas() + result = self._edatas + self._edatas = [] + return result + + def _create_edata( + self, condition_id: str, preequilibration_condition_id: str + ) -> amici.ExpData: + """Create ExpData object for a given condition. + + :param condition_id: PEtab condition ID + :param preequilibration_condition_id: PEtab preequilibration condition ID + :return: ExpData object + """ + simulation_condition = pd.DataFrame( + [ + { + SIMULATION_CONDITION_ID: condition_id, + PREEQUILIBRATION_CONDITION_ID: preequilibration_condition_id + or None, + } + ] + ) + edatas = create_edatas( + amici_model=self._amici_model, + petab_problem=self._petab_problem, + simulation_conditions=simulation_condition, + ) + parameter_mapping = create_parameter_mapping( + petab_problem=self._petab_problem, + simulation_conditions=simulation_condition, + scaled_parameters=self._scaled_parameters, + amici_model=self._amici_model, + ) + + # Fill parameters in ExpDatas (in-place) + fill_in_parameters( + edatas=edatas, + problem_parameters={ + p: self._problem_parameters[p] + for p in parameter_mapping.free_symbols + if p in self._problem_parameters + }, + scaled_parameters=self._scaled_parameters, + parameter_mapping=parameter_mapping, + amici_model=self._amici_model, + ) + + if len(edatas) != 1: + raise AssertionError("Expected exactly one ExpData object.") + return edatas[0] + + def _create_edatas( + self, + ): + """Create ExpData objects from PEtab problem definition.""" + self._edatas = create_edatas( + amici_model=self._amici_model, + petab_problem=self._petab_problem, + simulation_conditions=self._simulation_conditions, + ) + + fill_in_parameters( + edatas=self._edatas, + problem_parameters=self._problem_parameters, + scaled_parameters=self._scaled_parameters, + parameter_mapping=self._parameter_mapping, + amici_model=self._amici_model, + ) + + def _default_parameters(self) -> dict[str, float]: + """Get unscaled default parameters.""" + return { + t.Index: getattr(t, petab.NOMINAL_VALUE) + for t in self._petab_problem.parameter_df[ + self._petab_problem.parameter_df[petab.ESTIMATE] == 1 + ].itertuples() + } + + @property + def model(self) -> amici.Model: + """AMICI model.""" + return self._amici_model diff --git a/python/sdist/setup.cfg b/python/sdist/setup.cfg index 5ae8e1e742..bf0e61cdd5 100644 --- a/python/sdist/setup.cfg +++ b/python/sdist/setup.cfg @@ -46,6 +46,7 @@ zip_safe = False petab = petab>=0.2.1 pysb = pysb>=1.13.1 test = + benchmark_models_petab @ git+https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab.git@master#subdirectory=src/python h5py pytest pytest-cov diff --git a/python/tests/petab/test_petab_problem.py b/python/tests/petab/test_petab_problem.py new file mode 100644 index 0000000000..7b5ee1ca08 --- /dev/null +++ b/python/tests/petab/test_petab_problem.py @@ -0,0 +1,83 @@ +from amici.petab.petab_problem import PetabProblem +from benchmark_models_petab import get_problem + + +def test_amici_petab_problem_pregenerate(): + """PetabProblem with pre-generated ExpDatas""" + # any example is fine - the only assumption is that we don't have + # preequilibration + petab_problem = get_problem("Boehm_JProteomeRes2014") + app = PetabProblem(petab_problem, store_edatas=True) + + # ensure all edatas are generated upon construction + assert len(app._edatas) == len( + petab_problem.get_simulation_conditions_from_measurement_df() + ) + + # ensure the cached edatas are returned + for i, (_, condition) in enumerate( + petab_problem.get_simulation_conditions_from_measurement_df().iterrows() + ): + assert app.get_edata(condition.simulationConditionId) is app._edatas[i] + + # ensure parameter are updated + edatas = app.get_edatas() + app.set_parameters( + {app.model.getParameterIds()[0]: 0.12345}, scaled_parameters=True + ) + for edata in edatas: + assert edata.parameters[0] == 0.12345 + + +def test_amici_petab_problem_on_demand(): + """PetabProblem with on-demand ExpDatas""" + # any example is fine - the only assumption is that we don't have + # preequilibration + petab_problem = get_problem("Boehm_JProteomeRes2014") + app = PetabProblem(petab_problem, store_edatas=False) + + # ensure no edatas are generated upon construction + assert not app._edatas + + edatas = app.get_edatas() + assert len(edatas) == len( + petab_problem.get_simulation_conditions_from_measurement_df() + ) + + # ensure parameter are updated + app.set_parameters( + {app.model.getParameterIds()[0]: 0.12345}, scaled_parameters=True + ) + # previously generated ExpDatas are not updated + for edata in edatas: + assert edata.parameters[0] != 0.12345 + # but newly generated ExpDatas are + for edata in app.get_edatas(): + assert edata.parameters[0] == 0.12345 + + some_sim_condition = ( + petab_problem.measurement_df.simulationConditionId.iloc[0] + ) + # different objects for subsequent calls + assert app.get_edata(some_sim_condition) is not app.get_edata( + some_sim_condition + ) + + +def test_amici_petab_problem_pregenerate_equals_on_demand(): + """Check that PetabProblem produces the same ExpDatas + independent of the `store_edatas` parameter.""" + # any example is fine + petab_problem = get_problem("Boehm_JProteomeRes2014") + app_store_true = PetabProblem(petab_problem, store_edatas=True) + app_store_false = PetabProblem(petab_problem, store_edatas=False) + + parameter_update = {app_store_true.model.getParameterIds()[0]: 0.12345} + app_store_true.set_parameters(parameter_update, scaled_parameters=True) + app_store_false.set_parameters(parameter_update, scaled_parameters=True) + + for edata_store_true, edata_store_false in zip( + app_store_true.get_edatas(), app_store_false.get_edatas() + ): + assert edata_store_true is not edata_store_false + assert edata_store_true == edata_store_false