From 83354fd9f1a4e0a95d1220227ea23053d2c381ee Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Mon, 9 Dec 2024 21:55:56 +0100 Subject: [PATCH 01/17] Update petab v2 tests Update to recent format changes. --- .ci_pip_reqs.txt | 2 +- petabtests/cases/v2.0.0/sbml/0001/_0001.yaml | 7 +- .../cases/v2.0.0/sbml/0001/_conditions.tsv | 3 +- .../cases/v2.0.0/sbml/0001/_measurements.tsv | 4 +- petabtests/cases/v2.0.0/sbml/0002/_0002.yaml | 7 +- .../cases/v2.0.0/sbml/0002/_conditions.tsv | 8 +- petabtests/cases/v2.0.0/sbml/0003/_0003.yaml | 7 +- .../cases/v2.0.0/sbml/0003/_conditions.tsv | 3 +- .../cases/v2.0.0/sbml/0003/_measurements.tsv | 4 +- petabtests/cases/v2.0.0/sbml/0004/_0004.yaml | 7 +- .../cases/v2.0.0/sbml/0004/_conditions.tsv | 3 +- .../cases/v2.0.0/sbml/0004/_measurements.tsv | 4 +- petabtests/cases/v2.0.0/sbml/0005/_0005.yaml | 7 +- .../cases/v2.0.0/sbml/0005/_conditions.tsv | 6 +- petabtests/cases/v2.0.0/sbml/0006/_0006.yaml | 7 +- .../cases/v2.0.0/sbml/0006/_conditions.tsv | 3 +- .../cases/v2.0.0/sbml/0006/_measurements.tsv | 4 +- petabtests/cases/v2.0.0/sbml/0007/_0007.yaml | 7 +- .../cases/v2.0.0/sbml/0007/_conditions.tsv | 3 +- .../cases/v2.0.0/sbml/0007/_measurements.tsv | 4 +- petabtests/cases/v2.0.0/sbml/0008/_0008.yaml | 7 +- .../cases/v2.0.0/sbml/0008/_conditions.tsv | 3 +- .../cases/v2.0.0/sbml/0008/_measurements.tsv | 6 +- petabtests/cases/v2.0.0/sbml/0009/_0009.yaml | 7 +- .../cases/v2.0.0/sbml/0009/_conditions.tsv | 6 +- petabtests/cases/v2.0.0/sbml/0010/_0010.yaml | 7 +- .../cases/v2.0.0/sbml/0010/_conditions.tsv | 8 +- petabtests/cases/v2.0.0/sbml/0011/_0011.yaml | 7 +- .../cases/v2.0.0/sbml/0011/_conditions.tsv | 4 +- petabtests/cases/v2.0.0/sbml/0012/_0012.yaml | 7 +- .../cases/v2.0.0/sbml/0012/_conditions.tsv | 4 +- petabtests/cases/v2.0.0/sbml/0013/_0013.yaml | 7 +- .../cases/v2.0.0/sbml/0013/_conditions.tsv | 4 +- petabtests/cases/v2.0.0/sbml/0014/_0014.yaml | 7 +- .../cases/v2.0.0/sbml/0014/_conditions.tsv | 3 +- .../cases/v2.0.0/sbml/0014/_measurements.tsv | 4 +- petabtests/cases/v2.0.0/sbml/0015/_0015.yaml | 7 +- .../cases/v2.0.0/sbml/0015/_conditions.tsv | 3 +- .../cases/v2.0.0/sbml/0015/_measurements.tsv | 4 +- petabtests/cases/v2.0.0/sbml/0016/_0016.yaml | 7 +- .../cases/v2.0.0/sbml/0016/_conditions.tsv | 3 +- .../cases/v2.0.0/sbml/0016/_measurements.tsv | 4 +- petabtests/cases/v2.0.0/sbml/0017/_0017.yaml | 7 +- .../cases/v2.0.0/sbml/0017/_conditions.tsv | 10 ++- petabtests/cases/v2.0.0/sbml/0018/_0018.yaml | 7 +- .../cases/v2.0.0/sbml/0018/_conditions.tsv | 10 ++- petabtests/cases/v2.0.0/sbml/0019/0019.py | 80 ++++++------------- petabtests/cases/v2.0.0/sbml/0019/_0019.yaml | 3 +- .../v2.0.0/sbml/0019/_0019_solution.yaml | 2 +- .../cases/v2.0.0/sbml/0019/_parameters.tsv | 10 +-- petabtests/cases/v2.0.0/sbml/0020/_0020.yaml | 7 +- .../cases/v2.0.0/sbml/0020/_conditions.tsv | 5 +- petabtests/cases/v2.0.0/sbml/0021/0021.py | 57 ++++--------- petabtests/cases/v2.0.0/sbml/0021/_0021.yaml | 10 +-- .../v2.0.0/sbml/0021/_0021_solution.yaml | 2 +- .../cases/v2.0.0/sbml/0021/_conditions.tsv | 3 +- .../cases/v2.0.0/sbml/0021/_measurements.tsv | 4 +- .../cases/v2.0.0/sbml/0021/_parameters.tsv | 12 +-- .../cases/v2.0.0/sbml/0021/_simulations.tsv | 4 +- petabtests/file.py | 39 +++++++-- 60 files changed, 239 insertions(+), 252 deletions(-) diff --git a/.ci_pip_reqs.txt b/.ci_pip_reqs.txt index 75eba8c..d066353 100644 --- a/.ci_pip_reqs.txt +++ b/.ci_pip_reqs.txt @@ -1,4 +1,4 @@ pytest ruff -git+https://github.com/PEtab-dev/libpetab-python@develop +git+https://github.com/PEtab-dev/libpetab-python@long_conditions sympy>=1.12.1 diff --git a/petabtests/cases/v2.0.0/sbml/0001/_0001.yaml b/petabtests/cases/v2.0.0/sbml/0001/_0001.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0001/_0001.yaml +++ b/petabtests/cases/v2.0.0/sbml/0001/_0001.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0001/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0001/_conditions.tsv index f15e327..3664278 100644 --- a/petabtests/cases/v2.0.0/sbml/0001/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0001/_conditions.tsv @@ -1,2 +1 @@ -conditionId -c0 +conditionId targetId valueType targetValue diff --git a/petabtests/cases/v2.0.0/sbml/0001/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0001/_measurements.tsv index a497632..47fdf7c 100644 --- a/petabtests/cases/v2.0.0/sbml/0001/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0001/_measurements.tsv @@ -1,3 +1,3 @@ observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 +obs_a 0 0.7 +obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0002/_0002.yaml b/petabtests/cases/v2.0.0/sbml/0002/_0002.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0002/_0002.yaml +++ b/petabtests/cases/v2.0.0/sbml/0002/_0002.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0002/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0002/_conditions.tsv index 6524332..aba08a4 100644 --- a/petabtests/cases/v2.0.0/sbml/0002/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0002/_conditions.tsv @@ -1,3 +1,5 @@ -conditionId a0 b0 -c0 0.8 -c1 0.9 +conditionId targetId targetValue valueType +c0 a0 0.8 constant +c1 a0 0.9 constant +c0 b0 constant +c1 b0 constant diff --git a/petabtests/cases/v2.0.0/sbml/0003/_0003.yaml b/petabtests/cases/v2.0.0/sbml/0003/_0003.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0003/_0003.yaml +++ b/petabtests/cases/v2.0.0/sbml/0003/_0003.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0003/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0003/_conditions.tsv index f15e327..3664278 100644 --- a/petabtests/cases/v2.0.0/sbml/0003/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0003/_conditions.tsv @@ -1,2 +1 @@ -conditionId -c0 +conditionId targetId valueType targetValue diff --git a/petabtests/cases/v2.0.0/sbml/0003/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0003/_measurements.tsv index 2078ec7..1552a5b 100644 --- a/petabtests/cases/v2.0.0/sbml/0003/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0003/_measurements.tsv @@ -1,3 +1,3 @@ observableId simulationConditionId time measurement observableParameters -obs_a c0 0 0.7 0.5;2 -obs_a c0 10 0.1 0.5;2 +obs_a 0 0.7 0.5;2 +obs_a 10 0.1 0.5;2 diff --git a/petabtests/cases/v2.0.0/sbml/0004/_0004.yaml b/petabtests/cases/v2.0.0/sbml/0004/_0004.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0004/_0004.yaml +++ b/petabtests/cases/v2.0.0/sbml/0004/_0004.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0004/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0004/_conditions.tsv index f15e327..3664278 100644 --- a/petabtests/cases/v2.0.0/sbml/0004/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0004/_conditions.tsv @@ -1,2 +1 @@ -conditionId -c0 +conditionId targetId valueType targetValue diff --git a/petabtests/cases/v2.0.0/sbml/0004/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0004/_measurements.tsv index a497632..47fdf7c 100644 --- a/petabtests/cases/v2.0.0/sbml/0004/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0004/_measurements.tsv @@ -1,3 +1,3 @@ observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 +obs_a 0 0.7 +obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0005/_0005.yaml b/petabtests/cases/v2.0.0/sbml/0005/_0005.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0005/_0005.yaml +++ b/petabtests/cases/v2.0.0/sbml/0005/_0005.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0005/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0005/_conditions.tsv index db79bf4..623c4d1 100644 --- a/petabtests/cases/v2.0.0/sbml/0005/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0005/_conditions.tsv @@ -1,3 +1,3 @@ -conditionId offset_A -c0 offset_A_c0 -c1 offset_A_c1 +conditionId targetId targetValue valueType +c0 offset_A offset_A_c0 constant +c1 offset_A offset_A_c1 constant diff --git a/petabtests/cases/v2.0.0/sbml/0006/_0006.yaml b/petabtests/cases/v2.0.0/sbml/0006/_0006.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0006/_0006.yaml +++ b/petabtests/cases/v2.0.0/sbml/0006/_0006.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0006/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0006/_conditions.tsv index f15e327..3664278 100644 --- a/petabtests/cases/v2.0.0/sbml/0006/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0006/_conditions.tsv @@ -1,2 +1 @@ -conditionId -c0 +conditionId targetId valueType targetValue diff --git a/petabtests/cases/v2.0.0/sbml/0006/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0006/_measurements.tsv index 8ed279b..443864a 100644 --- a/petabtests/cases/v2.0.0/sbml/0006/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0006/_measurements.tsv @@ -1,3 +1,3 @@ observableId simulationConditionId time measurement observableParameters -obs_a c0 0 0.7 10 -obs_a c0 10 0.1 15 +obs_a 0 0.7 10 +obs_a 10 0.1 15 diff --git a/petabtests/cases/v2.0.0/sbml/0007/_0007.yaml b/petabtests/cases/v2.0.0/sbml/0007/_0007.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0007/_0007.yaml +++ b/petabtests/cases/v2.0.0/sbml/0007/_0007.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0007/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0007/_conditions.tsv index f15e327..3664278 100644 --- a/petabtests/cases/v2.0.0/sbml/0007/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0007/_conditions.tsv @@ -1,2 +1 @@ -conditionId -c0 +conditionId targetId valueType targetValue diff --git a/petabtests/cases/v2.0.0/sbml/0007/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0007/_measurements.tsv index 00c596e..d9e4439 100644 --- a/petabtests/cases/v2.0.0/sbml/0007/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0007/_measurements.tsv @@ -1,3 +1,3 @@ observableId simulationConditionId time measurement -obs_a c0 10 0.2 -obs_b c0 10 0.8 +obs_a 10 0.2 +obs_b 10 0.8 diff --git a/petabtests/cases/v2.0.0/sbml/0008/_0008.yaml b/petabtests/cases/v2.0.0/sbml/0008/_0008.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0008/_0008.yaml +++ b/petabtests/cases/v2.0.0/sbml/0008/_0008.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0008/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0008/_conditions.tsv index f15e327..3664278 100644 --- a/petabtests/cases/v2.0.0/sbml/0008/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0008/_conditions.tsv @@ -1,2 +1 @@ -conditionId -c0 +conditionId targetId valueType targetValue diff --git a/petabtests/cases/v2.0.0/sbml/0008/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0008/_measurements.tsv index b17d732..d2ae13a 100644 --- a/petabtests/cases/v2.0.0/sbml/0008/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0008/_measurements.tsv @@ -1,4 +1,4 @@ observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 -obs_a c0 10 0.2 +obs_a 0 0.7 +obs_a 10 0.1 +obs_a 10 0.2 diff --git a/petabtests/cases/v2.0.0/sbml/0009/_0009.yaml b/petabtests/cases/v2.0.0/sbml/0009/_0009.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0009/_0009.yaml +++ b/petabtests/cases/v2.0.0/sbml/0009/_0009.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0009/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0009/_conditions.tsv index 834fafc..42a1401 100644 --- a/petabtests/cases/v2.0.0/sbml/0009/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0009/_conditions.tsv @@ -1,3 +1,3 @@ -conditionId k1 -preeq_c0 0.3 -c0 0.8 +conditionId targetId targetValue valueType +preeq_c0 k1 0.3 constant +c0 k1 0.8 constant diff --git a/petabtests/cases/v2.0.0/sbml/0010/_0010.yaml b/petabtests/cases/v2.0.0/sbml/0010/_0010.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0010/_0010.yaml +++ b/petabtests/cases/v2.0.0/sbml/0010/_0010.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0010/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0010/_conditions.tsv index 96cbc94..b4012d5 100644 --- a/petabtests/cases/v2.0.0/sbml/0010/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0010/_conditions.tsv @@ -1,3 +1,5 @@ -conditionId k1 B -preeq_c0 0.3 0 -c0 0.8 1 +conditionId targetId targetValue valueType +preeq_c0 k1 0.3 constant +c0 k1 0.8 constant +preeq_c0 B 0.0 initial +c0 B 1.0 initial diff --git a/petabtests/cases/v2.0.0/sbml/0011/_0011.yaml b/petabtests/cases/v2.0.0/sbml/0011/_0011.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0011/_0011.yaml +++ b/petabtests/cases/v2.0.0/sbml/0011/_0011.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0011/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0011/_conditions.tsv index e765b36..2f2cece 100644 --- a/petabtests/cases/v2.0.0/sbml/0011/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0011/_conditions.tsv @@ -1,2 +1,2 @@ -conditionId B -c0 2 +conditionId targetId targetValue valueType +c0 B 2 initial diff --git a/petabtests/cases/v2.0.0/sbml/0012/_0012.yaml b/petabtests/cases/v2.0.0/sbml/0012/_0012.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0012/_0012.yaml +++ b/petabtests/cases/v2.0.0/sbml/0012/_0012.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0012/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0012/_conditions.tsv index 13666c2..e0aecfd 100644 --- a/petabtests/cases/v2.0.0/sbml/0012/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0012/_conditions.tsv @@ -1,2 +1,2 @@ -conditionId compartment -c0 3 +conditionId targetId targetValue valueType +c0 compartment 3 initial diff --git a/petabtests/cases/v2.0.0/sbml/0013/_0013.yaml b/petabtests/cases/v2.0.0/sbml/0013/_0013.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0013/_0013.yaml +++ b/petabtests/cases/v2.0.0/sbml/0013/_0013.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0013/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0013/_conditions.tsv index a26fa5d..e52b503 100644 --- a/petabtests/cases/v2.0.0/sbml/0013/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0013/_conditions.tsv @@ -1,2 +1,2 @@ -conditionId B -c0 par +conditionId targetId targetValue valueType +c0 B par initial diff --git a/petabtests/cases/v2.0.0/sbml/0014/_0014.yaml b/petabtests/cases/v2.0.0/sbml/0014/_0014.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0014/_0014.yaml +++ b/petabtests/cases/v2.0.0/sbml/0014/_0014.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0014/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0014/_conditions.tsv index f15e327..3664278 100644 --- a/petabtests/cases/v2.0.0/sbml/0014/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0014/_conditions.tsv @@ -1,2 +1 @@ -conditionId -c0 +conditionId targetId valueType targetValue diff --git a/petabtests/cases/v2.0.0/sbml/0014/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0014/_measurements.tsv index 980766d..9083eb1 100644 --- a/petabtests/cases/v2.0.0/sbml/0014/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0014/_measurements.tsv @@ -1,3 +1,3 @@ observableId simulationConditionId time measurement noiseParameters -obs_a c0 0 0.7 0.5;2 -obs_a c0 10 0.1 0.5;2 +obs_a 0 0.7 0.5;2 +obs_a 10 0.1 0.5;2 diff --git a/petabtests/cases/v2.0.0/sbml/0015/_0015.yaml b/petabtests/cases/v2.0.0/sbml/0015/_0015.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0015/_0015.yaml +++ b/petabtests/cases/v2.0.0/sbml/0015/_0015.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0015/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0015/_conditions.tsv index f15e327..3664278 100644 --- a/petabtests/cases/v2.0.0/sbml/0015/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0015/_conditions.tsv @@ -1,2 +1 @@ -conditionId -c0 +conditionId targetId valueType targetValue diff --git a/petabtests/cases/v2.0.0/sbml/0015/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0015/_measurements.tsv index 687cf08..c1ae0cc 100644 --- a/petabtests/cases/v2.0.0/sbml/0015/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0015/_measurements.tsv @@ -1,3 +1,3 @@ observableId simulationConditionId time measurement noiseParameters -obs_a c0 0 0.7 noise -obs_a c0 10 0.1 noise +obs_a 0 0.7 noise +obs_a 10 0.1 noise diff --git a/petabtests/cases/v2.0.0/sbml/0016/_0016.yaml b/petabtests/cases/v2.0.0/sbml/0016/_0016.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0016/_0016.yaml +++ b/petabtests/cases/v2.0.0/sbml/0016/_0016.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0016/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0016/_conditions.tsv index f15e327..3664278 100644 --- a/petabtests/cases/v2.0.0/sbml/0016/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0016/_conditions.tsv @@ -1,2 +1 @@ -conditionId -c0 +conditionId targetId valueType targetValue diff --git a/petabtests/cases/v2.0.0/sbml/0016/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0016/_measurements.tsv index 00c596e..d9e4439 100644 --- a/petabtests/cases/v2.0.0/sbml/0016/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0016/_measurements.tsv @@ -1,3 +1,3 @@ observableId simulationConditionId time measurement -obs_a c0 10 0.2 -obs_b c0 10 0.8 +obs_a 10 0.2 +obs_b 10 0.8 diff --git a/petabtests/cases/v2.0.0/sbml/0017/_0017.yaml b/petabtests/cases/v2.0.0/sbml/0017/_0017.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0017/_0017.yaml +++ b/petabtests/cases/v2.0.0/sbml/0017/_0017.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0017/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0017/_conditions.tsv index 18cccad..287e74a 100644 --- a/petabtests/cases/v2.0.0/sbml/0017/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0017/_conditions.tsv @@ -1,3 +1,7 @@ -conditionId k1 B A -preeq_c0 0.3 2.0 0 -c0 0.8 NaN 1 +conditionId targetId targetValue valueType +preeq_c0 k1 0.3 constant +c0 k1 0.8 constant +preeq_c0 B 2.0 initial +c0 B initial +preeq_c0 A 0.0 initial +c0 A 1.0 initial diff --git a/petabtests/cases/v2.0.0/sbml/0018/_0018.yaml b/petabtests/cases/v2.0.0/sbml/0018/_0018.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0018/_0018.yaml +++ b/petabtests/cases/v2.0.0/sbml/0018/_0018.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0018/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0018/_conditions.tsv index 18cccad..287e74a 100644 --- a/petabtests/cases/v2.0.0/sbml/0018/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0018/_conditions.tsv @@ -1,3 +1,7 @@ -conditionId k1 B A -preeq_c0 0.3 2.0 0 -c0 0.8 NaN 1 +conditionId targetId targetValue valueType +preeq_c0 k1 0.3 constant +c0 k1 0.8 constant +preeq_c0 B 2.0 initial +c0 B initial +preeq_c0 A 0.0 initial +c0 A 1.0 initial diff --git a/petabtests/cases/v2.0.0/sbml/0019/0019.py b/petabtests/cases/v2.0.0/sbml/0019/0019.py index 55a9921..d2441db 100644 --- a/petabtests/cases/v2.0.0/sbml/0019/0019.py +++ b/petabtests/cases/v2.0.0/sbml/0019/0019.py @@ -1,8 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * - +from petab.v2.C import * +from petab.v2 import Problem from petabtests import DEFAULT_SBML_FILE, PetabTestCase, analytical_a DESCRIPTION = cleandoc(""" @@ -17,74 +16,41 @@ """) # problem -------------------------------------------------------------------- +problem = Problem() # TODO use mapping here -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0"], - } -).set_index([CONDITION_ID]) - -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [0, 10], - MEASUREMENT: [0.7, 0.1], - } -) - -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["maps_to_A"], - NOISE_FORMULA: [0.5], - } -).set_index([OBSERVABLE_ID]) - -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["a0", "maps_to_b0", "k1", "maps_to_k2"], - PARAMETER_SCALE: [LIN] * 4, - LOWER_BOUND: [0] * 4, - UPPER_BOUND: [10] * 4, - NOMINAL_VALUE: [1, 0, 0.8, 0.6], - ESTIMATE: [1] * 4, - } -).set_index(PARAMETER_ID) +problem.add_condition("c0") +problem.add_measurement("obs_a", "c0", 0, 0.7) +problem.add_measurement("obs_a", "c0", 10, 0.1) +problem.add_observable("obs_a", "maps_to_A", 0.5) +problem.add_parameter("a0", lb=0, ub=10, nominal_value=1, scale=LIN) +problem.add_parameter("maps_to_b0", lb=0, ub=10, nominal_value=0, scale=LIN) +problem.add_parameter("k1", lb=0, ub=10, nominal_value=0.8, scale=LIN) +problem.add_parameter("maps_to_k2", lb=0, ub=10, nominal_value=0.6, scale=LIN) +problem.add_mapping("maps_to_a0", "a0") +problem.add_mapping("maps_to_b0", "b0") +problem.add_mapping("maps_to_k1", "k1") +problem.add_mapping("maps_to_k2", "k2") +problem.add_mapping("maps_to_A", "A") +problem.add_mapping("maps_to_B", "B") # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) simulation_df[SIMULATION] = [ analytical_a(t, 1, 0, 0.8, 0.6) for t in simulation_df[TIME] ] - -mapping_df = pd.DataFrame( - data={ - PETAB_ENTITY_ID: [ - "maps_to_a0", - "maps_to_b0", - "maps_to_k1", - "maps_to_k2", - "maps_to_A", - "maps_to_B", - ], - MODEL_ENTITY_ID: ["a0", "b0", "k1", "k2", "A", "B"], - } -).set_index(PETAB_ENTITY_ID) - case = PetabTestCase( id=19, brief="Mapping table.", description=DESCRIPTION, # TODO add local parameter and use in mapping table model=DEFAULT_SBML_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, - mapping_df=mapping_df, + parameter_df=problem.parameter_df, + mapping_df=problem.mapping_df, ) diff --git a/petabtests/cases/v2.0.0/sbml/0019/_0019.yaml b/petabtests/cases/v2.0.0/sbml/0019/_0019.yaml index c87fb5a..5e75a23 100644 --- a/petabtests/cases/v2.0.0/sbml/0019/_0019.yaml +++ b/petabtests/cases/v2.0.0/sbml/0019/_0019.yaml @@ -1,8 +1,7 @@ format_version: 2.0.0 parameter_file: _parameters.tsv problems: -- condition_files: - - _conditions.tsv +- condition_files: [] mapping_files: - _mapping.tsv measurement_files: diff --git a/petabtests/cases/v2.0.0/sbml/0019/_0019_solution.yaml b/petabtests/cases/v2.0.0/sbml/0019/_0019_solution.yaml index 1ee1c67..4a41272 100644 --- a/petabtests/cases/v2.0.0/sbml/0019/_0019_solution.yaml +++ b/petabtests/cases/v2.0.0/sbml/0019/_0019_solution.yaml @@ -1,4 +1,4 @@ -chi2: 0.79183798368486 +chi2: 0.86367596736971 llh: -0.84750169713188 simulation_files: - _simulations.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0019/_parameters.tsv b/petabtests/cases/v2.0.0/sbml/0019/_parameters.tsv index 797509b..fcaf228 100644 --- a/petabtests/cases/v2.0.0/sbml/0019/_parameters.tsv +++ b/petabtests/cases/v2.0.0/sbml/0019/_parameters.tsv @@ -1,5 +1,5 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -a0 lin 0 10 1.0 1 -maps_to_b0 lin 0 10 0.0 1 -k1 lin 0 10 0.8 1 -maps_to_k2 lin 0 10 0.6 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +a0 1 1.0 lin 0 10 +maps_to_b0 1 0.0 lin 0 10 +k1 1 0.8 lin 0 10 +maps_to_k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/sbml/0020/_0020.yaml b/petabtests/cases/v2.0.0/sbml/0020/_0020.yaml index b1337e7..c3170c2 100644 --- a/petabtests/cases/v2.0.0/sbml/0020/_0020.yaml +++ b/petabtests/cases/v2.0.0/sbml/0020/_0020.yaml @@ -5,9 +5,10 @@ problems: - _conditions.tsv measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0020/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0020/_conditions.tsv index 1297d08..f146116 100644 --- a/petabtests/cases/v2.0.0/sbml/0020/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0020/_conditions.tsv @@ -1,2 +1,3 @@ -conditionId A B -c0 initial_A initial_B +conditionId targetId targetValue valueType +c0 A initial_A initial +c0 B initial_B initial diff --git a/petabtests/cases/v2.0.0/sbml/0021/0021.py b/petabtests/cases/v2.0.0/sbml/0021/0021.py index 1586a4b..7e353f3 100644 --- a/petabtests/cases/v2.0.0/sbml/0021/0021.py +++ b/petabtests/cases/v2.0.0/sbml/0021/0021.py @@ -1,8 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * - +from petab.v2.C import * +from petab.v2 import Problem from petabtests import DEFAULT_SBML_FILE, PetabTestCase, analytical_a DESCRIPTION = cleandoc(""" @@ -19,44 +18,22 @@ # problem -------------------------------------------------------------------- -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0"], - } -).set_index([CONDITION_ID]) - -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [0, 10], - MEASUREMENT: [0.7, 0.1], - NOISE_PARAMETERS: ["noise", "noise"], - } +problem = Problem() +problem.add_measurement("obs_a", "", 0, 0.7, noise_parameters=["noise"]) +problem.add_measurement("obs_a", "", 10, 0.1, noise_parameters=["noise"]) +problem.add_observable( + "obs_a", "A", noise_formula="noiseParameter1_obs_a * obs_a" ) +problem.add_parameter("a0", lb=0, ub=10, nominal_value=1, scale=LIN) +problem.add_parameter("b0", lb=0, ub=10, nominal_value=0, scale=LIN) +problem.add_parameter("k1", lb=0, ub=10, nominal_value=0.8, scale=LIN) +problem.add_parameter("k2", lb=0, ub=10, nominal_value=0.6, scale=LIN) +problem.add_parameter("noise", lb=0, ub=10, nominal_value=5, scale=LIN) -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["A"], - NOISE_FORMULA: ["noiseParameter1_obs_a * obs_a"], - } -).set_index([OBSERVABLE_ID]) - -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["a0", "b0", "k1", "k2", "noise"], - PARAMETER_SCALE: [LIN] * 5, - LOWER_BOUND: [0] * 5, - UPPER_BOUND: [10] * 5, - NOMINAL_VALUE: [1, 0, 0.8, 0.6, 5], - ESTIMATE: [1] * 5, - } -).set_index(PARAMETER_ID) # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) simulation_df[SIMULATION] = [ @@ -69,9 +46,9 @@ brief="Simulation. Nothing special.", description=DESCRIPTION, model=DEFAULT_SBML_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, + parameter_df=problem.parameter_df, ) diff --git a/petabtests/cases/v2.0.0/sbml/0021/_0021.yaml b/petabtests/cases/v2.0.0/sbml/0021/_0021.yaml index b1337e7..e988ca3 100644 --- a/petabtests/cases/v2.0.0/sbml/0021/_0021.yaml +++ b/petabtests/cases/v2.0.0/sbml/0021/_0021.yaml @@ -1,13 +1,13 @@ format_version: 2.0.0 parameter_file: _parameters.tsv problems: -- condition_files: - - _conditions.tsv +- condition_files: [] measurement_files: - _measurements.tsv + observable_files: + - _observables.tsv model_files: - model_0: + _model: language: sbml location: _model.xml - observable_files: - - _observables.tsv +extensions: [] diff --git a/petabtests/cases/v2.0.0/sbml/0021/_0021_solution.yaml b/petabtests/cases/v2.0.0/sbml/0021/_0021_solution.yaml index fb2acef..a0060e6 100644 --- a/petabtests/cases/v2.0.0/sbml/0021/_0021_solution.yaml +++ b/petabtests/cases/v2.0.0/sbml/0021/_0021_solution.yaml @@ -1,4 +1,4 @@ -chi2: 0.0271111269779 +chi2: 0.04702225395579 llh: -4.22301170308364 simulation_files: - _simulations.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0021/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0021/_conditions.tsv index f15e327..3664278 100644 --- a/petabtests/cases/v2.0.0/sbml/0021/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0021/_conditions.tsv @@ -1,2 +1 @@ -conditionId -c0 +conditionId targetId valueType targetValue diff --git a/petabtests/cases/v2.0.0/sbml/0021/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0021/_measurements.tsv index 687cf08..c1ae0cc 100644 --- a/petabtests/cases/v2.0.0/sbml/0021/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0021/_measurements.tsv @@ -1,3 +1,3 @@ observableId simulationConditionId time measurement noiseParameters -obs_a c0 0 0.7 noise -obs_a c0 10 0.1 noise +obs_a 0 0.7 noise +obs_a 10 0.1 noise diff --git a/petabtests/cases/v2.0.0/sbml/0021/_parameters.tsv b/petabtests/cases/v2.0.0/sbml/0021/_parameters.tsv index 46c9b55..adce913 100644 --- a/petabtests/cases/v2.0.0/sbml/0021/_parameters.tsv +++ b/petabtests/cases/v2.0.0/sbml/0021/_parameters.tsv @@ -1,6 +1,6 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -a0 lin 0 10 1.0 1 -b0 lin 0 10 0.0 1 -k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 -noise lin 0 10 5.0 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +a0 1 1.0 lin 0 10 +b0 1 0.0 lin 0 10 +k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 +noise 1 5.0 lin 0 10 diff --git a/petabtests/cases/v2.0.0/sbml/0021/_simulations.tsv b/petabtests/cases/v2.0.0/sbml/0021/_simulations.tsv index 1bb82af..bc75731 100644 --- a/petabtests/cases/v2.0.0/sbml/0021/_simulations.tsv +++ b/petabtests/cases/v2.0.0/sbml/0021/_simulations.tsv @@ -1,3 +1,3 @@ observableId simulationConditionId time simulation noiseParameters -obs_a c0 0 1.0 noise -obs_a c0 10 0.42857190373069665 noise +obs_a 0 1.0 noise +obs_a 10 0.42857190373069665 noise diff --git a/petabtests/file.py b/petabtests/file.py index 1ed9bd2..2779299 100644 --- a/petabtests/file.py +++ b/petabtests/file.py @@ -6,7 +6,8 @@ from collections.abc import Callable from pathlib import Path import pandas as pd -import petab.v1 as petab +from petab import v1 +from petab import v2 import yaml from petab.v1.C import * # noqa: F403 from .C import * # noqa: F403 @@ -109,8 +110,11 @@ def write_problem( # id to string dir_ = get_case_dir(id_=test_id, format_=format_, version=version) - - if version == "v1.0.0": + if ( + version == "v1.0.0" + or SIMULATION_CONDITION_ID in measurement_dfs[0] + and not (version == "v2.0.0" and test_id == 19) + ): format_version = 1 else: assert version[0] == "v" @@ -149,9 +153,15 @@ def write_problem( pass copied_model_files.append(copied_model_file) - if version == "v1.0.0": + if ( + version == "v1.0.0" + or SIMULATION_CONDITION_ID in measurement_dfs[0] + and not (version == "v2.0.0" and test_id == 19) + ): + petab = v1 config[PROBLEMS][0][SBML_FILES] = copied_model_files else: + petab = v2 config[PROBLEMS][0][MODEL_FILES] = {} for model_idx, model_file in enumerate(copied_model_files): config[PROBLEMS][0][MODEL_FILES][f"model_{model_idx}"] = { @@ -198,7 +208,7 @@ def write_problem( config[PROBLEMS][0][MAPPING_FILES] = [mappings_file] # validate petab yaml - petab.validate(config, path_prefix=dir_) + v1.validate(config, path_prefix=dir_) # write yaml yaml_file = problem_yaml_name(test_id) @@ -206,6 +216,18 @@ def write_problem( with open(yaml_path, "w") as outfile: yaml.dump(config, outfile, default_flow_style=False) + # FIXME: Until the tests are proper v2 problems, we just auto-upgrade + # to a temp directory and copy the files back + if ( + version == "v2.0.0" + and SIMULATION_CONDITION_ID in measurement_dfs[0] + and not (version == "v2.0.0" and test_id == 19) + ): + from petab.v2.petab1to2 import petab1to2 + + petab1to2(yaml_path, dir_) + format_version = 2 + # FIXME Until a first libpetab with petab.v1 subpackage is released try: # new petab version @@ -230,8 +252,8 @@ def write_problem( ) except ModuleNotFoundError: # old petab version (will fail validation for some v2 tests) - problem = petab.Problem.from_yaml(os.path.join(dir_, yaml_file)) - if petab.lint_problem(problem): + problem = v1.Problem.from_yaml(os.path.join(dir_, yaml_file)) + if v1.lint_problem(problem): raise RuntimeError("Invalid PEtab problem, see messages above.") @@ -280,7 +302,8 @@ def write_solution( _write_dfs_to_files( dir_, "simulations", - petab.write_measurement_df, + # TODO v2 + v1.write_measurement_df, simulation_dfs, config[SIMULATION_FILES], ) From 68c0c6e38ea6e249302c725bb0653a3434742f44 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Mon, 16 Dec 2024 22:23:06 +0100 Subject: [PATCH 02/17] experimentId --- petabtests/cases/v2.0.0/sbml/0001/_measurements.tsv | 6 +++--- petabtests/cases/v2.0.0/sbml/0001/experiments.tsv | 2 ++ petabtests/cases/v2.0.0/sbml/0002/_measurements.tsv | 10 +++++----- petabtests/cases/v2.0.0/sbml/0002/experiments.tsv | 3 +++ petabtests/cases/v2.0.0/sbml/0003/_measurements.tsv | 6 +++--- petabtests/cases/v2.0.0/sbml/0003/experiments.tsv | 2 ++ petabtests/cases/v2.0.0/sbml/0004/_measurements.tsv | 6 +++--- petabtests/cases/v2.0.0/sbml/0004/experiments.tsv | 2 ++ petabtests/cases/v2.0.0/sbml/0005/_measurements.tsv | 6 +++--- petabtests/cases/v2.0.0/sbml/0005/experiments.tsv | 3 +++ petabtests/cases/v2.0.0/sbml/0006/_measurements.tsv | 6 +++--- petabtests/cases/v2.0.0/sbml/0006/experiments.tsv | 2 ++ petabtests/cases/v2.0.0/sbml/0007/_measurements.tsv | 6 +++--- petabtests/cases/v2.0.0/sbml/0007/experiments.tsv | 2 ++ petabtests/cases/v2.0.0/sbml/0008/_measurements.tsv | 8 ++++---- petabtests/cases/v2.0.0/sbml/0008/experiments.tsv | 2 ++ petabtests/cases/v2.0.0/sbml/0009/_measurements.tsv | 6 +++--- petabtests/cases/v2.0.0/sbml/0009/experiments.tsv | 3 +++ petabtests/cases/v2.0.0/sbml/0010/_measurements.tsv | 6 +++--- petabtests/cases/v2.0.0/sbml/0010/experiments.tsv | 3 +++ petabtests/cases/v2.0.0/sbml/0011/_measurements.tsv | 6 +++--- petabtests/cases/v2.0.0/sbml/0011/experiments.tsv | 2 ++ petabtests/cases/v2.0.0/sbml/0012/_measurements.tsv | 6 +++--- petabtests/cases/v2.0.0/sbml/0012/experiments.tsv | 2 ++ petabtests/cases/v2.0.0/sbml/0013/_measurements.tsv | 6 +++--- petabtests/cases/v2.0.0/sbml/0013/experiments.tsv | 2 ++ petabtests/cases/v2.0.0/sbml/0014/_measurements.tsv | 6 +++--- petabtests/cases/v2.0.0/sbml/0014/experiments.tsv | 2 ++ petabtests/cases/v2.0.0/sbml/0015/_measurements.tsv | 6 +++--- petabtests/cases/v2.0.0/sbml/0015/experiments.tsv | 2 ++ petabtests/cases/v2.0.0/sbml/0016/_measurements.tsv | 6 +++--- petabtests/cases/v2.0.0/sbml/0016/experiments.tsv | 2 ++ petabtests/cases/v2.0.0/sbml/0017/_measurements.tsv | 6 +++--- petabtests/cases/v2.0.0/sbml/0017/experiments.tsv | 3 +++ petabtests/cases/v2.0.0/sbml/0018/_measurements.tsv | 10 +++++----- petabtests/cases/v2.0.0/sbml/0018/experiments.tsv | 3 +++ petabtests/cases/v2.0.0/sbml/0019/_measurements.tsv | 2 +- 37 files changed, 102 insertions(+), 60 deletions(-) create mode 100644 petabtests/cases/v2.0.0/sbml/0001/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0002/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0003/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0004/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0005/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0006/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0007/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0008/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0009/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0010/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0011/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0012/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0013/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0014/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0015/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0016/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0017/experiments.tsv create mode 100644 petabtests/cases/v2.0.0/sbml/0018/experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0001/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0001/_measurements.tsv index 47fdf7c..853679a 100644 --- a/petabtests/cases/v2.0.0/sbml/0001/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0001/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a 0 0.7 -obs_a 10 0.1 +experimentId observableId time measurement + obs_a 0 0.7 + obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0001/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0001/experiments.tsv new file mode 100644 index 0000000..774db85 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0001/experiments.tsv @@ -0,0 +1,2 @@ +experimentId conditionId time +experiment_c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0002/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0002/_measurements.tsv index 9dbc71c..fd40b31 100644 --- a/petabtests/cases/v2.0.0/sbml/0002/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0002/_measurements.tsv @@ -1,5 +1,5 @@ -observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 -obs_a c1 0 0.8 -obs_a c1 10 0.2 +experimentId observableId time measurement +experiment_c0 obs_a 0 0.7 +experiment_c0 obs_a 10 0.1 +experiment_c1 obs_a 0 0.8 +experiment_c1 obs_a 10 0.2 diff --git a/petabtests/cases/v2.0.0/sbml/0002/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0002/experiments.tsv new file mode 100644 index 0000000..288f9cd --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0002/experiments.tsv @@ -0,0 +1,3 @@ +experimentId conditionId time +experiment_c0 c0 0 +experiment_c1 c1 0 diff --git a/petabtests/cases/v2.0.0/sbml/0003/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0003/_measurements.tsv index 1552a5b..9f00080 100644 --- a/petabtests/cases/v2.0.0/sbml/0003/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0003/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement observableParameters -obs_a 0 0.7 0.5;2 -obs_a 10 0.1 0.5;2 +experimentId observableId time measurement observableParameters + obs_a 0 0.7 0.5;2 + obs_a 10 0.1 0.5;2 diff --git a/petabtests/cases/v2.0.0/sbml/0003/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0003/experiments.tsv new file mode 100644 index 0000000..774db85 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0003/experiments.tsv @@ -0,0 +1,2 @@ +experimentId conditionId time +experiment_c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0004/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0004/_measurements.tsv index 47fdf7c..853679a 100644 --- a/petabtests/cases/v2.0.0/sbml/0004/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0004/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a 0 0.7 -obs_a 10 0.1 +experimentId observableId time measurement + obs_a 0 0.7 + obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0004/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0004/experiments.tsv new file mode 100644 index 0000000..774db85 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0004/experiments.tsv @@ -0,0 +1,2 @@ +experimentId conditionId time +experiment_c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0005/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0005/_measurements.tsv index 6016b73..44f6f85 100644 --- a/petabtests/cases/v2.0.0/sbml/0005/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0005/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a c0 10 2.1 -obs_a c1 10 3.2 +experimentId observableId time measurement +experiment_c0 obs_a 10 2.1 +experiment_c1 obs_a 10 3.2 diff --git a/petabtests/cases/v2.0.0/sbml/0005/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0005/experiments.tsv new file mode 100644 index 0000000..288f9cd --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0005/experiments.tsv @@ -0,0 +1,3 @@ +experimentId conditionId time +experiment_c0 c0 0 +experiment_c1 c1 0 diff --git a/petabtests/cases/v2.0.0/sbml/0006/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0006/_measurements.tsv index 443864a..5ce07e7 100644 --- a/petabtests/cases/v2.0.0/sbml/0006/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0006/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement observableParameters -obs_a 0 0.7 10 -obs_a 10 0.1 15 +experimentId observableId time measurement observableParameters + obs_a 0 0.7 10 + obs_a 10 0.1 15 diff --git a/petabtests/cases/v2.0.0/sbml/0006/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0006/experiments.tsv new file mode 100644 index 0000000..774db85 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0006/experiments.tsv @@ -0,0 +1,2 @@ +experimentId conditionId time +experiment_c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0007/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0007/_measurements.tsv index d9e4439..17cc638 100644 --- a/petabtests/cases/v2.0.0/sbml/0007/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0007/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a 10 0.2 -obs_b 10 0.8 +experimentId observableId time measurement + obs_a 10 0.2 + obs_b 10 0.8 diff --git a/petabtests/cases/v2.0.0/sbml/0007/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0007/experiments.tsv new file mode 100644 index 0000000..774db85 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0007/experiments.tsv @@ -0,0 +1,2 @@ +experimentId conditionId time +experiment_c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0008/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0008/_measurements.tsv index d2ae13a..a7f4c44 100644 --- a/petabtests/cases/v2.0.0/sbml/0008/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0008/_measurements.tsv @@ -1,4 +1,4 @@ -observableId simulationConditionId time measurement -obs_a 0 0.7 -obs_a 10 0.1 -obs_a 10 0.2 +experimentId observableId time measurement + obs_a 0 0.7 + obs_a 10 0.1 + obs_a 10 0.2 diff --git a/petabtests/cases/v2.0.0/sbml/0008/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0008/experiments.tsv new file mode 100644 index 0000000..774db85 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0008/experiments.tsv @@ -0,0 +1,2 @@ +experimentId conditionId time +experiment_c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0009/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0009/_measurements.tsv index a9a1cb0..bb1fec5 100644 --- a/petabtests/cases/v2.0.0/sbml/0009/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0009/_measurements.tsv @@ -1,3 +1,3 @@ -observableId preequilibrationConditionId simulationConditionId time measurement -obs_a preeq_c0 c0 1 0.7 -obs_a preeq_c0 c0 10 0.1 +experimentId observableId time measurement +experiment_preeq_c0_c0 obs_a 1 0.7 +experiment_preeq_c0_c0 obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0009/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0009/experiments.tsv new file mode 100644 index 0000000..78d6328 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0009/experiments.tsv @@ -0,0 +1,3 @@ +experimentId conditionId time +experiment_preeq_c0_c0 preeq_c0 -inf +experiment_preeq_c0_c0 c0 0.0 diff --git a/petabtests/cases/v2.0.0/sbml/0010/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0010/_measurements.tsv index a9a1cb0..bb1fec5 100644 --- a/petabtests/cases/v2.0.0/sbml/0010/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0010/_measurements.tsv @@ -1,3 +1,3 @@ -observableId preequilibrationConditionId simulationConditionId time measurement -obs_a preeq_c0 c0 1 0.7 -obs_a preeq_c0 c0 10 0.1 +experimentId observableId time measurement +experiment_preeq_c0_c0 obs_a 1 0.7 +experiment_preeq_c0_c0 obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0010/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0010/experiments.tsv new file mode 100644 index 0000000..78d6328 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0010/experiments.tsv @@ -0,0 +1,3 @@ +experimentId conditionId time +experiment_preeq_c0_c0 preeq_c0 -inf +experiment_preeq_c0_c0 c0 0.0 diff --git a/petabtests/cases/v2.0.0/sbml/0011/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0011/_measurements.tsv index a497632..35939b8 100644 --- a/petabtests/cases/v2.0.0/sbml/0011/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0011/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 +experimentId observableId time measurement +experiment_c0 obs_a 0 0.7 +experiment_c0 obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0011/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0011/experiments.tsv new file mode 100644 index 0000000..774db85 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0011/experiments.tsv @@ -0,0 +1,2 @@ +experimentId conditionId time +experiment_c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0012/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0012/_measurements.tsv index a497632..35939b8 100644 --- a/petabtests/cases/v2.0.0/sbml/0012/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0012/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 +experimentId observableId time measurement +experiment_c0 obs_a 0 0.7 +experiment_c0 obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0012/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0012/experiments.tsv new file mode 100644 index 0000000..774db85 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0012/experiments.tsv @@ -0,0 +1,2 @@ +experimentId conditionId time +experiment_c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0013/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0013/_measurements.tsv index a497632..35939b8 100644 --- a/petabtests/cases/v2.0.0/sbml/0013/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0013/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 +experimentId observableId time measurement +experiment_c0 obs_a 0 0.7 +experiment_c0 obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0013/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0013/experiments.tsv new file mode 100644 index 0000000..774db85 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0013/experiments.tsv @@ -0,0 +1,2 @@ +experimentId conditionId time +experiment_c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0014/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0014/_measurements.tsv index 9083eb1..5e5b1f7 100644 --- a/petabtests/cases/v2.0.0/sbml/0014/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0014/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement noiseParameters -obs_a 0 0.7 0.5;2 -obs_a 10 0.1 0.5;2 +experimentId observableId time measurement noiseParameters + obs_a 0 0.7 0.5;2 + obs_a 10 0.1 0.5;2 diff --git a/petabtests/cases/v2.0.0/sbml/0014/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0014/experiments.tsv new file mode 100644 index 0000000..774db85 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0014/experiments.tsv @@ -0,0 +1,2 @@ +experimentId conditionId time +experiment_c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0015/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0015/_measurements.tsv index c1ae0cc..416b884 100644 --- a/petabtests/cases/v2.0.0/sbml/0015/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0015/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement noiseParameters -obs_a 0 0.7 noise -obs_a 10 0.1 noise +experimentId observableId time measurement noiseParameters + obs_a 0 0.7 noise + obs_a 10 0.1 noise diff --git a/petabtests/cases/v2.0.0/sbml/0015/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0015/experiments.tsv new file mode 100644 index 0000000..774db85 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0015/experiments.tsv @@ -0,0 +1,2 @@ +experimentId conditionId time +experiment_c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0016/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0016/_measurements.tsv index d9e4439..17cc638 100644 --- a/petabtests/cases/v2.0.0/sbml/0016/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0016/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a 10 0.2 -obs_b 10 0.8 +experimentId observableId time measurement + obs_a 10 0.2 + obs_b 10 0.8 diff --git a/petabtests/cases/v2.0.0/sbml/0016/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0016/experiments.tsv new file mode 100644 index 0000000..774db85 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0016/experiments.tsv @@ -0,0 +1,2 @@ +experimentId conditionId time +experiment_c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0017/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0017/_measurements.tsv index a9a1cb0..bb1fec5 100644 --- a/petabtests/cases/v2.0.0/sbml/0017/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0017/_measurements.tsv @@ -1,3 +1,3 @@ -observableId preequilibrationConditionId simulationConditionId time measurement -obs_a preeq_c0 c0 1 0.7 -obs_a preeq_c0 c0 10 0.1 +experimentId observableId time measurement +experiment_preeq_c0_c0 obs_a 1 0.7 +experiment_preeq_c0_c0 obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0017/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0017/experiments.tsv new file mode 100644 index 0000000..78d6328 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0017/experiments.tsv @@ -0,0 +1,3 @@ +experimentId conditionId time +experiment_preeq_c0_c0 preeq_c0 -inf +experiment_preeq_c0_c0 c0 0.0 diff --git a/petabtests/cases/v2.0.0/sbml/0018/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0018/_measurements.tsv index b3885d3..f358b0e 100644 --- a/petabtests/cases/v2.0.0/sbml/0018/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0018/_measurements.tsv @@ -1,5 +1,5 @@ -observableId preequilibrationConditionId simulationConditionId time measurement -obs_a preeq_c0 c0 0 0.1 -obs_a preeq_c0 c0 1 0.7 -obs_a preeq_c0 c0 10 0.1 -obs_b preeq_c0 c0 0 0.1 +experimentId observableId time measurement +experiment_preeq_c0_c0 obs_a 0 0.1 +experiment_preeq_c0_c0 obs_a 1 0.7 +experiment_preeq_c0_c0 obs_a 10 0.1 +experiment_preeq_c0_c0 obs_b 0 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0018/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0018/experiments.tsv new file mode 100644 index 0000000..78d6328 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0018/experiments.tsv @@ -0,0 +1,3 @@ +experimentId conditionId time +experiment_preeq_c0_c0 preeq_c0 -inf +experiment_preeq_c0_c0 c0 0.0 diff --git a/petabtests/cases/v2.0.0/sbml/0019/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0019/_measurements.tsv index a497632..25969da 100644 --- a/petabtests/cases/v2.0.0/sbml/0019/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0019/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement +observableId experimentId time measurement obs_a c0 0 0.7 obs_a c0 10 0.1 From fc17260df2779819ede1e9a4e286ac696695972b Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 18 Dec 2024 19:44:05 +0100 Subject: [PATCH 03/17] .. --- petabtests/cases/v2.0.0/pysb/0001/0001.py | 53 +++++----------- petabtests/cases/v2.0.0/pysb/0001/_0001.yaml | 4 +- .../cases/v2.0.0/pysb/0001/_measurements.tsv | 6 +- .../cases/v2.0.0/pysb/0001/_parameters.tsv | 10 +-- .../cases/v2.0.0/pysb/0001/_simulations.tsv | 6 +- petabtests/cases/v2.0.0/pysb/0003/0003.py | 62 +++++++------------ petabtests/cases/v2.0.0/pysb/0003/_0003.yaml | 4 +- .../cases/v2.0.0/pysb/0003/_measurements.tsv | 6 +- .../cases/v2.0.0/pysb/0003/_parameters.tsv | 10 +-- .../cases/v2.0.0/pysb/0003/_simulations.tsv | 6 +- .../{experiments.tsv => _experiments.tsv} | 0 .../{experiments.tsv => _experiments.tsv} | 0 .../{experiments.tsv => _experiments.tsv} | 0 .../experiments.tsv => 0005/_experiments.tsv} | 0 .../{experiments.tsv => _experiments.tsv} | 0 .../{experiments.tsv => _experiments.tsv} | 0 .../{experiments.tsv => _experiments.tsv} | 0 .../{experiments.tsv => _experiments.tsv} | 0 .../{experiments.tsv => _experiments.tsv} | 0 .../{experiments.tsv => _experiments.tsv} | 0 .../{experiments.tsv => _experiments.tsv} | 0 .../{experiments.tsv => _experiments.tsv} | 0 .../{experiments.tsv => _experiments.tsv} | 0 .../{experiments.tsv => _experiments.tsv} | 0 .../{experiments.tsv => _experiments.tsv} | 0 .../{experiments.tsv => _experiments.tsv} | 0 .../{experiments.tsv => _experiments.tsv} | 0 petabtests/cases/v2.0.0/sbml/0019/_0019.yaml | 1 + .../cases/v2.0.0/sbml/0019/_conditions.tsv | 2 - .../cases/v2.0.0/sbml/0019/_simulations.tsv | 2 +- .../experiments.tsv => 0020/_experiments.tsv} | 1 - .../cases/v2.0.0/sbml/0020/_measurements.tsv | 6 +- petabtests/core.py | 12 +++- petabtests/file.py | 37 ++++++++++- pyproject.toml | 2 +- 35 files changed, 114 insertions(+), 116 deletions(-) rename petabtests/cases/v2.0.0/sbml/0001/{experiments.tsv => _experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/0003/{experiments.tsv => _experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/0004/{experiments.tsv => _experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/{0002/experiments.tsv => 0005/_experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/0006/{experiments.tsv => _experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/0007/{experiments.tsv => _experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/0008/{experiments.tsv => _experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/0009/{experiments.tsv => _experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/0010/{experiments.tsv => _experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/0011/{experiments.tsv => _experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/0012/{experiments.tsv => _experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/0013/{experiments.tsv => _experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/0014/{experiments.tsv => _experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/0015/{experiments.tsv => _experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/0016/{experiments.tsv => _experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/0017/{experiments.tsv => _experiments.tsv} (100%) rename petabtests/cases/v2.0.0/sbml/0018/{experiments.tsv => _experiments.tsv} (100%) delete mode 100644 petabtests/cases/v2.0.0/sbml/0019/_conditions.tsv rename petabtests/cases/v2.0.0/sbml/{0005/experiments.tsv => 0020/_experiments.tsv} (72%) diff --git a/petabtests/cases/v2.0.0/pysb/0001/0001.py b/petabtests/cases/v2.0.0/pysb/0001/0001.py index e7024ea..353224b 100644 --- a/petabtests/cases/v2.0.0/pysb/0001/0001.py +++ b/petabtests/cases/v2.0.0/pysb/0001/0001.py @@ -1,9 +1,8 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * - from petabtests import DEFAULT_PYSB_FILE, PetabTestCase, analytical_a +from petab.v2 import Problem +from petab.v2.C import * DESCRIPTION = cleandoc(""" ## Objective @@ -19,43 +18,21 @@ # problem -------------------------------------------------------------------- -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0"], - } -).set_index([CONDITION_ID]) +problem = Problem() -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [0, 10], - MEASUREMENT: [0.7, 0.1], - } -) +problem.add_observable("obs_a", "A", noise_formula=0.5) -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["A"], - NOISE_FORMULA: [0.5], - } -).set_index([OBSERVABLE_ID]) +problem.add_measurement("obs_a", "", time=0, measurement=0.7) +problem.add_measurement("obs_a", "", time=10, measurement=0.1) -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["a0", "b0", "k1", "k2"], - PARAMETER_SCALE: [LIN] * 4, - LOWER_BOUND: [0] * 4, - UPPER_BOUND: [10] * 4, - NOMINAL_VALUE: [1, 0, 0.8, 0.6], - ESTIMATE: [1] * 4, - } -).set_index(PARAMETER_ID) +problem.add_parameter("a0", lb=0, ub=10, nominal_value=1, scale=LIN) +problem.add_parameter("b0", lb=0, ub=10, nominal_value=0, scale=LIN) +problem.add_parameter("k1", lb=0, ub=10, nominal_value=0.8, scale=LIN) +problem.add_parameter("k2", lb=0, ub=10, nominal_value=0.6, scale=LIN) # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) simulation_df[SIMULATION] = [ @@ -68,9 +45,9 @@ brief="Simulation. Nothing special.", description=DESCRIPTION, model=DEFAULT_PYSB_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, + parameter_df=problem.parameter_df, ) diff --git a/petabtests/cases/v2.0.0/pysb/0001/_0001.yaml b/petabtests/cases/v2.0.0/pysb/0001/_0001.yaml index 493b4f8..1ce7ed6 100644 --- a/petabtests/cases/v2.0.0/pysb/0001/_0001.yaml +++ b/petabtests/cases/v2.0.0/pysb/0001/_0001.yaml @@ -1,8 +1,8 @@ format_version: 2.0.0 parameter_file: _parameters.tsv problems: -- condition_files: - - _conditions.tsv +- condition_files: [] + experiment_files: [] measurement_files: - _measurements.tsv model_files: diff --git a/petabtests/cases/v2.0.0/pysb/0001/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0001/_measurements.tsv index a497632..59bd3e4 100644 --- a/petabtests/cases/v2.0.0/pysb/0001/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0001/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 +observableId experimentId time measurement +obs_a 0 0.7 +obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/pysb/0001/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0001/_parameters.tsv index 8c1e5cb..9ead8dd 100644 --- a/petabtests/cases/v2.0.0/pysb/0001/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0001/_parameters.tsv @@ -1,5 +1,5 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -a0 lin 0 10 1.0 1 -b0 lin 0 10 0.0 1 -k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +a0 1 1.0 lin 0 10 +b0 1 0.0 lin 0 10 +k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0001/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0001/_simulations.tsv index c1339e4..8322fe9 100644 --- a/petabtests/cases/v2.0.0/pysb/0001/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0001/_simulations.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time simulation -obs_a c0 0 1.0 -obs_a c0 10 0.42857190373069665 +observableId experimentId time simulation +obs_a 0 1.0 +obs_a 10 0.42857190373069665 diff --git a/petabtests/cases/v2.0.0/pysb/0003/0003.py b/petabtests/cases/v2.0.0/pysb/0003/0003.py index d0fde50..018a2e3 100644 --- a/petabtests/cases/v2.0.0/pysb/0003/0003.py +++ b/petabtests/cases/v2.0.0/pysb/0003/0003.py @@ -1,7 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import DEFAULT_PYSB_FILE, PetabTestCase, analytical_a @@ -24,47 +24,29 @@ """) # problem -------------------------------------------------------------------- +problem = Problem() -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0"], - } -).set_index([CONDITION_ID]) - -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [0, 10], - MEASUREMENT: [0.7, 0.1], - OBSERVABLE_PARAMETERS: ["0.5;2", "0.5;2"], - } +problem.add_observable( + "obs_a", + "observableParameter1_obs_a * A + observableParameter2_obs_a", + noise_formula=0.5, ) -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: [ - "observableParameter1_obs_a * A + " "observableParameter2_obs_a" - ], - NOISE_FORMULA: [0.5], - } -).set_index([OBSERVABLE_ID]) +problem.add_measurement( + "obs_a", "", time=0, measurement=0.7, observable_parameters=(0.5, 2) +) +problem.add_measurement( + "obs_a", "", time=10, measurement=0.1, observable_parameters=(0.5, 2) +) -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["a0", "b0", "k1", "k2"], - PARAMETER_SCALE: [LIN] * 4, - LOWER_BOUND: [0] * 4, - UPPER_BOUND: [10] * 4, - NOMINAL_VALUE: [1, 0, 0.8, 0.6], - ESTIMATE: [1] * 4, - } -).set_index(PARAMETER_ID) +problem.add_parameter("a0", lb=0, ub=10, nominal_value=1, scale=LIN) +problem.add_parameter("b0", lb=0, ub=10, nominal_value=0, scale=LIN) +problem.add_parameter("k1", lb=0, ub=10, nominal_value=0.8, scale=LIN) +problem.add_parameter("k2", lb=0, ub=10, nominal_value=0.6, scale=LIN) # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) simulation_df[SIMULATION] = [ @@ -77,9 +59,9 @@ "table.", description=DESCRIPTION, model=DEFAULT_PYSB_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, + parameter_df=problem.parameter_df, ) diff --git a/petabtests/cases/v2.0.0/pysb/0003/_0003.yaml b/petabtests/cases/v2.0.0/pysb/0003/_0003.yaml index 493b4f8..1ce7ed6 100644 --- a/petabtests/cases/v2.0.0/pysb/0003/_0003.yaml +++ b/petabtests/cases/v2.0.0/pysb/0003/_0003.yaml @@ -1,8 +1,8 @@ format_version: 2.0.0 parameter_file: _parameters.tsv problems: -- condition_files: - - _conditions.tsv +- condition_files: [] + experiment_files: [] measurement_files: - _measurements.tsv model_files: diff --git a/petabtests/cases/v2.0.0/pysb/0003/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0003/_measurements.tsv index 2078ec7..c8a4604 100644 --- a/petabtests/cases/v2.0.0/pysb/0003/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0003/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement observableParameters -obs_a c0 0 0.7 0.5;2 -obs_a c0 10 0.1 0.5;2 +observableId experimentId time measurement observableParameters +obs_a 0 0.7 0.5;2 +obs_a 10 0.1 0.5;2 diff --git a/petabtests/cases/v2.0.0/pysb/0003/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0003/_parameters.tsv index 8c1e5cb..9ead8dd 100644 --- a/petabtests/cases/v2.0.0/pysb/0003/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0003/_parameters.tsv @@ -1,5 +1,5 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -a0 lin 0 10 1.0 1 -b0 lin 0 10 0.0 1 -k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +a0 1 1.0 lin 0 10 +b0 1 0.0 lin 0 10 +k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0003/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0003/_simulations.tsv index 79750a3..740f13a 100644 --- a/petabtests/cases/v2.0.0/pysb/0003/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0003/_simulations.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time simulation observableParameters -obs_a c0 0 2.5 0.5;2 -obs_a c0 10 2.214285951865348 0.5;2 +observableId experimentId time simulation observableParameters +obs_a 0 2.5 0.5;2 +obs_a 10 2.214285951865348 0.5;2 diff --git a/petabtests/cases/v2.0.0/sbml/0001/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0001/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0001/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0001/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0003/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0003/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0003/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0003/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0004/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0004/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0004/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0004/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0002/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0005/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0002/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0005/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0006/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0006/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0006/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0006/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0007/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0007/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0007/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0007/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0008/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0008/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0008/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0008/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0009/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0009/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0009/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0009/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0010/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0010/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0010/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0010/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0011/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0011/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0011/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0011/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0012/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0012/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0012/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0012/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0013/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0013/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0013/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0013/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0014/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0014/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0014/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0014/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0015/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0015/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0015/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0015/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0016/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0016/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0016/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0016/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0017/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0017/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0017/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0017/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0018/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0018/_experiments.tsv similarity index 100% rename from petabtests/cases/v2.0.0/sbml/0018/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0018/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0019/_0019.yaml b/petabtests/cases/v2.0.0/sbml/0019/_0019.yaml index 5e75a23..86402e6 100644 --- a/petabtests/cases/v2.0.0/sbml/0019/_0019.yaml +++ b/petabtests/cases/v2.0.0/sbml/0019/_0019.yaml @@ -2,6 +2,7 @@ format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: [] + experiment_files: [] mapping_files: - _mapping.tsv measurement_files: diff --git a/petabtests/cases/v2.0.0/sbml/0019/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0019/_conditions.tsv deleted file mode 100644 index f15e327..0000000 --- a/petabtests/cases/v2.0.0/sbml/0019/_conditions.tsv +++ /dev/null @@ -1,2 +0,0 @@ -conditionId -c0 diff --git a/petabtests/cases/v2.0.0/sbml/0019/_simulations.tsv b/petabtests/cases/v2.0.0/sbml/0019/_simulations.tsv index c1339e4..3b04603 100644 --- a/petabtests/cases/v2.0.0/sbml/0019/_simulations.tsv +++ b/petabtests/cases/v2.0.0/sbml/0019/_simulations.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time simulation +observableId experimentId time simulation obs_a c0 0 1.0 obs_a c0 10 0.42857190373069665 diff --git a/petabtests/cases/v2.0.0/sbml/0005/experiments.tsv b/petabtests/cases/v2.0.0/sbml/0020/_experiments.tsv similarity index 72% rename from petabtests/cases/v2.0.0/sbml/0005/experiments.tsv rename to petabtests/cases/v2.0.0/sbml/0020/_experiments.tsv index 288f9cd..774db85 100644 --- a/petabtests/cases/v2.0.0/sbml/0005/experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0020/_experiments.tsv @@ -1,3 +1,2 @@ experimentId conditionId time experiment_c0 c0 0 -experiment_c1 c1 0 diff --git a/petabtests/cases/v2.0.0/sbml/0020/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0020/_measurements.tsv index a497632..35939b8 100644 --- a/petabtests/cases/v2.0.0/sbml/0020/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0020/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 +experimentId observableId time measurement +experiment_c0 obs_a 0 0.7 +experiment_c0 obs_a 10 0.1 diff --git a/petabtests/core.py b/petabtests/core.py index 9812977..befeb52 100644 --- a/petabtests/core.py +++ b/petabtests/core.py @@ -54,7 +54,9 @@ def create(): case_dir = get_case_dir( format_=format_, version=version, id_=case_id ) - logger.info("# ", format_, version, case_id, case_dir) + logger.info( + f"Processing {version}/{format_} #{case_id} at {case_dir}" + ) # load test case module # directory needs to be removed from path again and the module @@ -76,6 +78,7 @@ def create(): test_id=case.id, parameter_df=case.parameter_df, condition_dfs=case.condition_dfs, + experiment_dfs=case.experiment_dfs, observable_dfs=case.observable_dfs, measurement_dfs=case.measurement_dfs, model_files=case.model, @@ -125,3 +128,10 @@ def clear(): for file_ in os.scandir(case_dir): if file_.name.startswith("_") and not file_.is_dir(): os.remove(file_.path) + + +def _cli_create(): + """`petabtests_create` entry point.""" + # initialize logging + logging.basicConfig(level=logging.INFO) + create() diff --git a/petabtests/file.py b/petabtests/file.py index 2779299..bb540ba 100644 --- a/petabtests/file.py +++ b/petabtests/file.py @@ -11,6 +11,12 @@ import yaml from petab.v1.C import * # noqa: F403 from .C import * # noqa: F403 +from pprint import pprint +import logging +from petab.v2.C import EXPERIMENT_FILES + +logger = logging.getLogger("petab_test_suite") + __all__ = [ "get_case_dir", @@ -39,6 +45,7 @@ class PetabTestCase: simulation_dfs: list[pd.DataFrame] parameter_df: pd.DataFrame mapping_df: pd.DataFrame = None + experiment_dfs: list[pd.DataFrame] = None def get_case_dir(id_: int | str, format_: str, version: str) -> Path: @@ -76,6 +83,7 @@ def write_problem( test_id: int, parameter_df: pd.DataFrame, condition_dfs: list[pd.DataFrame] | pd.DataFrame, + experiment_dfs: list[pd.DataFrame] | pd.DataFrame, observable_dfs: list[pd.DataFrame] | pd.DataFrame, measurement_dfs: list[pd.DataFrame] | pd.DataFrame, model_files: list[Path] | Path, @@ -90,6 +98,7 @@ def write_problem( test_id: Identifier of the test. parameter_df: PEtab parameter table. condition_dfs: PEtab condition tables. + experiment_dfs: PEtab experiment tables. observable_dfs: PEtab observable tables. measurement_dfs: PEtab measurement tables. model_files: PEtab SBML/PySB files. @@ -163,6 +172,7 @@ def write_problem( else: petab = v2 config[PROBLEMS][0][MODEL_FILES] = {} + config[PROBLEMS][0][EXPERIMENT_FILES] = [] for model_idx, model_file in enumerate(copied_model_files): config[PROBLEMS][0][MODEL_FILES][f"model_{model_idx}"] = { MODEL_LANGUAGE: format_, @@ -201,6 +211,16 @@ def write_problem( config[PROBLEMS][0][MEASUREMENT_FILES], ) + # write experiments + if experiment_dfs is not None: + _write_dfs_to_files( + dir_, + "experiments", + v2.write_experiment_df, + experiment_dfs, + config[PROBLEMS][0][EXPERIMENT_FILES], + ) + if format_version != 1 and mapping_df is not None: # write mapping table mappings_file = "_mapping.tsv" @@ -225,7 +245,15 @@ def write_problem( ): from petab.v2.petab1to2 import petab1to2 + # delete previously auto-generated experiments.tsv + exp_file = Path(dir_, "_experiments.tsv") + if exp_file.exists(): + exp_file.unlink() petab1to2(yaml_path, dir_) + # rename auto-generated experiments.tsv + tmp_exp_file = Path(dir_, "experiments.tsv") + if tmp_exp_file.exists(): + tmp_exp_file.rename(exp_file) format_version = 2 # FIXME Until a first libpetab with petab.v1 subpackage is released @@ -244,9 +272,11 @@ def write_problem( ) else: # v2 - validation_result = lint_problem_v2(yaml_path) - if validation_result: - print(validation_result) + validation_results = lint_problem_v2(yaml_path) + if validation_results: + logger.error(f"Validation failed for {dir_}:") + for issue in validation_results: + pprint(issue) raise RuntimeError( "Invalid PEtab problem, see messages above." ) @@ -322,6 +352,7 @@ def _write_dfs_to_files( config_list: list[str] = None, ): """Write data frames to files and add them to config.""" + dfs = [df for df in dfs if df is not None] for idx, df in enumerate(dfs): if len(dfs) == 1: idx = "" diff --git a/pyproject.toml b/pyproject.toml index 4a4f54b..ec12816 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ dependencies = [ homepage = "https://github.com/PEtab-dev/petab_test_suite" [project.scripts] -petabtests_create = "petabtests.core:create" +petabtests_create = "petabtests.core:_cli_create" petabtests_clear = "petabtests.core:clear" From b098ea06a00f02816dc054744bee683d599c9467 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 18 Dec 2024 21:56:21 +0100 Subject: [PATCH 04/17] refactor --- petabtests/core.py | 117 ++++++++++++++++++++++++------------------ petabtests/file.py | 8 ++- test/test_generate.py | 4 +- 3 files changed, 75 insertions(+), 54 deletions(-) diff --git a/petabtests/core.py b/petabtests/core.py index befeb52..c9b93af 100644 --- a/petabtests/core.py +++ b/petabtests/core.py @@ -5,6 +5,7 @@ import re import sys from pathlib import Path +from collections.abc import Iterable from petab.v1.calculate import calculate_chi2, calculate_llh @@ -18,7 +19,7 @@ write_solution, ) -__all__ = ["get_cases", "create", "clear", "get_cases_dir"] +__all__ = ["get_cases", "create_all", "clear", "get_cases_dir"] test_formats = ("sbml", "pysb") test_versions = ("v1.0.0", "v2.0.0") @@ -27,10 +28,14 @@ def get_cases_dir(format_: str, version: str) -> Path: + """Get the directory of the test cases for the given PEtab version and + model format.""" return CASES_DIR / version / format_ -def get_cases(format_: str, version: str): +def get_cases(format_: str, version: str) -> Iterable[str]: + """Get the list of test case IDs for the given PEtab version and model + format.""" cases_dir = get_cases_dir(format_=format_, version=version) if not cases_dir.exists(): return [] @@ -41,13 +46,15 @@ def get_cases(format_: str, version: str): ) -def create(): +def create_all(): """Create all test files.""" for version, format_ in itertools.product(test_versions, test_formats): case_list = get_cases(format_=format_, version=version) if not case_list: continue + # Table of contents markdown string for the current format x version + # directory README toc = "" for case_id in case_list: @@ -58,55 +65,12 @@ def create(): f"Processing {version}/{format_} #{case_id} at {case_dir}" ) - # load test case module - # directory needs to be removed from path again and the module - # has to be unloaded, as modules from different model format - # suites have the same name - sys.path.append(str(case_dir)) - case_module = importlib.import_module(case_id) - sys.path.pop() - # noinspection PyUnresolvedReferences - case: PetabTestCase = case_module.case - del sys.modules[case_id] + case = load_case(case_dir, case_id) id_str = test_id_str(case.id) toc += f"# [{id_str}]({id_str}/)\n\n{case.brief}\n\n" - write_info(case, format_, version=version) - - write_problem( - test_id=case.id, - parameter_df=case.parameter_df, - condition_dfs=case.condition_dfs, - experiment_dfs=case.experiment_dfs, - observable_dfs=case.observable_dfs, - measurement_dfs=case.measurement_dfs, - model_files=case.model, - format_=format_, - version=version, - mapping_df=case.mapping_df, - ) - - chi2 = calculate_chi2( - case.measurement_dfs, - case.simulation_dfs, - case.observable_dfs, - case.parameter_df, - ) - llh = calculate_llh( - case.measurement_dfs, - case.simulation_dfs, - case.observable_dfs, - case.parameter_df, - ) - write_solution( - test_id=case.id, - chi2=chi2, - llh=llh, - simulation_dfs=case.simulation_dfs, - format_=format_, - version=version, - ) + create_case(format_, version, case_id) toc_path = ( get_cases_dir(format_=format_, version=version) / "README.md" @@ -115,7 +79,60 @@ def create(): f.write(toc) -def clear(): +def load_case(case_dir: Path, case_id: str) -> PetabTestCase: + """Load a test case definition module.""" + sys.path.append(str(case_dir)) + case_module = importlib.import_module(case_id) + sys.path.pop() + # noinspection PyUnresolvedReferences + case: PetabTestCase = case_module.case + del sys.modules[case_id] + return case + + +def create_case(format_: str, version: str, id_: str) -> None: + """Create a single test case.""" + case_dir = get_case_dir(format_=format_, version=version, id_=id_) + case = load_case(case_dir, id_) + + write_info(case, format_, version=version) + + write_problem( + test_id=case.id, + parameter_df=case.parameter_df, + condition_dfs=case.condition_dfs, + experiment_dfs=case.experiment_dfs, + observable_dfs=case.observable_dfs, + measurement_dfs=case.measurement_dfs, + model_files=case.model, + format_=format_, + version=version, + mapping_df=case.mapping_df, + ) + + chi2 = calculate_chi2( + case.measurement_dfs, + case.simulation_dfs, + case.observable_dfs, + case.parameter_df, + ) + llh = calculate_llh( + case.measurement_dfs, + case.simulation_dfs, + case.observable_dfs, + case.parameter_df, + ) + write_solution( + test_id=case.id, + chi2=chi2, + llh=llh, + simulation_dfs=case.simulation_dfs, + format_=format_, + version=version, + ) + + +def clear() -> None: """Clear all model folders.""" for version, format_ in itertools.product(test_versions, test_formats): case_list = get_cases(format_=format_, version=version) @@ -134,4 +151,4 @@ def _cli_create(): """`petabtests_create` entry point.""" # initialize logging logging.basicConfig(level=logging.INFO) - create() + create_all() diff --git a/petabtests/file.py b/petabtests/file.py index bb540ba..4219be2 100644 --- a/petabtests/file.py +++ b/petabtests/file.py @@ -49,6 +49,7 @@ class PetabTestCase: def get_case_dir(id_: int | str, format_: str, version: str) -> Path: + """Get the directory of a test case.""" id_str = test_id_str(id_) dir_ = CASES_DIR / version / format_ / id_str dir_.mkdir(parents=True, exist_ok=True) @@ -56,18 +57,21 @@ def get_case_dir(id_: int | str, format_: str, version: str) -> Path: def problem_yaml_name(_id: int | str) -> str: + """Get the name of the problem yaml file.""" return "_" + test_id_str(_id) + ".yaml" def solution_yaml_name(_id: int | str) -> str: + """Get the name of the solution yaml file.""" return "_" + test_id_str(_id) + "_solution.yaml" def test_id_str(_id: int | str) -> str: + """Get the test id as a string.""" return f"{_id:0>4}" -def write_info(case: PetabTestCase, format_: str, version: str): +def write_info(case: PetabTestCase, format_: str, version: str) -> None: """Write test info markdown file""" # id to string dir_ = get_case_dir(id_=case.id, format_=format_, version=version) @@ -91,7 +95,7 @@ def write_problem( mapping_df: pd.DataFrame = None, format_: str = "sbml", ) -> None: - """Write problem to files. + """Write the PEtab problem for a given test to files. Parameters ---------- diff --git a/test/test_generate.py b/test/test_generate.py index 40238be..3b76cb4 100644 --- a/test/test_generate.py +++ b/test/test_generate.py @@ -1,4 +1,4 @@ -from petabtests.core import create +from petabtests.core import create_all from petabtests.C import CASES_DIR import sys @@ -7,7 +7,7 @@ def test_check_cases_up_to_date(): sys.path.insert(0, CASES_DIR) - create() + create_all() res = subprocess.run( ["git", "diff", "--exit-code", CASES_DIR], capture_output=True ) From 1e5328a32e173453f2f2fdcbd025f28142a29251 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 18 Dec 2024 22:11:06 +0100 Subject: [PATCH 05/17] updated experiment ids --- petabtests/cases/v2.0.0/sbml/0001/_experiments.tsv | 2 +- petabtests/cases/v2.0.0/sbml/0002/_experiments.tsv | 3 +++ petabtests/cases/v2.0.0/sbml/0002/_measurements.tsv | 8 ++++---- petabtests/cases/v2.0.0/sbml/0003/_experiments.tsv | 2 +- petabtests/cases/v2.0.0/sbml/0004/_experiments.tsv | 2 +- petabtests/cases/v2.0.0/sbml/0005/_experiments.tsv | 4 ++-- petabtests/cases/v2.0.0/sbml/0005/_measurements.tsv | 4 ++-- petabtests/cases/v2.0.0/sbml/0006/_experiments.tsv | 2 +- petabtests/cases/v2.0.0/sbml/0007/_experiments.tsv | 2 +- petabtests/cases/v2.0.0/sbml/0008/_experiments.tsv | 2 +- petabtests/cases/v2.0.0/sbml/0009/_experiments.tsv | 4 ++-- petabtests/cases/v2.0.0/sbml/0009/_measurements.tsv | 4 ++-- petabtests/cases/v2.0.0/sbml/0010/_experiments.tsv | 4 ++-- petabtests/cases/v2.0.0/sbml/0010/_measurements.tsv | 4 ++-- petabtests/cases/v2.0.0/sbml/0011/_experiments.tsv | 2 +- petabtests/cases/v2.0.0/sbml/0011/_measurements.tsv | 4 ++-- petabtests/cases/v2.0.0/sbml/0012/_experiments.tsv | 2 +- petabtests/cases/v2.0.0/sbml/0012/_measurements.tsv | 4 ++-- petabtests/cases/v2.0.0/sbml/0013/_experiments.tsv | 2 +- petabtests/cases/v2.0.0/sbml/0013/_measurements.tsv | 4 ++-- petabtests/cases/v2.0.0/sbml/0014/_experiments.tsv | 2 +- petabtests/cases/v2.0.0/sbml/0015/_experiments.tsv | 2 +- petabtests/cases/v2.0.0/sbml/0016/_experiments.tsv | 2 +- petabtests/cases/v2.0.0/sbml/0017/_experiments.tsv | 4 ++-- petabtests/cases/v2.0.0/sbml/0017/_measurements.tsv | 4 ++-- petabtests/cases/v2.0.0/sbml/0018/_experiments.tsv | 4 ++-- petabtests/cases/v2.0.0/sbml/0018/_measurements.tsv | 8 ++++---- petabtests/cases/v2.0.0/sbml/0019/_0019_solution.yaml | 2 +- petabtests/cases/v2.0.0/sbml/0020/_experiments.tsv | 2 +- petabtests/cases/v2.0.0/sbml/0020/_measurements.tsv | 4 ++-- petabtests/cases/v2.0.0/sbml/0021/_0021.yaml | 8 ++++---- petabtests/cases/v2.0.0/sbml/0021/_0021_solution.yaml | 2 +- petabtests/cases/v2.0.0/sbml/0021/_conditions.tsv | 1 - petabtests/cases/v2.0.0/sbml/0021/_measurements.tsv | 2 +- petabtests/cases/v2.0.0/sbml/0021/_simulations.tsv | 2 +- 35 files changed, 58 insertions(+), 56 deletions(-) create mode 100644 petabtests/cases/v2.0.0/sbml/0002/_experiments.tsv delete mode 100644 petabtests/cases/v2.0.0/sbml/0021/_conditions.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0001/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0001/_experiments.tsv index 774db85..9ae6a66 100644 --- a/petabtests/cases/v2.0.0/sbml/0001/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0001/_experiments.tsv @@ -1,2 +1,2 @@ experimentId conditionId time -experiment_c0 c0 0 +experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0002/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0002/_experiments.tsv new file mode 100644 index 0000000..a566778 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0002/_experiments.tsv @@ -0,0 +1,3 @@ +experimentId conditionId time +experiment____c0 c0 0 +experiment____c1 c1 0 diff --git a/petabtests/cases/v2.0.0/sbml/0002/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0002/_measurements.tsv index fd40b31..39c08e4 100644 --- a/petabtests/cases/v2.0.0/sbml/0002/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0002/_measurements.tsv @@ -1,5 +1,5 @@ experimentId observableId time measurement -experiment_c0 obs_a 0 0.7 -experiment_c0 obs_a 10 0.1 -experiment_c1 obs_a 0 0.8 -experiment_c1 obs_a 10 0.2 +experiment____c0 obs_a 0 0.7 +experiment____c0 obs_a 10 0.1 +experiment____c1 obs_a 0 0.8 +experiment____c1 obs_a 10 0.2 diff --git a/petabtests/cases/v2.0.0/sbml/0003/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0003/_experiments.tsv index 774db85..9ae6a66 100644 --- a/petabtests/cases/v2.0.0/sbml/0003/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0003/_experiments.tsv @@ -1,2 +1,2 @@ experimentId conditionId time -experiment_c0 c0 0 +experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0004/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0004/_experiments.tsv index 774db85..9ae6a66 100644 --- a/petabtests/cases/v2.0.0/sbml/0004/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0004/_experiments.tsv @@ -1,2 +1,2 @@ experimentId conditionId time -experiment_c0 c0 0 +experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0005/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0005/_experiments.tsv index 288f9cd..a566778 100644 --- a/petabtests/cases/v2.0.0/sbml/0005/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0005/_experiments.tsv @@ -1,3 +1,3 @@ experimentId conditionId time -experiment_c0 c0 0 -experiment_c1 c1 0 +experiment____c0 c0 0 +experiment____c1 c1 0 diff --git a/petabtests/cases/v2.0.0/sbml/0005/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0005/_measurements.tsv index 44f6f85..768a004 100644 --- a/petabtests/cases/v2.0.0/sbml/0005/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0005/_measurements.tsv @@ -1,3 +1,3 @@ experimentId observableId time measurement -experiment_c0 obs_a 10 2.1 -experiment_c1 obs_a 10 3.2 +experiment____c0 obs_a 10 2.1 +experiment____c1 obs_a 10 3.2 diff --git a/petabtests/cases/v2.0.0/sbml/0006/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0006/_experiments.tsv index 774db85..9ae6a66 100644 --- a/petabtests/cases/v2.0.0/sbml/0006/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0006/_experiments.tsv @@ -1,2 +1,2 @@ experimentId conditionId time -experiment_c0 c0 0 +experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0007/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0007/_experiments.tsv index 774db85..9ae6a66 100644 --- a/petabtests/cases/v2.0.0/sbml/0007/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0007/_experiments.tsv @@ -1,2 +1,2 @@ experimentId conditionId time -experiment_c0 c0 0 +experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0008/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0008/_experiments.tsv index 774db85..9ae6a66 100644 --- a/petabtests/cases/v2.0.0/sbml/0008/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0008/_experiments.tsv @@ -1,2 +1,2 @@ experimentId conditionId time -experiment_c0 c0 0 +experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0009/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0009/_experiments.tsv index 78d6328..998f34d 100644 --- a/petabtests/cases/v2.0.0/sbml/0009/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0009/_experiments.tsv @@ -1,3 +1,3 @@ experimentId conditionId time -experiment_preeq_c0_c0 preeq_c0 -inf -experiment_preeq_c0_c0 c0 0.0 +experiment__preeq_c0___c0 preeq_c0 -inf +experiment__preeq_c0___c0 c0 0.0 diff --git a/petabtests/cases/v2.0.0/sbml/0009/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0009/_measurements.tsv index bb1fec5..0537f02 100644 --- a/petabtests/cases/v2.0.0/sbml/0009/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0009/_measurements.tsv @@ -1,3 +1,3 @@ experimentId observableId time measurement -experiment_preeq_c0_c0 obs_a 1 0.7 -experiment_preeq_c0_c0 obs_a 10 0.1 +experiment__preeq_c0___c0 obs_a 1 0.7 +experiment__preeq_c0___c0 obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0010/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0010/_experiments.tsv index 78d6328..998f34d 100644 --- a/petabtests/cases/v2.0.0/sbml/0010/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0010/_experiments.tsv @@ -1,3 +1,3 @@ experimentId conditionId time -experiment_preeq_c0_c0 preeq_c0 -inf -experiment_preeq_c0_c0 c0 0.0 +experiment__preeq_c0___c0 preeq_c0 -inf +experiment__preeq_c0___c0 c0 0.0 diff --git a/petabtests/cases/v2.0.0/sbml/0010/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0010/_measurements.tsv index bb1fec5..0537f02 100644 --- a/petabtests/cases/v2.0.0/sbml/0010/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0010/_measurements.tsv @@ -1,3 +1,3 @@ experimentId observableId time measurement -experiment_preeq_c0_c0 obs_a 1 0.7 -experiment_preeq_c0_c0 obs_a 10 0.1 +experiment__preeq_c0___c0 obs_a 1 0.7 +experiment__preeq_c0___c0 obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0011/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0011/_experiments.tsv index 774db85..9ae6a66 100644 --- a/petabtests/cases/v2.0.0/sbml/0011/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0011/_experiments.tsv @@ -1,2 +1,2 @@ experimentId conditionId time -experiment_c0 c0 0 +experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0011/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0011/_measurements.tsv index 35939b8..5a39812 100644 --- a/petabtests/cases/v2.0.0/sbml/0011/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0011/_measurements.tsv @@ -1,3 +1,3 @@ experimentId observableId time measurement -experiment_c0 obs_a 0 0.7 -experiment_c0 obs_a 10 0.1 +experiment____c0 obs_a 0 0.7 +experiment____c0 obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0012/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0012/_experiments.tsv index 774db85..9ae6a66 100644 --- a/petabtests/cases/v2.0.0/sbml/0012/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0012/_experiments.tsv @@ -1,2 +1,2 @@ experimentId conditionId time -experiment_c0 c0 0 +experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0012/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0012/_measurements.tsv index 35939b8..5a39812 100644 --- a/petabtests/cases/v2.0.0/sbml/0012/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0012/_measurements.tsv @@ -1,3 +1,3 @@ experimentId observableId time measurement -experiment_c0 obs_a 0 0.7 -experiment_c0 obs_a 10 0.1 +experiment____c0 obs_a 0 0.7 +experiment____c0 obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0013/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0013/_experiments.tsv index 774db85..9ae6a66 100644 --- a/petabtests/cases/v2.0.0/sbml/0013/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0013/_experiments.tsv @@ -1,2 +1,2 @@ experimentId conditionId time -experiment_c0 c0 0 +experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0013/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0013/_measurements.tsv index 35939b8..5a39812 100644 --- a/petabtests/cases/v2.0.0/sbml/0013/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0013/_measurements.tsv @@ -1,3 +1,3 @@ experimentId observableId time measurement -experiment_c0 obs_a 0 0.7 -experiment_c0 obs_a 10 0.1 +experiment____c0 obs_a 0 0.7 +experiment____c0 obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0014/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0014/_experiments.tsv index 774db85..9ae6a66 100644 --- a/petabtests/cases/v2.0.0/sbml/0014/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0014/_experiments.tsv @@ -1,2 +1,2 @@ experimentId conditionId time -experiment_c0 c0 0 +experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0015/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0015/_experiments.tsv index 774db85..9ae6a66 100644 --- a/petabtests/cases/v2.0.0/sbml/0015/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0015/_experiments.tsv @@ -1,2 +1,2 @@ experimentId conditionId time -experiment_c0 c0 0 +experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0016/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0016/_experiments.tsv index 774db85..9ae6a66 100644 --- a/petabtests/cases/v2.0.0/sbml/0016/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0016/_experiments.tsv @@ -1,2 +1,2 @@ experimentId conditionId time -experiment_c0 c0 0 +experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0017/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0017/_experiments.tsv index 78d6328..998f34d 100644 --- a/petabtests/cases/v2.0.0/sbml/0017/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0017/_experiments.tsv @@ -1,3 +1,3 @@ experimentId conditionId time -experiment_preeq_c0_c0 preeq_c0 -inf -experiment_preeq_c0_c0 c0 0.0 +experiment__preeq_c0___c0 preeq_c0 -inf +experiment__preeq_c0___c0 c0 0.0 diff --git a/petabtests/cases/v2.0.0/sbml/0017/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0017/_measurements.tsv index bb1fec5..0537f02 100644 --- a/petabtests/cases/v2.0.0/sbml/0017/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0017/_measurements.tsv @@ -1,3 +1,3 @@ experimentId observableId time measurement -experiment_preeq_c0_c0 obs_a 1 0.7 -experiment_preeq_c0_c0 obs_a 10 0.1 +experiment__preeq_c0___c0 obs_a 1 0.7 +experiment__preeq_c0___c0 obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0018/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0018/_experiments.tsv index 78d6328..998f34d 100644 --- a/petabtests/cases/v2.0.0/sbml/0018/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0018/_experiments.tsv @@ -1,3 +1,3 @@ experimentId conditionId time -experiment_preeq_c0_c0 preeq_c0 -inf -experiment_preeq_c0_c0 c0 0.0 +experiment__preeq_c0___c0 preeq_c0 -inf +experiment__preeq_c0___c0 c0 0.0 diff --git a/petabtests/cases/v2.0.0/sbml/0018/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0018/_measurements.tsv index f358b0e..5d9dabf 100644 --- a/petabtests/cases/v2.0.0/sbml/0018/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0018/_measurements.tsv @@ -1,5 +1,5 @@ experimentId observableId time measurement -experiment_preeq_c0_c0 obs_a 0 0.1 -experiment_preeq_c0_c0 obs_a 1 0.7 -experiment_preeq_c0_c0 obs_a 10 0.1 -experiment_preeq_c0_c0 obs_b 0 0.1 +experiment__preeq_c0___c0 obs_a 0 0.1 +experiment__preeq_c0___c0 obs_a 1 0.7 +experiment__preeq_c0___c0 obs_a 10 0.1 +experiment__preeq_c0___c0 obs_b 0 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0019/_0019_solution.yaml b/petabtests/cases/v2.0.0/sbml/0019/_0019_solution.yaml index 4a41272..1ee1c67 100644 --- a/petabtests/cases/v2.0.0/sbml/0019/_0019_solution.yaml +++ b/petabtests/cases/v2.0.0/sbml/0019/_0019_solution.yaml @@ -1,4 +1,4 @@ -chi2: 0.86367596736971 +chi2: 0.79183798368486 llh: -0.84750169713188 simulation_files: - _simulations.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0020/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0020/_experiments.tsv index 774db85..9ae6a66 100644 --- a/petabtests/cases/v2.0.0/sbml/0020/_experiments.tsv +++ b/petabtests/cases/v2.0.0/sbml/0020/_experiments.tsv @@ -1,2 +1,2 @@ experimentId conditionId time -experiment_c0 c0 0 +experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0020/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0020/_measurements.tsv index 35939b8..5a39812 100644 --- a/petabtests/cases/v2.0.0/sbml/0020/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0020/_measurements.tsv @@ -1,3 +1,3 @@ experimentId observableId time measurement -experiment_c0 obs_a 0 0.7 -experiment_c0 obs_a 10 0.1 +experiment____c0 obs_a 0 0.7 +experiment____c0 obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0021/_0021.yaml b/petabtests/cases/v2.0.0/sbml/0021/_0021.yaml index e988ca3..681b3f0 100644 --- a/petabtests/cases/v2.0.0/sbml/0021/_0021.yaml +++ b/petabtests/cases/v2.0.0/sbml/0021/_0021.yaml @@ -2,12 +2,12 @@ format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: [] + experiment_files: [] measurement_files: - _measurements.tsv - observable_files: - - _observables.tsv model_files: - _model: + model_0: language: sbml location: _model.xml -extensions: [] + observable_files: + - _observables.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0021/_0021_solution.yaml b/petabtests/cases/v2.0.0/sbml/0021/_0021_solution.yaml index a0060e6..fb2acef 100644 --- a/petabtests/cases/v2.0.0/sbml/0021/_0021_solution.yaml +++ b/petabtests/cases/v2.0.0/sbml/0021/_0021_solution.yaml @@ -1,4 +1,4 @@ -chi2: 0.04702225395579 +chi2: 0.0271111269779 llh: -4.22301170308364 simulation_files: - _simulations.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0021/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0021/_conditions.tsv deleted file mode 100644 index 3664278..0000000 --- a/petabtests/cases/v2.0.0/sbml/0021/_conditions.tsv +++ /dev/null @@ -1 +0,0 @@ -conditionId targetId valueType targetValue diff --git a/petabtests/cases/v2.0.0/sbml/0021/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0021/_measurements.tsv index c1ae0cc..96bf6a3 100644 --- a/petabtests/cases/v2.0.0/sbml/0021/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0021/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement noiseParameters +observableId experimentId time measurement noiseParameters obs_a 0 0.7 noise obs_a 10 0.1 noise diff --git a/petabtests/cases/v2.0.0/sbml/0021/_simulations.tsv b/petabtests/cases/v2.0.0/sbml/0021/_simulations.tsv index bc75731..69b0c9c 100644 --- a/petabtests/cases/v2.0.0/sbml/0021/_simulations.tsv +++ b/petabtests/cases/v2.0.0/sbml/0021/_simulations.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time simulation noiseParameters +observableId experimentId time simulation noiseParameters obs_a 0 1.0 noise obs_a 10 0.42857190373069665 noise From 5e29d3e3736df7f41b0c04246a656935a5749f30 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 18 Dec 2024 22:06:50 +0100 Subject: [PATCH 06/17] pysb0002 --- petabtests/cases/v2.0.0/pysb/0002/0002.py | 70 +++++++------------ petabtests/cases/v2.0.0/pysb/0002/_0002.yaml | 2 + .../cases/v2.0.0/pysb/0002/_conditions.tsv | 6 +- .../cases/v2.0.0/pysb/0002/_experiments.tsv | 3 + .../cases/v2.0.0/pysb/0002/_measurements.tsv | 10 +-- .../cases/v2.0.0/pysb/0002/_parameters.tsv | 6 +- .../cases/v2.0.0/pysb/0002/_simulations.tsv | 10 +-- test/test_generate.py | 13 ++++ 8 files changed, 61 insertions(+), 59 deletions(-) create mode 100644 petabtests/cases/v2.0.0/pysb/0002/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/pysb/0002/0002.py b/petabtests/cases/v2.0.0/pysb/0002/0002.py index a273e9d..9d23e86 100644 --- a/petabtests/cases/v2.0.0/pysb/0002/0002.py +++ b/petabtests/cases/v2.0.0/pysb/0002/0002.py @@ -1,8 +1,7 @@ from inspect import cleandoc -from math import nan -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import DEFAULT_PYSB_FILE, PetabTestCase, analytical_a @@ -24,61 +23,46 @@ """) # problem -------------------------------------------------------------------- +problem = Problem() -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0", "c1"], - "a0": [0.8, 0.9], - "b0": [nan, nan], - } -).set_index([CONDITION_ID]) - -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"] * 4, - SIMULATION_CONDITION_ID: ["c0", "c0", "c1", "c1"], - TIME: [0, 10, 0, 10], - MEASUREMENT: [0.7, 0.1, 0.8, 0.2], - } -) +problem.add_condition("c0", a0=(VT_INITIAL, 0.8)) +problem.add_condition("c1", a0=(VT_INITIAL, 0.9)) + +problem.add_experiment("e0", 0, "c0") +problem.add_experiment("e1", 0, "c1") -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["A"], - NOISE_FORMULA: [1], - } -).set_index([OBSERVABLE_ID]) - -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["k1", "k2"], - PARAMETER_SCALE: [LIN] * 2, - LOWER_BOUND: [0] * 2, - UPPER_BOUND: [10] * 2, - NOMINAL_VALUE: [0.8, 0.6], - ESTIMATE: [1] * 2, - } -).set_index(PARAMETER_ID) +problem.add_observable("obs_a", "A", noise_formula=1) + +problem.add_measurement("obs_a", "e0", time=0, measurement=0.7) +problem.add_measurement("obs_a", "e0", time=10, measurement=0.1) +problem.add_measurement("obs_a", "e1", time=0, measurement=0.8) +problem.add_measurement("obs_a", "e1", time=10, measurement=0.2) + +problem.add_parameter( + "k1", lb=0, ub=10, nominal_value=0.8, scale=LIN, estimate=True +) +problem.add_parameter( + "k2", lb=0, ub=10, nominal_value=0.6, scale=LIN, estimate=True +) # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) simulation_df[SIMULATION] = [ *[analytical_a(t, 0.8, 1, 0.8, 0.6) for t in [0, 10]], *[analytical_a(t, 0.9, 1, 0.8, 0.6) for t in [0, 10]], ] - case = PetabTestCase( id=2, brief="Simulation. Two conditions. Numeric parameter override.", description=DESCRIPTION, model=DEFAULT_PYSB_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, + experiment_dfs=[problem.experiment_df], + parameter_df=problem.parameter_df, ) diff --git a/petabtests/cases/v2.0.0/pysb/0002/_0002.yaml b/petabtests/cases/v2.0.0/pysb/0002/_0002.yaml index 493b4f8..4e0d35b 100644 --- a/petabtests/cases/v2.0.0/pysb/0002/_0002.yaml +++ b/petabtests/cases/v2.0.0/pysb/0002/_0002.yaml @@ -3,6 +3,8 @@ parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv model_files: diff --git a/petabtests/cases/v2.0.0/pysb/0002/_conditions.tsv b/petabtests/cases/v2.0.0/pysb/0002/_conditions.tsv index 6524332..ca94df2 100644 --- a/petabtests/cases/v2.0.0/pysb/0002/_conditions.tsv +++ b/petabtests/cases/v2.0.0/pysb/0002/_conditions.tsv @@ -1,3 +1,3 @@ -conditionId a0 b0 -c0 0.8 -c1 0.9 +conditionId targetId valueType targetValue +c0 a0 initial 0.8 +c1 a0 initial 0.9 diff --git a/petabtests/cases/v2.0.0/pysb/0002/_experiments.tsv b/petabtests/cases/v2.0.0/pysb/0002/_experiments.tsv new file mode 100644 index 0000000..e595c08 --- /dev/null +++ b/petabtests/cases/v2.0.0/pysb/0002/_experiments.tsv @@ -0,0 +1,3 @@ +experimentId time conditionId +e0 0 c0 +e1 0 c1 diff --git a/petabtests/cases/v2.0.0/pysb/0002/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0002/_measurements.tsv index 9dbc71c..af86813 100644 --- a/petabtests/cases/v2.0.0/pysb/0002/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0002/_measurements.tsv @@ -1,5 +1,5 @@ -observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 -obs_a c1 0 0.8 -obs_a c1 10 0.2 +observableId experimentId time measurement +obs_a e0 0 0.7 +obs_a e0 10 0.1 +obs_a e1 0 0.8 +obs_a e1 10 0.2 diff --git a/petabtests/cases/v2.0.0/pysb/0002/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0002/_parameters.tsv index bf45aa8..558a18a 100644 --- a/petabtests/cases/v2.0.0/pysb/0002/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0002/_parameters.tsv @@ -1,3 +1,3 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +k1 True 0.8 lin 0 10 +k2 True 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0002/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0002/_simulations.tsv index f9dbb59..bdb76bc 100644 --- a/petabtests/cases/v2.0.0/pysb/0002/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0002/_simulations.tsv @@ -1,5 +1,5 @@ -observableId simulationConditionId time simulation -obs_a c0 0 0.8 -obs_a c0 10 0.771428595186535 -obs_a c1 0 0.9 -obs_a c1 10 0.8142857855596045 +observableId experimentId time simulation +obs_a e0 0 0.8 +obs_a e0 10 0.771428595186535 +obs_a e1 0 0.9 +obs_a e1 10 0.8142857855596045 diff --git a/test/test_generate.py b/test/test_generate.py index 3b76cb4..ba5482f 100644 --- a/test/test_generate.py +++ b/test/test_generate.py @@ -4,6 +4,8 @@ import sys import subprocess +from petabtests.core import create_case + def test_check_cases_up_to_date(): sys.path.insert(0, CASES_DIR) @@ -13,3 +15,14 @@ def test_check_cases_up_to_date(): ) has_changes = res.returncode assert not has_changes, res.stdout.decode() + + +def test_create_case(): + """Test creating a single test case. + + Mostly for debugging purposes. + """ + format_ = "pysb" + version = "v2.0.0" + id_ = "0002" + create_case(format_=format_, version=version, id_=id_) From 825bee73af5678d14a74a2326429638d9e1b7ce1 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 18 Dec 2024 22:49:57 +0100 Subject: [PATCH 07/17] pc --- pytest.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pytest.ini b/pytest.ini index 8e64a3e..81caef2 100644 --- a/pytest.ini +++ b/pytest.ini @@ -6,5 +6,7 @@ filterwarnings = # warnings are errors error ignore:Support for PEtab2.0 and all of petab.v2 is experimental and subject to changes!:UserWarning + # some pycharm 2024.3.1 issue... + ignore:Passing unrecognized arguments to super\(PyDevIPCompleter6\).__init__\(use_readline=False\).:DeprecationWarning norecursedirs = .git cases petabtests/cases From 573dc6326664ebb4639d845ecd3a95050c8fce2e Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 18 Dec 2024 22:53:14 +0100 Subject: [PATCH 08/17] -v --- petabtests/core.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/petabtests/core.py b/petabtests/core.py index c9b93af..2341b84 100644 --- a/petabtests/core.py +++ b/petabtests/core.py @@ -149,6 +149,15 @@ def clear() -> None: def _cli_create(): """`petabtests_create` entry point.""" - # initialize logging - logging.basicConfig(level=logging.INFO) + import argparse + + parser = argparse.ArgumentParser(description="Create PEtab test cases.") + parser.add_argument( + "--verbose", "-v", action="store_true", help="Verbose output." + ) + args = parser.parse_args() + + if args.verbose: + logging.basicConfig(level=logging.INFO) + create_all() From ab573183e5c7fe69bec7d2224fde40a17f55364b Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 18 Dec 2024 23:18:47 +0100 Subject: [PATCH 09/17] pysb 4+5 --- .../cases/v2.0.0/pysb/0002/_parameters.tsv | 4 +- petabtests/cases/v2.0.0/pysb/0004/0004.py | 108 ++++++++++------ petabtests/cases/v2.0.0/pysb/0004/_0004.yaml | 4 +- .../cases/v2.0.0/pysb/0004/_measurements.tsv | 6 +- .../cases/v2.0.0/pysb/0004/_parameters.tsv | 14 +- .../cases/v2.0.0/pysb/0004/_simulations.tsv | 6 +- petabtests/cases/v2.0.0/pysb/0005/0005.py | 120 ++++++++++++------ petabtests/cases/v2.0.0/pysb/0005/_0005.yaml | 2 + .../cases/v2.0.0/pysb/0005/_conditions.tsv | 6 +- .../cases/v2.0.0/pysb/0005/_experiments.tsv | 3 + .../cases/v2.0.0/pysb/0005/_measurements.tsv | 6 +- .../cases/v2.0.0/pysb/0005/_parameters.tsv | 14 +- .../cases/v2.0.0/pysb/0005/_simulations.tsv | 6 +- 13 files changed, 191 insertions(+), 108 deletions(-) create mode 100644 petabtests/cases/v2.0.0/pysb/0005/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/pysb/0002/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0002/_parameters.tsv index 558a18a..e75654a 100644 --- a/petabtests/cases/v2.0.0/pysb/0002/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0002/_parameters.tsv @@ -1,3 +1,3 @@ parameterId estimate nominalValue parameterScale lowerBound upperBound -k1 True 0.8 lin 0 10 -k2 True 0.6 lin 0 10 +k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0004/0004.py b/petabtests/cases/v2.0.0/pysb/0004/0004.py index 41d8184..07fdf6f 100644 --- a/petabtests/cases/v2.0.0/pysb/0004/0004.py +++ b/petabtests/cases/v2.0.0/pysb/0004/0004.py @@ -1,7 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import DEFAULT_PYSB_FILE, PetabTestCase, analytical_a @@ -24,44 +24,80 @@ """) # problem -------------------------------------------------------------------- +problem = Problem() -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0"], - } -).set_index([CONDITION_ID]) +problem.add_observable( + "obs_a", + "scaling_A * A + offset_A", + noise_formula=1, +) -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [0, 10], - MEASUREMENT: [0.7, 0.1], - } +problem.add_measurement( + "obs_a", + "", + time=0, + measurement=0.7, +) +problem.add_measurement( + "obs_a", + "", + time=10, + measurement=0.1, ) -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["scaling_A * A + offset_A"], - NOISE_FORMULA: [1], - } -).set_index([OBSERVABLE_ID]) +problem.add_parameter( + "scaling_A", + lb=0, + ub=10, + nominal_value=0.5, + scale=LIN, + estimate=False, +) +problem.add_parameter( + "offset_A", + lb=0, + ub=10, + nominal_value=2, + scale=LIN, + estimate=False, +) +problem.add_parameter( + "a0", + lb=0, + ub=10, + nominal_value=1, + scale=LIN, + estimate=True, +) +problem.add_parameter( + "b0", + lb=0, + ub=10, + nominal_value=0, + scale=LIN, + estimate=True, +) +problem.add_parameter( + "k1", + lb=0, + ub=10, + nominal_value=0.8, + scale=LIN, + estimate=True, +) +problem.add_parameter( + "k2", + lb=0, + ub=10, + nominal_value=0.6, + scale=LIN, + estimate=True, +) -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["a0", "b0", "k1", "k2", "scaling_A", "offset_A"], - PARAMETER_SCALE: [LIN] * 6, - LOWER_BOUND: [0] * 6, - UPPER_BOUND: [10] * 6, - NOMINAL_VALUE: [1, 0, 0.8, 0.6, 0.5, 2], - ESTIMATE: [1] * 6, - } -).set_index(PARAMETER_ID) # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) simulation_df[SIMULATION] = [ @@ -73,9 +109,9 @@ brief="Simulation. Observable parameters only defined in parameter table.", description=DESCRIPTION, model=DEFAULT_PYSB_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, + parameter_df=problem.parameter_df, ) diff --git a/petabtests/cases/v2.0.0/pysb/0004/_0004.yaml b/petabtests/cases/v2.0.0/pysb/0004/_0004.yaml index 493b4f8..1ce7ed6 100644 --- a/petabtests/cases/v2.0.0/pysb/0004/_0004.yaml +++ b/petabtests/cases/v2.0.0/pysb/0004/_0004.yaml @@ -1,8 +1,8 @@ format_version: 2.0.0 parameter_file: _parameters.tsv problems: -- condition_files: - - _conditions.tsv +- condition_files: [] + experiment_files: [] measurement_files: - _measurements.tsv model_files: diff --git a/petabtests/cases/v2.0.0/pysb/0004/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0004/_measurements.tsv index a497632..59bd3e4 100644 --- a/petabtests/cases/v2.0.0/pysb/0004/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0004/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 +observableId experimentId time measurement +obs_a 0 0.7 +obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/pysb/0004/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0004/_parameters.tsv index 6d40b89..c5ae3e7 100644 --- a/petabtests/cases/v2.0.0/pysb/0004/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0004/_parameters.tsv @@ -1,7 +1,7 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -a0 lin 0 10 1.0 1 -b0 lin 0 10 0.0 1 -k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 -scaling_A lin 0 10 0.5 1 -offset_A lin 0 10 2.0 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +scaling_A 0 0.5 lin 0 10 +offset_A 0 2.0 lin 0 10 +a0 1 1.0 lin 0 10 +b0 1 0.0 lin 0 10 +k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0004/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0004/_simulations.tsv index 94e0e2f..92f3fe0 100644 --- a/petabtests/cases/v2.0.0/pysb/0004/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0004/_simulations.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time simulation -obs_a c0 0 2.5 -obs_a c0 10 2.214285951865348 +observableId experimentId time simulation +obs_a 0 2.5 +obs_a 10 2.214285951865348 diff --git a/petabtests/cases/v2.0.0/pysb/0005/0005.py b/petabtests/cases/v2.0.0/pysb/0005/0005.py index 2b21823..01e2ed1 100644 --- a/petabtests/cases/v2.0.0/pysb/0005/0005.py +++ b/petabtests/cases/v2.0.0/pysb/0005/0005.py @@ -1,7 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import PetabTestCase, analytical_a @@ -23,44 +23,85 @@ # problem -------------------------------------------------------------------- -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0", "c1"], - "offset_A": ["offset_A_c0", "offset_A_c1"], - } -).set_index([CONDITION_ID]) - -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - SIMULATION_CONDITION_ID: ["c0", "c1"], - TIME: [10, 10], - MEASUREMENT: [2.1, 3.2], - } +problem = Problem() + +problem.add_condition("c0", offset_A=(VT_CONSTANT, "offset_A_c0")) +problem.add_condition("c1", offset_A=(VT_CONSTANT, "offset_A_c1")) + +problem.add_experiment("e0", 0, "c0") +problem.add_experiment("e1", 0, "c1") + +problem.add_observable( + "obs_a", + "A + offset_A", + noise_formula=1, +) + +problem.add_measurement( + "obs_a", + "e0", + time=10, + measurement=2.1, +) +problem.add_measurement( + "obs_a", + "e1", + time=10, + measurement=3.2, ) -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["A + offset_A"], - NOISE_FORMULA: [1], - } -).set_index([OBSERVABLE_ID]) - -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["a0", "b0", "k1", "k2", "offset_A_c0", "offset_A_c1"], - PARAMETER_SCALE: [LIN] * 6, - LOWER_BOUND: [0] * 6, - UPPER_BOUND: [10] * 6, - NOMINAL_VALUE: [1, 0, 0.8, 0.6, 2, 3], - ESTIMATE: [1] * 6, - } -).set_index(PARAMETER_ID) +problem.add_parameter( + "a0", + lb=0, + ub=10, + nominal_value=1, + scale=LIN, + estimate=True, +) +problem.add_parameter( + "b0", + lb=0, + ub=10, + nominal_value=0, + scale=LIN, + estimate=True, +) +problem.add_parameter( + "k1", + lb=0, + ub=10, + nominal_value=0.8, + scale=LIN, + estimate=True, +) +problem.add_parameter( + "k2", + lb=0, + ub=10, + nominal_value=0.6, + scale=LIN, + estimate=True, +) +problem.add_parameter( + "offset_A_c0", + lb=0, + ub=10, + nominal_value=2, + scale=LIN, + estimate=False, +) +problem.add_parameter( + "offset_A_c1", + lb=0, + ub=10, + nominal_value=3, + scale=LIN, + estimate=False, +) # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) simulation_df[SIMULATION] = [ @@ -73,9 +114,10 @@ "parameter table.", description=DESCRIPTION, model="conversion_modified_pysb.py", - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, + parameter_df=problem.parameter_df, + experiment_dfs=[problem.experiment_df], ) diff --git a/petabtests/cases/v2.0.0/pysb/0005/_0005.yaml b/petabtests/cases/v2.0.0/pysb/0005/_0005.yaml index 493b4f8..4e0d35b 100644 --- a/petabtests/cases/v2.0.0/pysb/0005/_0005.yaml +++ b/petabtests/cases/v2.0.0/pysb/0005/_0005.yaml @@ -3,6 +3,8 @@ parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv model_files: diff --git a/petabtests/cases/v2.0.0/pysb/0005/_conditions.tsv b/petabtests/cases/v2.0.0/pysb/0005/_conditions.tsv index db79bf4..4d5cd53 100644 --- a/petabtests/cases/v2.0.0/pysb/0005/_conditions.tsv +++ b/petabtests/cases/v2.0.0/pysb/0005/_conditions.tsv @@ -1,3 +1,3 @@ -conditionId offset_A -c0 offset_A_c0 -c1 offset_A_c1 +conditionId targetId valueType targetValue +c0 offset_A constant offset_A_c0 +c1 offset_A constant offset_A_c1 diff --git a/petabtests/cases/v2.0.0/pysb/0005/_experiments.tsv b/petabtests/cases/v2.0.0/pysb/0005/_experiments.tsv new file mode 100644 index 0000000..e595c08 --- /dev/null +++ b/petabtests/cases/v2.0.0/pysb/0005/_experiments.tsv @@ -0,0 +1,3 @@ +experimentId time conditionId +e0 0 c0 +e1 0 c1 diff --git a/petabtests/cases/v2.0.0/pysb/0005/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0005/_measurements.tsv index 6016b73..ed70fa0 100644 --- a/petabtests/cases/v2.0.0/pysb/0005/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0005/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a c0 10 2.1 -obs_a c1 10 3.2 +observableId experimentId time measurement +obs_a e0 10 2.1 +obs_a e1 10 3.2 diff --git a/petabtests/cases/v2.0.0/pysb/0005/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0005/_parameters.tsv index 2676343..bba238e 100644 --- a/petabtests/cases/v2.0.0/pysb/0005/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0005/_parameters.tsv @@ -1,7 +1,7 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -a0 lin 0 10 1.0 1 -b0 lin 0 10 0.0 1 -k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 -offset_A_c0 lin 0 10 2.0 1 -offset_A_c1 lin 0 10 3.0 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +a0 1 1.0 lin 0 10 +b0 1 0.0 lin 0 10 +k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 +offset_A_c0 0 2.0 lin 0 10 +offset_A_c1 0 3.0 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0005/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0005/_simulations.tsv index 3fb757b..836fcad 100644 --- a/petabtests/cases/v2.0.0/pysb/0005/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0005/_simulations.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time simulation -obs_a c0 10 2.4285719037306968 -obs_a c1 10 3.4285719037306968 +observableId experimentId time simulation +obs_a e0 10 2.4285719037306968 +obs_a e1 10 3.4285719037306968 From 2f3a8735e010aeb232c0a4dc435f95950ef2b299 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 18 Dec 2024 23:28:09 +0100 Subject: [PATCH 10/17] pysb 6+7 --- .ci_pip_reqs.txt | 2 +- petabtests/cases/v2.0.0/pysb/0006/0006.py | 66 ++++++++----------- petabtests/cases/v2.0.0/pysb/0006/_0006.yaml | 4 +- .../cases/v2.0.0/pysb/0006/_measurements.tsv | 2 +- .../cases/v2.0.0/pysb/0006/_parameters.tsv | 10 +-- .../cases/v2.0.0/pysb/0006/_simulations.tsv | 2 +- petabtests/cases/v2.0.0/pysb/0007/0007.py | 62 +++++++---------- petabtests/cases/v2.0.0/pysb/0007/_0007.yaml | 4 +- .../v2.0.0/pysb/0007/_0007_solution.yaml | 4 +- .../cases/v2.0.0/pysb/0007/_measurements.tsv | 6 +- .../cases/v2.0.0/pysb/0007/_observables.tsv | 6 +- .../cases/v2.0.0/pysb/0007/_parameters.tsv | 10 +-- .../cases/v2.0.0/pysb/0007/_simulations.tsv | 6 +- 13 files changed, 80 insertions(+), 104 deletions(-) diff --git a/.ci_pip_reqs.txt b/.ci_pip_reqs.txt index d066353..75eba8c 100644 --- a/.ci_pip_reqs.txt +++ b/.ci_pip_reqs.txt @@ -1,4 +1,4 @@ pytest ruff -git+https://github.com/PEtab-dev/libpetab-python@long_conditions +git+https://github.com/PEtab-dev/libpetab-python@develop sympy>=1.12.1 diff --git a/petabtests/cases/v2.0.0/pysb/0006/0006.py b/petabtests/cases/v2.0.0/pysb/0006/0006.py index 79400ca..fc638c6 100644 --- a/petabtests/cases/v2.0.0/pysb/0006/0006.py +++ b/petabtests/cases/v2.0.0/pysb/0006/0006.py @@ -1,9 +1,10 @@ from inspect import cleandoc -import pandas as pd from petab.v1.C import * from petabtests import DEFAULT_PYSB_FILE, PetabTestCase, analytical_a +from petab.v2 import Problem +from petab.v2.C import * DESCRIPTION = cleandoc(""" ## Objective @@ -21,45 +22,34 @@ """) # problem -------------------------------------------------------------------- +problem = Problem() -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0"], - } -).set_index([CONDITION_ID]) - -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [0, 10], - MEASUREMENT: [0.7, 0.1], - OBSERVABLE_PARAMETERS: [10, 15], - } +problem.add_observable( + "obs_a", "observableParameter1_obs_a * A", noise_formula=1 ) -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["observableParameter1_obs_a * A"], - NOISE_FORMULA: [1], - } -).set_index([OBSERVABLE_ID]) - -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["a0", "b0", "k1", "k2"], - PARAMETER_SCALE: [LIN] * 4, - LOWER_BOUND: [0] * 4, - UPPER_BOUND: [10] * 4, - NOMINAL_VALUE: [1, 0, 0.8, 0.6], - ESTIMATE: [1] * 4, - } -).set_index(PARAMETER_ID) +problem.add_measurement( + "obs_a", "c0", time=0, measurement=0.7, observable_parameters=(10,) +) +problem.add_measurement( + "obs_a", "c0", time=10, measurement=0.1, observable_parameters=(15,) +) +problem.add_parameter( + "a0", lb=0, ub=10, nominal_value=1, scale=LIN, estimate=True +) +problem.add_parameter( + "b0", lb=0, ub=10, nominal_value=0, scale=LIN, estimate=True +) +problem.add_parameter( + "k1", lb=0, ub=10, nominal_value=0.8, scale=LIN, estimate=True +) +problem.add_parameter( + "k2", lb=0, ub=10, nominal_value=0.6, scale=LIN, estimate=True +) # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) simulation_df[SIMULATION] = [ @@ -73,9 +63,9 @@ "overrides.", description=DESCRIPTION, model=DEFAULT_PYSB_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, + parameter_df=problem.parameter_df, ) diff --git a/petabtests/cases/v2.0.0/pysb/0006/_0006.yaml b/petabtests/cases/v2.0.0/pysb/0006/_0006.yaml index 493b4f8..1ce7ed6 100644 --- a/petabtests/cases/v2.0.0/pysb/0006/_0006.yaml +++ b/petabtests/cases/v2.0.0/pysb/0006/_0006.yaml @@ -1,8 +1,8 @@ format_version: 2.0.0 parameter_file: _parameters.tsv problems: -- condition_files: - - _conditions.tsv +- condition_files: [] + experiment_files: [] measurement_files: - _measurements.tsv model_files: diff --git a/petabtests/cases/v2.0.0/pysb/0006/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0006/_measurements.tsv index 8ed279b..16cb6a1 100644 --- a/petabtests/cases/v2.0.0/pysb/0006/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0006/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement observableParameters +observableId experimentId time measurement observableParameters obs_a c0 0 0.7 10 obs_a c0 10 0.1 15 diff --git a/petabtests/cases/v2.0.0/pysb/0006/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0006/_parameters.tsv index 8c1e5cb..9ead8dd 100644 --- a/petabtests/cases/v2.0.0/pysb/0006/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0006/_parameters.tsv @@ -1,5 +1,5 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -a0 lin 0 10 1.0 1 -b0 lin 0 10 0.0 1 -k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +a0 1 1.0 lin 0 10 +b0 1 0.0 lin 0 10 +k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0006/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0006/_simulations.tsv index 7d219fa..d9f49d5 100644 --- a/petabtests/cases/v2.0.0/pysb/0006/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0006/_simulations.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time simulation observableParameters +observableId experimentId time simulation observableParameters obs_a c0 0 10.0 10 obs_a c0 10 6.42857855596045 15 diff --git a/petabtests/cases/v2.0.0/pysb/0007/0007.py b/petabtests/cases/v2.0.0/pysb/0007/0007.py index 1dc033e..c5bbccc 100644 --- a/petabtests/cases/v2.0.0/pysb/0007/0007.py +++ b/petabtests/cases/v2.0.0/pysb/0007/0007.py @@ -1,7 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import ( DEFAULT_PYSB_FILE, @@ -26,45 +26,31 @@ """) # problem -------------------------------------------------------------------- +problem = Problem() -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0"], - } -).set_index([CONDITION_ID]) +problem.add_observable("obs_a", "A", noise_formula=0.5) +problem.add_observable("obs_b", "B", noise_formula=0.6) -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_b"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [10, 10], - MEASUREMENT: [0.2, 0.8], - } -) +problem.add_measurement("obs_a", "", time=10, measurement=0.2) +problem.add_measurement("obs_b", "", time=10, measurement=0.8) -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_b"], - OBSERVABLE_FORMULA: ["A", "B"], - OBSERVABLE_TRANSFORMATION: [LIN, LOG10], - NOISE_FORMULA: [0.5, 0.6], - } -).set_index([OBSERVABLE_ID]) +problem.add_parameter( + "a0", lb=0, ub=10, nominal_value=1, scale=LIN, estimate=True +) +problem.add_parameter( + "b0", lb=0, ub=10, nominal_value=0, scale=LIN, estimate=True +) +problem.add_parameter( + "k1", lb=0, ub=10, nominal_value=0.8, scale=LIN, estimate=True +) +problem.add_parameter( + "k2", lb=0, ub=10, nominal_value=0.6, scale=LIN, estimate=True +) -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["a0", "b0", "k1", "k2"], - PARAMETER_SCALE: [LIN] * 4, - LOWER_BOUND: [0] * 4, - UPPER_BOUND: [10] * 4, - NOMINAL_VALUE: [1, 0, 0.8, 0.6], - ESTIMATE: [1] * 4, - } -).set_index(PARAMETER_ID) # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) simulation_df[SIMULATION] = [ @@ -77,9 +63,9 @@ brief="Simulation. Observable transformation log10.", description=DESCRIPTION, model=DEFAULT_PYSB_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, + parameter_df=problem.parameter_df, ) diff --git a/petabtests/cases/v2.0.0/pysb/0007/_0007.yaml b/petabtests/cases/v2.0.0/pysb/0007/_0007.yaml index 493b4f8..1ce7ed6 100644 --- a/petabtests/cases/v2.0.0/pysb/0007/_0007.yaml +++ b/petabtests/cases/v2.0.0/pysb/0007/_0007.yaml @@ -1,8 +1,8 @@ format_version: 2.0.0 parameter_file: _parameters.tsv problems: -- condition_files: - - _conditions.tsv +- condition_files: [] + experiment_files: [] measurement_files: - _measurements.tsv model_files: diff --git a/petabtests/cases/v2.0.0/pysb/0007/_0007_solution.yaml b/petabtests/cases/v2.0.0/pysb/0007/_0007_solution.yaml index 6025b5e..649e4cc 100644 --- a/petabtests/cases/v2.0.0/pysb/0007/_0007_solution.yaml +++ b/petabtests/cases/v2.0.0/pysb/0007/_0007_solution.yaml @@ -1,5 +1,5 @@ -chi2: 0.2682957616817 -llh: -1.378941036858 +chi2: 0.35410578063106 +llh: -0.81095715239894 simulation_files: - _simulations.tsv tol_chi2: 0.001 diff --git a/petabtests/cases/v2.0.0/pysb/0007/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0007/_measurements.tsv index 00c596e..16d7e3b 100644 --- a/petabtests/cases/v2.0.0/pysb/0007/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0007/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a c0 10 0.2 -obs_b c0 10 0.8 +observableId experimentId time measurement +obs_a 10 0.2 +obs_b 10 0.8 diff --git a/petabtests/cases/v2.0.0/pysb/0007/_observables.tsv b/petabtests/cases/v2.0.0/pysb/0007/_observables.tsv index c966bde..845682f 100644 --- a/petabtests/cases/v2.0.0/pysb/0007/_observables.tsv +++ b/petabtests/cases/v2.0.0/pysb/0007/_observables.tsv @@ -1,3 +1,3 @@ -observableId observableFormula observableTransformation noiseFormula -obs_a A lin 0.5 -obs_b B log10 0.6 +observableId observableFormula noiseFormula +obs_a A 0.5 +obs_b B 0.6 diff --git a/petabtests/cases/v2.0.0/pysb/0007/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0007/_parameters.tsv index 8c1e5cb..9ead8dd 100644 --- a/petabtests/cases/v2.0.0/pysb/0007/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0007/_parameters.tsv @@ -1,5 +1,5 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -a0 lin 0 10 1.0 1 -b0 lin 0 10 0.0 1 -k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +a0 1 1.0 lin 0 10 +b0 1 0.0 lin 0 10 +k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0007/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0007/_simulations.tsv index a054455..1dc6109 100644 --- a/petabtests/cases/v2.0.0/pysb/0007/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0007/_simulations.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time simulation -obs_a c0 10 0.42857190373069665 -obs_b c0 10 0.5714280962693035 +observableId experimentId time simulation +obs_a 10 0.42857190373069665 +obs_b 10 0.5714280962693035 From e9b012d5242b64983c95c14061d3a5c6b81f8101 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 18 Dec 2024 23:33:46 +0100 Subject: [PATCH 11/17] pysb 8+9 --- petabtests/cases/v2.0.0/pysb/0008/0008.py | 62 +++++++---------- petabtests/cases/v2.0.0/pysb/0008/_0008.yaml | 4 +- .../cases/v2.0.0/pysb/0008/_measurements.tsv | 8 +-- .../cases/v2.0.0/pysb/0008/_parameters.tsv | 10 +-- .../cases/v2.0.0/pysb/0008/_simulations.tsv | 8 +-- petabtests/cases/v2.0.0/pysb/0009/0009.py | 66 ++++++++----------- petabtests/cases/v2.0.0/pysb/0009/_0009.yaml | 1 + .../cases/v2.0.0/pysb/0009/_conditions.tsv | 6 +- .../cases/v2.0.0/pysb/0009/_measurements.tsv | 6 +- .../cases/v2.0.0/pysb/0009/_parameters.tsv | 8 +-- .../cases/v2.0.0/pysb/0009/_simulations.tsv | 6 +- 11 files changed, 79 insertions(+), 106 deletions(-) diff --git a/petabtests/cases/v2.0.0/pysb/0008/0008.py b/petabtests/cases/v2.0.0/pysb/0008/0008.py index 9132eec..6ecc210 100644 --- a/petabtests/cases/v2.0.0/pysb/0008/0008.py +++ b/petabtests/cases/v2.0.0/pysb/0008/0008.py @@ -1,7 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import DEFAULT_PYSB_FILE, PetabTestCase, analytical_a @@ -20,44 +20,30 @@ """) # problem -------------------------------------------------------------------- +problem = Problem() -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0"], - } -).set_index([CONDITION_ID]) +problem.add_observable("obs_a", "A", noise_formula=0.5) -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a", "obs_a"], - SIMULATION_CONDITION_ID: ["c0", "c0", "c0"], - TIME: [0, 10, 10], - MEASUREMENT: [0.7, 0.1, 0.2], - } -) - -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["A"], - NOISE_FORMULA: [0.5], - } -).set_index([OBSERVABLE_ID]) +problem.add_measurement("obs_a", "", time=0, measurement=0.7) +problem.add_measurement("obs_a", "", time=10, measurement=0.1) +problem.add_measurement("obs_a", "", time=10, measurement=0.2) -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["a0", "b0", "k1", "k2"], - PARAMETER_SCALE: [LIN] * 4, - LOWER_BOUND: [0] * 4, - UPPER_BOUND: [10] * 4, - NOMINAL_VALUE: [1, 0, 0.8, 0.6], - ESTIMATE: [1] * 4, - } -).set_index(PARAMETER_ID) +problem.add_parameter( + "a0", lb=0, ub=10, nominal_value=1, scale=LIN, estimate=True +) +problem.add_parameter( + "b0", lb=0, ub=10, nominal_value=0, scale=LIN, estimate=True +) +problem.add_parameter( + "k1", lb=0, ub=10, nominal_value=0.8, scale=LIN, estimate=True +) +problem.add_parameter( + "k2", lb=0, ub=10, nominal_value=0.6, scale=LIN, estimate=True +) # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) simulation_df[SIMULATION] = [ @@ -69,9 +55,9 @@ brief="Simulation. Replicate measurements.", description=DESCRIPTION, model=DEFAULT_PYSB_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, + parameter_df=problem.parameter_df, ) diff --git a/petabtests/cases/v2.0.0/pysb/0008/_0008.yaml b/petabtests/cases/v2.0.0/pysb/0008/_0008.yaml index 493b4f8..1ce7ed6 100644 --- a/petabtests/cases/v2.0.0/pysb/0008/_0008.yaml +++ b/petabtests/cases/v2.0.0/pysb/0008/_0008.yaml @@ -1,8 +1,8 @@ format_version: 2.0.0 parameter_file: _parameters.tsv problems: -- condition_files: - - _conditions.tsv +- condition_files: [] + experiment_files: [] measurement_files: - _measurements.tsv model_files: diff --git a/petabtests/cases/v2.0.0/pysb/0008/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0008/_measurements.tsv index b17d732..314bfb3 100644 --- a/petabtests/cases/v2.0.0/pysb/0008/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0008/_measurements.tsv @@ -1,4 +1,4 @@ -observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 -obs_a c0 10 0.2 +observableId experimentId time measurement +obs_a 0 0.7 +obs_a 10 0.1 +obs_a 10 0.2 diff --git a/petabtests/cases/v2.0.0/pysb/0008/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0008/_parameters.tsv index 8c1e5cb..9ead8dd 100644 --- a/petabtests/cases/v2.0.0/pysb/0008/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0008/_parameters.tsv @@ -1,5 +1,5 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -a0 lin 0 10 1.0 1 -b0 lin 0 10 0.0 1 -k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +a0 1 1.0 lin 0 10 +b0 1 0.0 lin 0 10 +k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0008/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0008/_simulations.tsv index 05743ad..f53098a 100644 --- a/petabtests/cases/v2.0.0/pysb/0008/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0008/_simulations.tsv @@ -1,4 +1,4 @@ -observableId simulationConditionId time simulation -obs_a c0 0 1.0 -obs_a c0 10 0.42857190373069665 -obs_a c0 10 0.42857190373069665 +observableId experimentId time simulation +obs_a 0 1.0 +obs_a 10 0.42857190373069665 +obs_a 10 0.42857190373069665 diff --git a/petabtests/cases/v2.0.0/pysb/0009/0009.py b/petabtests/cases/v2.0.0/pysb/0009/0009.py index 9c02a58..ff15463 100644 --- a/petabtests/cases/v2.0.0/pysb/0009/0009.py +++ b/petabtests/cases/v2.0.0/pysb/0009/0009.py @@ -1,7 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import ( DEFAULT_PYSB_FILE, @@ -25,46 +25,32 @@ """) # problem -------------------------------------------------------------------- +problem = Problem() -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["preeq_c0", "c0"], - "k1": [0.3, 0.8], - } -).set_index([CONDITION_ID]) - -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - PREEQUILIBRATION_CONDITION_ID: ["preeq_c0", "preeq_c0"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [1, 10], - MEASUREMENT: [0.7, 0.1], - } +problem.add_condition("preeq_c0", k1=(VT_INITIAL, 0.3)) +problem.add_condition("c0", k1=(VT_INITIAL, 0.8)) + +problem.add_experiment("e0", TIME_PREEQUILIBRATION, "preeq_c0", 0, "c0") + +problem.add_observable("obs_a", "A", noise_formula=0.5) + +problem.add_measurement("obs_a", "e0", time=1, measurement=0.7) +problem.add_measurement("obs_a", "e0", time=10, measurement=0.1) + +problem.add_parameter( + "a0", lb=0, ub=10, nominal_value=1, scale=LIN, estimate=True +) +problem.add_parameter( + "b0", lb=0, ub=10, nominal_value=0, scale=LIN, estimate=True +) +problem.add_parameter( + "k2", lb=0, ub=10, nominal_value=0.6, scale=LIN, estimate=True ) -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["A"], - NOISE_FORMULA: [0.5], - } -).set_index([OBSERVABLE_ID]) - -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["a0", "b0", "k2"], - PARAMETER_SCALE: [LIN] * 3, - LOWER_BOUND: [0] * 3, - UPPER_BOUND: [10] * 3, - NOMINAL_VALUE: [1, 0, 0.6], - ESTIMATE: [1] * 3, - } -).set_index(PARAMETER_ID) # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) # simulate for far time point as steady state @@ -81,9 +67,9 @@ brief="Simulation. Preequilibration.", description=DESCRIPTION, model=DEFAULT_PYSB_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, + parameter_df=problem.parameter_df, ) diff --git a/petabtests/cases/v2.0.0/pysb/0009/_0009.yaml b/petabtests/cases/v2.0.0/pysb/0009/_0009.yaml index 493b4f8..df06036 100644 --- a/petabtests/cases/v2.0.0/pysb/0009/_0009.yaml +++ b/petabtests/cases/v2.0.0/pysb/0009/_0009.yaml @@ -3,6 +3,7 @@ parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: [] measurement_files: - _measurements.tsv model_files: diff --git a/petabtests/cases/v2.0.0/pysb/0009/_conditions.tsv b/petabtests/cases/v2.0.0/pysb/0009/_conditions.tsv index 834fafc..1ed7a46 100644 --- a/petabtests/cases/v2.0.0/pysb/0009/_conditions.tsv +++ b/petabtests/cases/v2.0.0/pysb/0009/_conditions.tsv @@ -1,3 +1,3 @@ -conditionId k1 -preeq_c0 0.3 -c0 0.8 +conditionId targetId valueType targetValue +preeq_c0 k1 initial 0.3 +c0 k1 initial 0.8 diff --git a/petabtests/cases/v2.0.0/pysb/0009/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0009/_measurements.tsv index a9a1cb0..6221e75 100644 --- a/petabtests/cases/v2.0.0/pysb/0009/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0009/_measurements.tsv @@ -1,3 +1,3 @@ -observableId preequilibrationConditionId simulationConditionId time measurement -obs_a preeq_c0 c0 1 0.7 -obs_a preeq_c0 c0 10 0.1 +observableId experimentId time measurement +obs_a e0 1 0.7 +obs_a e0 10 0.1 diff --git a/petabtests/cases/v2.0.0/pysb/0009/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0009/_parameters.tsv index 69c6ade..aa5009a 100644 --- a/petabtests/cases/v2.0.0/pysb/0009/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0009/_parameters.tsv @@ -1,4 +1,4 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -a0 lin 0 10 1.0 1 -b0 lin 0 10 0.0 1 -k2 lin 0 10 0.6 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +a0 1 1.0 lin 0 10 +b0 1 0.0 lin 0 10 +k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0009/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0009/_simulations.tsv index 0b86e24..b56c2f7 100644 --- a/petabtests/cases/v2.0.0/pysb/0009/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0009/_simulations.tsv @@ -1,3 +1,3 @@ -observableId preequilibrationConditionId simulationConditionId time simulation -obs_a preeq_c0 c0 1 0.48728499141466824 -obs_a preeq_c0 c0 10 0.42857162655445696 +observableId experimentId time simulation +obs_a e0 1 0.48728499141466824 +obs_a e0 10 0.42857162655445696 From f4885e4538dd14fd86ad0374efbe4c1a47a9c677 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 18 Dec 2024 23:41:14 +0100 Subject: [PATCH 12/17] pysb 10+11 --- petabtests/cases/v2.0.0/pysb/0010/0010.py | 73 ++++++------------- petabtests/cases/v2.0.0/pysb/0010/_0010.yaml | 2 + .../cases/v2.0.0/pysb/0010/_conditions.tsv | 8 +- .../cases/v2.0.0/pysb/0010/_experiments.tsv | 3 + .../cases/v2.0.0/pysb/0010/_measurements.tsv | 6 +- .../cases/v2.0.0/pysb/0010/_parameters.tsv | 4 +- .../cases/v2.0.0/pysb/0010/_simulations.tsv | 6 +- petabtests/cases/v2.0.0/pysb/0011/0011.py | 68 +++++++---------- petabtests/cases/v2.0.0/pysb/0011/_0011.yaml | 2 + .../cases/v2.0.0/pysb/0011/_conditions.tsv | 4 +- .../cases/v2.0.0/pysb/0011/_experiments.tsv | 2 + .../cases/v2.0.0/pysb/0011/_measurements.tsv | 6 +- .../cases/v2.0.0/pysb/0011/_parameters.tsv | 6 +- .../cases/v2.0.0/pysb/0011/_simulations.tsv | 6 +- 14 files changed, 82 insertions(+), 114 deletions(-) create mode 100644 petabtests/cases/v2.0.0/pysb/0010/_experiments.tsv create mode 100644 petabtests/cases/v2.0.0/pysb/0011/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/pysb/0010/0010.py b/petabtests/cases/v2.0.0/pysb/0010/0010.py index bf97fc9..878d943 100644 --- a/petabtests/cases/v2.0.0/pysb/0010/0010.py +++ b/petabtests/cases/v2.0.0/pysb/0010/0010.py @@ -1,7 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import DEFAULT_PYSB_FILE, PetabTestCase, analytical_a @@ -22,54 +22,28 @@ """) # problem -------------------------------------------------------------------- +problem = Problem() -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["preeq_c0", "c0"], - "k1": [0.3, 0.8], - "B": [0, 1], - } -).set_index([CONDITION_ID]) - -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - PREEQUILIBRATION_CONDITION_ID: ["preeq_c0", "preeq_c0"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [1, 10], - MEASUREMENT: [0.7, 0.1], - } +problem.add_condition("preeq_c0", k1=(VT_INITIAL, 0.3), B=(VT_INITIAL, 0)) +problem.add_condition("c0", k1=(VT_INITIAL, 0.8), B=(VT_INITIAL, 1)) + +problem.add_experiment("e0", TIME_PREEQUILIBRATION, "preeq_c0", 0, "c0") + +problem.add_observable("obs_a", "A", noise_formula=0.5) + +problem.add_measurement("obs_a", "e0", time=1, measurement=0.7) +problem.add_measurement("obs_a", "e0", time=10, measurement=0.1) + +problem.add_parameter( + "k2", lb=0, ub=10, nominal_value=0.6, scale=LIN, estimate=True ) +problem.add_mapping("A", "A_() ** compartment") +problem.add_mapping("B", "B_() ** compartment") -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["A"], - NOISE_FORMULA: [0.5], - } -).set_index([OBSERVABLE_ID]) - -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["k2"], - PARAMETER_SCALE: [LIN], - LOWER_BOUND: [0], - UPPER_BOUND: [10], - NOMINAL_VALUE: [0.6], - ESTIMATE: [1], - } -).set_index(PARAMETER_ID) - -mapping_df = pd.DataFrame( - data={ - PETAB_ENTITY_ID: ["A", "B"], - MODEL_ENTITY_ID: ["A_() ** compartment", "B_() ** compartment"], - } -).set_index(PETAB_ENTITY_ID) # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) # simulate for far time point as steady state @@ -85,10 +59,11 @@ "InitialAssignment to species overridden.", description=DESCRIPTION, model=DEFAULT_PYSB_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, - mapping_df=mapping_df, + parameter_df=problem.parameter_df, + mapping_df=problem.mapping_df, + experiment_dfs=[problem.experiment_df], ) diff --git a/petabtests/cases/v2.0.0/pysb/0010/_0010.yaml b/petabtests/cases/v2.0.0/pysb/0010/_0010.yaml index 0048e7e..5232ade 100644 --- a/petabtests/cases/v2.0.0/pysb/0010/_0010.yaml +++ b/petabtests/cases/v2.0.0/pysb/0010/_0010.yaml @@ -3,6 +3,8 @@ parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv mapping_files: - _mapping.tsv measurement_files: diff --git a/petabtests/cases/v2.0.0/pysb/0010/_conditions.tsv b/petabtests/cases/v2.0.0/pysb/0010/_conditions.tsv index 96cbc94..dd7c3e1 100644 --- a/petabtests/cases/v2.0.0/pysb/0010/_conditions.tsv +++ b/petabtests/cases/v2.0.0/pysb/0010/_conditions.tsv @@ -1,3 +1,5 @@ -conditionId k1 B -preeq_c0 0.3 0 -c0 0.8 1 +conditionId targetId valueType targetValue +preeq_c0 k1 initial 0.3 +preeq_c0 B initial 0.0 +c0 k1 initial 0.8 +c0 B initial 1.0 diff --git a/petabtests/cases/v2.0.0/pysb/0010/_experiments.tsv b/petabtests/cases/v2.0.0/pysb/0010/_experiments.tsv new file mode 100644 index 0000000..430d0ee --- /dev/null +++ b/petabtests/cases/v2.0.0/pysb/0010/_experiments.tsv @@ -0,0 +1,3 @@ +experimentId time conditionId +e0 -inf preeq_c0 +e0 0.0 c0 diff --git a/petabtests/cases/v2.0.0/pysb/0010/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0010/_measurements.tsv index a9a1cb0..6221e75 100644 --- a/petabtests/cases/v2.0.0/pysb/0010/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0010/_measurements.tsv @@ -1,3 +1,3 @@ -observableId preequilibrationConditionId simulationConditionId time measurement -obs_a preeq_c0 c0 1 0.7 -obs_a preeq_c0 c0 10 0.1 +observableId experimentId time measurement +obs_a e0 1 0.7 +obs_a e0 10 0.1 diff --git a/petabtests/cases/v2.0.0/pysb/0010/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0010/_parameters.tsv index 72b88de..75018a0 100644 --- a/petabtests/cases/v2.0.0/pysb/0010/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0010/_parameters.tsv @@ -1,2 +1,2 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -k2 lin 0 10 0.6 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0010/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0010/_simulations.tsv index c467087..e6121aa 100644 --- a/petabtests/cases/v2.0.0/pysb/0010/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0010/_simulations.tsv @@ -1,3 +1,3 @@ -observableId preequilibrationConditionId simulationConditionId time simulation -obs_a preeq_c0 c0 1 0.7025430017170664 -obs_a preeq_c0 c0 10 0.7142856746891086 +observableId experimentId time simulation +obs_a e0 1 0.7025430017170664 +obs_a e0 10 0.7142856746891086 diff --git a/petabtests/cases/v2.0.0/pysb/0011/0011.py b/petabtests/cases/v2.0.0/pysb/0011/0011.py index 264f2bc..23843a2 100644 --- a/petabtests/cases/v2.0.0/pysb/0011/0011.py +++ b/petabtests/cases/v2.0.0/pysb/0011/0011.py @@ -1,7 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import PetabTestCase, analytical_a @@ -19,49 +19,30 @@ """) # problem -------------------------------------------------------------------- +problem = Problem() -condition_df = pd.DataFrame(data={CONDITION_ID: ["c0"], "B": [2]}).set_index( - [CONDITION_ID] -) +problem.add_condition("c0", B=(VT_INITIAL, 2)) + +problem.add_experiment("e0", 0, "c0") + +problem.add_observable("obs_a", "A", noise_formula=0.5) -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [0, 10], - MEASUREMENT: [0.7, 0.1], - } +problem.add_measurement("obs_a", "e0", time=0, measurement=0.7) +problem.add_measurement("obs_a", "e0", time=10, measurement=0.1) + +problem.add_parameter( + "k1", lb=0, ub=10, nominal_value=0.8, scale=LIN, estimate=True +) +problem.add_parameter( + "k2", lb=0, ub=10, nominal_value=0.6, scale=LIN, estimate=True ) -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["A"], - NOISE_FORMULA: [0.5], - } -).set_index([OBSERVABLE_ID]) - -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["k1", "k2"], - PARAMETER_SCALE: [LIN] * 2, - LOWER_BOUND: [0] * 2, - UPPER_BOUND: [10] * 2, - NOMINAL_VALUE: [0.8, 0.6], - ESTIMATE: [1] * 2, - } -).set_index(PARAMETER_ID) - -mapping_df = pd.DataFrame( - data={ - PETAB_ENTITY_ID: ["A", "B"], - MODEL_ENTITY_ID: ["A_() ** compartment", "B_() ** compartment"], - } -).set_index(PETAB_ENTITY_ID) +problem.add_mapping("A", "A_() ** compartment") +problem.add_mapping("B", "B_() ** compartment") # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) simulation_df[SIMULATION] = [ @@ -73,10 +54,11 @@ brief="Simulation. InitialAssignment to species overridden.", description=DESCRIPTION, model="conversion_modified_pysb.py", - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, - mapping_df=mapping_df, + parameter_df=problem.parameter_df, + mapping_df=problem.mapping_df, + experiment_dfs=[problem.experiment_df], ) diff --git a/petabtests/cases/v2.0.0/pysb/0011/_0011.yaml b/petabtests/cases/v2.0.0/pysb/0011/_0011.yaml index 0048e7e..5232ade 100644 --- a/petabtests/cases/v2.0.0/pysb/0011/_0011.yaml +++ b/petabtests/cases/v2.0.0/pysb/0011/_0011.yaml @@ -3,6 +3,8 @@ parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv mapping_files: - _mapping.tsv measurement_files: diff --git a/petabtests/cases/v2.0.0/pysb/0011/_conditions.tsv b/petabtests/cases/v2.0.0/pysb/0011/_conditions.tsv index e765b36..dde28a9 100644 --- a/petabtests/cases/v2.0.0/pysb/0011/_conditions.tsv +++ b/petabtests/cases/v2.0.0/pysb/0011/_conditions.tsv @@ -1,2 +1,2 @@ -conditionId B -c0 2 +conditionId targetId valueType targetValue +c0 B initial 2 diff --git a/petabtests/cases/v2.0.0/pysb/0011/_experiments.tsv b/petabtests/cases/v2.0.0/pysb/0011/_experiments.tsv new file mode 100644 index 0000000..166dcb9 --- /dev/null +++ b/petabtests/cases/v2.0.0/pysb/0011/_experiments.tsv @@ -0,0 +1,2 @@ +experimentId time conditionId +e0 0 c0 diff --git a/petabtests/cases/v2.0.0/pysb/0011/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0011/_measurements.tsv index a497632..eed2133 100644 --- a/petabtests/cases/v2.0.0/pysb/0011/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0011/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 +observableId experimentId time measurement +obs_a e0 0 0.7 +obs_a e0 10 0.1 diff --git a/petabtests/cases/v2.0.0/pysb/0011/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0011/_parameters.tsv index bf45aa8..e75654a 100644 --- a/petabtests/cases/v2.0.0/pysb/0011/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0011/_parameters.tsv @@ -1,3 +1,3 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0011/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0011/_simulations.tsv index b57949d..f29555b 100644 --- a/petabtests/cases/v2.0.0/pysb/0011/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0011/_simulations.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time simulation -obs_a c0 0 1.0 -obs_a c0 10 1.2857140481346516 +observableId experimentId time simulation +obs_a e0 0 1.0 +obs_a e0 10 1.2857140481346516 From f11d2defe9c98886a17f4c83719b6b320fb4ed2e Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Thu, 19 Dec 2024 09:06:27 +0100 Subject: [PATCH 13/17] pysb 12+13 --- petabtests/cases/v2.0.0/pysb/0012/0012.py | 58 +++++---------- petabtests/cases/v2.0.0/pysb/0012/_0012.yaml | 2 + .../cases/v2.0.0/pysb/0012/_conditions.tsv | 4 +- .../cases/v2.0.0/pysb/0012/_experiments.tsv | 2 + .../cases/v2.0.0/pysb/0012/_measurements.tsv | 6 +- .../cases/v2.0.0/pysb/0012/_parameters.tsv | 6 +- .../cases/v2.0.0/pysb/0012/_simulations.tsv | 6 +- petabtests/cases/v2.0.0/pysb/0013/0013.py | 72 +++++++------------ petabtests/cases/v2.0.0/pysb/0013/_0013.yaml | 2 + .../cases/v2.0.0/pysb/0013/_conditions.tsv | 4 +- .../cases/v2.0.0/pysb/0013/_experiments.tsv | 2 + .../cases/v2.0.0/pysb/0013/_measurements.tsv | 6 +- .../cases/v2.0.0/pysb/0013/_parameters.tsv | 8 +-- .../cases/v2.0.0/pysb/0013/_simulations.tsv | 6 +- 14 files changed, 76 insertions(+), 108 deletions(-) create mode 100644 petabtests/cases/v2.0.0/pysb/0012/_experiments.tsv create mode 100644 petabtests/cases/v2.0.0/pysb/0013/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/pysb/0012/0012.py b/petabtests/cases/v2.0.0/pysb/0012/0012.py index 7e99eee..69028ed 100644 --- a/petabtests/cases/v2.0.0/pysb/0012/0012.py +++ b/petabtests/cases/v2.0.0/pysb/0012/0012.py @@ -1,7 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import DEFAULT_PYSB_FILE, PetabTestCase, analytical_a @@ -17,45 +17,24 @@ """) # problem -------------------------------------------------------------------- +problem = Problem() -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0"], - "compartment": [3], - } -).set_index([CONDITION_ID]) +problem.add_condition("c0", compartment=(VT_INITIAL, 3)) +problem.add_experiment("e0", 0, "c0") +problem.add_observable("obs_a", "A", noise_formula=0.5) -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [0, 10], - MEASUREMENT: [0.7, 0.1], - } +problem.add_measurement("obs_a", "e0", time=0, measurement=0.7) +problem.add_measurement("obs_a", "e0", time=10, measurement=0.1) +problem.add_parameter( + "k1", lb=0, ub=10, nominal_value=0.8, scale=LIN, estimate=True +) +problem.add_parameter( + "k2", lb=0, ub=10, nominal_value=0.6, scale=LIN, estimate=True ) - -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["A"], - NOISE_FORMULA: [0.5], - } -).set_index([OBSERVABLE_ID]) - -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["k1", "k2"], - PARAMETER_SCALE: [LIN] * 2, - LOWER_BOUND: [0] * 2, - UPPER_BOUND: [10] * 2, - NOMINAL_VALUE: [0.8, 0.6], - ESTIMATE: [1] * 2, - } -).set_index(PARAMETER_ID) # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) # in the model, concentrations are used, which do not depend on the @@ -69,9 +48,10 @@ brief="Simulation. Initial compartment size in condition table.", description=DESCRIPTION, model=DEFAULT_PYSB_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, + parameter_df=problem.parameter_df, + experiment_dfs=[problem.experiment_df], ) diff --git a/petabtests/cases/v2.0.0/pysb/0012/_0012.yaml b/petabtests/cases/v2.0.0/pysb/0012/_0012.yaml index 493b4f8..4e0d35b 100644 --- a/petabtests/cases/v2.0.0/pysb/0012/_0012.yaml +++ b/petabtests/cases/v2.0.0/pysb/0012/_0012.yaml @@ -3,6 +3,8 @@ parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv model_files: diff --git a/petabtests/cases/v2.0.0/pysb/0012/_conditions.tsv b/petabtests/cases/v2.0.0/pysb/0012/_conditions.tsv index 13666c2..e123561 100644 --- a/petabtests/cases/v2.0.0/pysb/0012/_conditions.tsv +++ b/petabtests/cases/v2.0.0/pysb/0012/_conditions.tsv @@ -1,2 +1,2 @@ -conditionId compartment -c0 3 +conditionId targetId valueType targetValue +c0 compartment initial 3 diff --git a/petabtests/cases/v2.0.0/pysb/0012/_experiments.tsv b/petabtests/cases/v2.0.0/pysb/0012/_experiments.tsv new file mode 100644 index 0000000..166dcb9 --- /dev/null +++ b/petabtests/cases/v2.0.0/pysb/0012/_experiments.tsv @@ -0,0 +1,2 @@ +experimentId time conditionId +e0 0 c0 diff --git a/petabtests/cases/v2.0.0/pysb/0012/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0012/_measurements.tsv index a497632..eed2133 100644 --- a/petabtests/cases/v2.0.0/pysb/0012/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0012/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 +observableId experimentId time measurement +obs_a e0 0 0.7 +obs_a e0 10 0.1 diff --git a/petabtests/cases/v2.0.0/pysb/0012/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0012/_parameters.tsv index bf45aa8..e75654a 100644 --- a/petabtests/cases/v2.0.0/pysb/0012/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0012/_parameters.tsv @@ -1,3 +1,3 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0012/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0012/_simulations.tsv index d9cb2f9..1ff79fd 100644 --- a/petabtests/cases/v2.0.0/pysb/0012/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0012/_simulations.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time simulation -obs_a c0 0 1.0 -obs_a c0 10 0.8571429759326742 +observableId experimentId time simulation +obs_a e0 0 1.0 +obs_a e0 10 0.8571429759326742 diff --git a/petabtests/cases/v2.0.0/pysb/0013/0013.py b/petabtests/cases/v2.0.0/pysb/0013/0013.py index 1ac9e04..9c65548 100644 --- a/petabtests/cases/v2.0.0/pysb/0013/0013.py +++ b/petabtests/cases/v2.0.0/pysb/0013/0013.py @@ -1,7 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import PetabTestCase, analytical_a @@ -17,52 +17,31 @@ """) # problem -------------------------------------------------------------------- +problem = Problem() -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0"], - "B": ["par"], - } -).set_index([CONDITION_ID]) +problem.add_condition("c0", B=(VT_INITIAL, "par")) +problem.add_experiment("e0", 0, "c0") +problem.add_observable("obs_a", "A", noise_formula=0.5) -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [0, 10], - MEASUREMENT: [0.7, 0.1], - } -) - -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["A"], - NOISE_FORMULA: [0.5], - } -).set_index([OBSERVABLE_ID]) +problem.add_measurement("obs_a", "e0", time=0, measurement=0.7) +problem.add_measurement("obs_a", "e0", time=10, measurement=0.1) -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["k1", "k2", "par"], - PARAMETER_SCALE: [LIN] * 3, - LOWER_BOUND: [0] * 3, - UPPER_BOUND: [10] * 3, - NOMINAL_VALUE: [0.8, 0.6, 7], - ESTIMATE: [1] * 3, - } -).set_index(PARAMETER_ID) +problem.add_parameter( + "k1", lb=0, ub=10, nominal_value=0.8, scale=LIN, estimate=True +) +problem.add_parameter( + "k2", lb=0, ub=10, nominal_value=0.6, scale=LIN, estimate=True +) +problem.add_parameter( + "par", lb=0, ub=10, nominal_value=7, scale=LIN, estimate=True +) -mapping_df = pd.DataFrame( - data={ - PETAB_ENTITY_ID: ["A", "B"], - MODEL_ENTITY_ID: ["A_() ** compartment", "B_() ** compartment"], - } -).set_index(PETAB_ENTITY_ID) +problem.add_mapping("A", "A_() ** compartment") +problem.add_mapping("B", "B_() ** compartment") # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) # in the model, concentrations are used, which do not depend on the @@ -77,10 +56,11 @@ "parameter.", description=DESCRIPTION, model="conversion_modified_pysb.py", - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, - mapping_df=mapping_df, + parameter_df=problem.parameter_df, + mapping_df=problem.mapping_df, + experiment_dfs=[problem.experiment_df], ) diff --git a/petabtests/cases/v2.0.0/pysb/0013/_0013.yaml b/petabtests/cases/v2.0.0/pysb/0013/_0013.yaml index 0048e7e..5232ade 100644 --- a/petabtests/cases/v2.0.0/pysb/0013/_0013.yaml +++ b/petabtests/cases/v2.0.0/pysb/0013/_0013.yaml @@ -3,6 +3,8 @@ parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv mapping_files: - _mapping.tsv measurement_files: diff --git a/petabtests/cases/v2.0.0/pysb/0013/_conditions.tsv b/petabtests/cases/v2.0.0/pysb/0013/_conditions.tsv index a26fa5d..cf4f9e2 100644 --- a/petabtests/cases/v2.0.0/pysb/0013/_conditions.tsv +++ b/petabtests/cases/v2.0.0/pysb/0013/_conditions.tsv @@ -1,2 +1,2 @@ -conditionId B -c0 par +conditionId targetId valueType targetValue +c0 B initial par diff --git a/petabtests/cases/v2.0.0/pysb/0013/_experiments.tsv b/petabtests/cases/v2.0.0/pysb/0013/_experiments.tsv new file mode 100644 index 0000000..166dcb9 --- /dev/null +++ b/petabtests/cases/v2.0.0/pysb/0013/_experiments.tsv @@ -0,0 +1,2 @@ +experimentId time conditionId +e0 0 c0 diff --git a/petabtests/cases/v2.0.0/pysb/0013/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0013/_measurements.tsv index a497632..eed2133 100644 --- a/petabtests/cases/v2.0.0/pysb/0013/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0013/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 +observableId experimentId time measurement +obs_a e0 0 0.7 +obs_a e0 10 0.1 diff --git a/petabtests/cases/v2.0.0/pysb/0013/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0013/_parameters.tsv index bd50c04..40bb70e 100644 --- a/petabtests/cases/v2.0.0/pysb/0013/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0013/_parameters.tsv @@ -1,4 +1,4 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 -par lin 0 10 7.0 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 +par 1 7.0 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0013/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0013/_simulations.tsv index 172fa2b..6db1760 100644 --- a/petabtests/cases/v2.0.0/pysb/0013/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0013/_simulations.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time simulation -obs_a c0 0 1.0 -obs_a c0 10 3.4285694091445396 +observableId experimentId time simulation +obs_a e0 0 1.0 +obs_a e0 10 3.4285694091445396 From 63ee7558510ba6628eb688eec2a96f4aa091954d Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Thu, 19 Dec 2024 09:12:52 +0100 Subject: [PATCH 14/17] pysb 14+15 --- petabtests/cases/v2.0.0/pysb/0014/0014.py | 69 ++++++++---------- petabtests/cases/v2.0.0/pysb/0014/_0014.yaml | 4 +- .../cases/v2.0.0/pysb/0014/_measurements.tsv | 6 +- .../cases/v2.0.0/pysb/0014/_parameters.tsv | 10 +-- .../cases/v2.0.0/pysb/0014/_simulations.tsv | 6 +- petabtests/cases/v2.0.0/pysb/0015/0015.py | 70 ++++++++----------- petabtests/cases/v2.0.0/pysb/0015/_0015.yaml | 4 +- .../cases/v2.0.0/pysb/0015/_measurements.tsv | 6 +- .../cases/v2.0.0/pysb/0015/_parameters.tsv | 12 ++-- .../cases/v2.0.0/pysb/0015/_simulations.tsv | 6 +- 10 files changed, 84 insertions(+), 109 deletions(-) diff --git a/petabtests/cases/v2.0.0/pysb/0014/0014.py b/petabtests/cases/v2.0.0/pysb/0014/0014.py index 7350532..434db19 100644 --- a/petabtests/cases/v2.0.0/pysb/0014/0014.py +++ b/petabtests/cases/v2.0.0/pysb/0014/0014.py @@ -1,7 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import DEFAULT_PYSB_FILE, PetabTestCase, analytical_a @@ -17,45 +17,32 @@ """) # problem -------------------------------------------------------------------- - -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0"], - } -).set_index([CONDITION_ID]) - -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [0, 10], - MEASUREMENT: [0.7, 0.1], - NOISE_PARAMETERS: ["0.5;2", "0.5;2"], - } +problem = Problem() +problem.add_observable( + "obs_a", "A", noise_formula="noiseParameter1_obs_a + noiseParameter2_obs_a" +) +problem.add_measurement( + "obs_a", "", time=0, measurement=0.7, noise_parameters=(0.5, 2) +) +problem.add_measurement( + "obs_a", "", time=10, measurement=0.1, noise_parameters=(0.5, 2) +) +problem.add_parameter( + "a0", lb=0, ub=10, nominal_value=1, scale=LIN, estimate=True +) +problem.add_parameter( + "b0", lb=0, ub=10, nominal_value=0, scale=LIN, estimate=True +) +problem.add_parameter( + "k1", lb=0, ub=10, nominal_value=0.8, scale=LIN, estimate=True +) +problem.add_parameter( + "k2", lb=0, ub=10, nominal_value=0.6, scale=LIN, estimate=True ) - -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["A"], - NOISE_FORMULA: ["noiseParameter1_obs_a + noiseParameter2_obs_a"], - } -).set_index([OBSERVABLE_ID]) - -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["a0", "b0", "k1", "k2"], - PARAMETER_SCALE: [LIN] * 4, - LOWER_BOUND: [0] * 4, - UPPER_BOUND: [10] * 4, - NOMINAL_VALUE: [1, 0, 0.8, 0.6], - ESTIMATE: [1] * 4, - } -).set_index(PARAMETER_ID) # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) simulation_df[SIMULATION] = [ @@ -67,9 +54,9 @@ brief="Simulation. Multiple numeric noise parameter overrides.", description=DESCRIPTION, model=DEFAULT_PYSB_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, + parameter_df=problem.parameter_df, ) diff --git a/petabtests/cases/v2.0.0/pysb/0014/_0014.yaml b/petabtests/cases/v2.0.0/pysb/0014/_0014.yaml index 493b4f8..1ce7ed6 100644 --- a/petabtests/cases/v2.0.0/pysb/0014/_0014.yaml +++ b/petabtests/cases/v2.0.0/pysb/0014/_0014.yaml @@ -1,8 +1,8 @@ format_version: 2.0.0 parameter_file: _parameters.tsv problems: -- condition_files: - - _conditions.tsv +- condition_files: [] + experiment_files: [] measurement_files: - _measurements.tsv model_files: diff --git a/petabtests/cases/v2.0.0/pysb/0014/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0014/_measurements.tsv index 980766d..861c92f 100644 --- a/petabtests/cases/v2.0.0/pysb/0014/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0014/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement noiseParameters -obs_a c0 0 0.7 0.5;2 -obs_a c0 10 0.1 0.5;2 +observableId experimentId time measurement noiseParameters +obs_a 0 0.7 0.5;2 +obs_a 10 0.1 0.5;2 diff --git a/petabtests/cases/v2.0.0/pysb/0014/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0014/_parameters.tsv index 8c1e5cb..9ead8dd 100644 --- a/petabtests/cases/v2.0.0/pysb/0014/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0014/_parameters.tsv @@ -1,5 +1,5 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -a0 lin 0 10 1.0 1 -b0 lin 0 10 0.0 1 -k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +a0 1 1.0 lin 0 10 +b0 1 0.0 lin 0 10 +k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0014/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0014/_simulations.tsv index be85c82..34179c5 100644 --- a/petabtests/cases/v2.0.0/pysb/0014/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0014/_simulations.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time simulation noiseParameters -obs_a c0 0 1.0 0.5;2 -obs_a c0 10 0.42857190373069665 0.5;2 +observableId experimentId time simulation noiseParameters +obs_a 0 1.0 0.5;2 +obs_a 10 0.42857190373069665 0.5;2 diff --git a/petabtests/cases/v2.0.0/pysb/0015/0015.py b/petabtests/cases/v2.0.0/pysb/0015/0015.py index 78bd6d2..8f0bffd 100644 --- a/petabtests/cases/v2.0.0/pysb/0015/0015.py +++ b/petabtests/cases/v2.0.0/pysb/0015/0015.py @@ -1,7 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import DEFAULT_PYSB_FILE, PetabTestCase, analytical_a @@ -17,45 +17,33 @@ """) # problem -------------------------------------------------------------------- - -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0"], - } -).set_index([CONDITION_ID]) - -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [0, 10], - MEASUREMENT: [0.7, 0.1], - NOISE_PARAMETERS: ["noise", "noise"], - } +problem = Problem() +problem.add_observable("obs_a", "A", noise_formula="noiseParameter1_obs_a") +problem.add_measurement( + "obs_a", "", time=0, measurement=0.7, noise_parameters=("noise",) +) +problem.add_measurement( + "obs_a", "", time=10, measurement=0.1, noise_parameters=("noise",) +) +problem.add_parameter( + "a0", lb=0, ub=10, nominal_value=1, scale=LIN, estimate=True +) +problem.add_parameter( + "b0", lb=0, ub=10, nominal_value=0, scale=LIN, estimate=True +) +problem.add_parameter( + "k1", lb=0, ub=10, nominal_value=0.8, scale=LIN, estimate=True +) +problem.add_parameter( + "k2", lb=0, ub=10, nominal_value=0.6, scale=LIN, estimate=True +) +problem.add_parameter( + "noise", lb=0, ub=10, nominal_value=5, scale=LIN, estimate=True ) - -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["A"], - NOISE_FORMULA: ["noiseParameter1_obs_a"], - } -).set_index([OBSERVABLE_ID]) - -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["a0", "b0", "k1", "k2", "noise"], - PARAMETER_SCALE: [LIN] * 5, - LOWER_BOUND: [0] * 5, - UPPER_BOUND: [10] * 5, - NOMINAL_VALUE: [1, 0, 0.8, 0.6, 5], - ESTIMATE: [1] * 5, - } -).set_index(PARAMETER_ID) # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) simulation_df[SIMULATION] = [ @@ -67,9 +55,9 @@ brief="Simulation. Single parametric noise parameter override.", description=DESCRIPTION, model=DEFAULT_PYSB_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, + parameter_df=problem.parameter_df, ) diff --git a/petabtests/cases/v2.0.0/pysb/0015/_0015.yaml b/petabtests/cases/v2.0.0/pysb/0015/_0015.yaml index 493b4f8..1ce7ed6 100644 --- a/petabtests/cases/v2.0.0/pysb/0015/_0015.yaml +++ b/petabtests/cases/v2.0.0/pysb/0015/_0015.yaml @@ -1,8 +1,8 @@ format_version: 2.0.0 parameter_file: _parameters.tsv problems: -- condition_files: - - _conditions.tsv +- condition_files: [] + experiment_files: [] measurement_files: - _measurements.tsv model_files: diff --git a/petabtests/cases/v2.0.0/pysb/0015/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0015/_measurements.tsv index 687cf08..96bf6a3 100644 --- a/petabtests/cases/v2.0.0/pysb/0015/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0015/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement noiseParameters -obs_a c0 0 0.7 noise -obs_a c0 10 0.1 noise +observableId experimentId time measurement noiseParameters +obs_a 0 0.7 noise +obs_a 10 0.1 noise diff --git a/petabtests/cases/v2.0.0/pysb/0015/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0015/_parameters.tsv index 46c9b55..adce913 100644 --- a/petabtests/cases/v2.0.0/pysb/0015/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0015/_parameters.tsv @@ -1,6 +1,6 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -a0 lin 0 10 1.0 1 -b0 lin 0 10 0.0 1 -k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 -noise lin 0 10 5.0 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +a0 1 1.0 lin 0 10 +b0 1 0.0 lin 0 10 +k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 +noise 1 5.0 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0015/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0015/_simulations.tsv index 1bb82af..69b0c9c 100644 --- a/petabtests/cases/v2.0.0/pysb/0015/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0015/_simulations.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time simulation noiseParameters -obs_a c0 0 1.0 noise -obs_a c0 10 0.42857190373069665 noise +observableId experimentId time simulation noiseParameters +obs_a 0 1.0 noise +obs_a 10 0.42857190373069665 noise From e68404162e238436781a690c790d364985afe3ce Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Thu, 19 Dec 2024 09:39:59 +0100 Subject: [PATCH 15/17] .. --- petabtests/cases/v2.0.0/pysb/0016/0016.py | 64 ++++++--------- petabtests/cases/v2.0.0/pysb/0016/_0016.yaml | 4 +- .../cases/v2.0.0/pysb/0016/_measurements.tsv | 6 +- .../cases/v2.0.0/pysb/0016/_observables.tsv | 6 +- .../cases/v2.0.0/pysb/0016/_parameters.tsv | 10 +-- .../cases/v2.0.0/pysb/0016/_simulations.tsv | 6 +- petabtests/cases/v2.0.0/pysb/0017/0017.py | 75 +++++------------ petabtests/cases/v2.0.0/pysb/0017/_0017.yaml | 2 + .../cases/v2.0.0/pysb/0017/_conditions.tsv | 9 ++- .../cases/v2.0.0/pysb/0017/_experiments.tsv | 3 + .../cases/v2.0.0/pysb/0017/_measurements.tsv | 6 +- .../cases/v2.0.0/pysb/0017/_parameters.tsv | 4 +- .../cases/v2.0.0/pysb/0017/_simulations.tsv | 6 +- petabtests/cases/v2.0.0/pysb/0018/0018.py | 81 +++++++------------ petabtests/cases/v2.0.0/pysb/0018/_0018.yaml | 4 +- .../cases/v2.0.0/pysb/0018/_measurements.tsv | 6 +- .../cases/v2.0.0/pysb/0018/_parameters.tsv | 10 +-- .../cases/v2.0.0/pysb/0018/_simulations.tsv | 6 +- 18 files changed, 120 insertions(+), 188 deletions(-) create mode 100644 petabtests/cases/v2.0.0/pysb/0017/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/pysb/0016/0016.py b/petabtests/cases/v2.0.0/pysb/0016/0016.py index 76b561c..4e5f708 100644 --- a/petabtests/cases/v2.0.0/pysb/0016/0016.py +++ b/petabtests/cases/v2.0.0/pysb/0016/0016.py @@ -1,7 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import ( DEFAULT_PYSB_FILE, @@ -25,45 +25,27 @@ mass action kinetics. """) # problem -------------------------------------------------------------------- - -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0"], - } -).set_index([CONDITION_ID]) - -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_b"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [10, 10], - MEASUREMENT: [0.2, 0.8], - } +problem = Problem() +problem.add_observable("obs_a", "A", noise_formula=0.5, transform=LIN) +problem.add_observable("obs_b", "B", noise_formula=0.7, transform=LOG) +problem.add_measurement("obs_a", "", time=10, measurement=0.2) +problem.add_measurement("obs_b", "", time=10, measurement=0.8) +problem.add_parameter( + "a0", lb=0, ub=10, nominal_value=1, scale=LIN, estimate=True +) +problem.add_parameter( + "b0", lb=0, ub=10, nominal_value=0, scale=LIN, estimate=True +) +problem.add_parameter( + "k1", lb=0, ub=10, nominal_value=0.8, scale=LIN, estimate=True +) +problem.add_parameter( + "k2", lb=0, ub=10, nominal_value=0.6, scale=LIN, estimate=True ) - -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_b"], - OBSERVABLE_FORMULA: ["A", "B"], - OBSERVABLE_TRANSFORMATION: [LIN, LOG], - NOISE_FORMULA: [0.5, 0.7], - } -).set_index([OBSERVABLE_ID]) - -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["a0", "b0", "k1", "k2"], - PARAMETER_SCALE: [LIN] * 4, - LOWER_BOUND: [0] * 4, - UPPER_BOUND: [10] * 4, - NOMINAL_VALUE: [1, 0, 0.8, 0.6], - ESTIMATE: [1] * 4, - } -).set_index(PARAMETER_ID) # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) simulation_df[SIMULATION] = [ @@ -76,9 +58,9 @@ brief="Simulation. Observable transformation log.", description=DESCRIPTION, model=DEFAULT_PYSB_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, + parameter_df=problem.parameter_df, ) diff --git a/petabtests/cases/v2.0.0/pysb/0016/_0016.yaml b/petabtests/cases/v2.0.0/pysb/0016/_0016.yaml index 493b4f8..1ce7ed6 100644 --- a/petabtests/cases/v2.0.0/pysb/0016/_0016.yaml +++ b/petabtests/cases/v2.0.0/pysb/0016/_0016.yaml @@ -1,8 +1,8 @@ format_version: 2.0.0 parameter_file: _parameters.tsv problems: -- condition_files: - - _conditions.tsv +- condition_files: [] + experiment_files: [] measurement_files: - _measurements.tsv model_files: diff --git a/petabtests/cases/v2.0.0/pysb/0016/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0016/_measurements.tsv index 00c596e..16d7e3b 100644 --- a/petabtests/cases/v2.0.0/pysb/0016/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0016/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a c0 10 0.2 -obs_b c0 10 0.8 +observableId experimentId time measurement +obs_a 10 0.2 +obs_b 10 0.8 diff --git a/petabtests/cases/v2.0.0/pysb/0016/_observables.tsv b/petabtests/cases/v2.0.0/pysb/0016/_observables.tsv index 6d90598..10b5041 100644 --- a/petabtests/cases/v2.0.0/pysb/0016/_observables.tsv +++ b/petabtests/cases/v2.0.0/pysb/0016/_observables.tsv @@ -1,3 +1,3 @@ -observableId observableFormula observableTransformation noiseFormula -obs_a A lin 0.5 -obs_b B log 0.7 +observableId observableFormula noiseFormula observableTransformation +obs_a A 0.5 lin +obs_b B 0.7 log diff --git a/petabtests/cases/v2.0.0/pysb/0016/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0016/_parameters.tsv index 8c1e5cb..9ead8dd 100644 --- a/petabtests/cases/v2.0.0/pysb/0016/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0016/_parameters.tsv @@ -1,5 +1,5 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -a0 lin 0 10 1.0 1 -b0 lin 0 10 0.0 1 -k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +a0 1 1.0 lin 0 10 +b0 1 0.0 lin 0 10 +k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0016/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0016/_simulations.tsv index a054455..1dc6109 100644 --- a/petabtests/cases/v2.0.0/pysb/0016/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0016/_simulations.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time simulation -obs_a c0 10 0.42857190373069665 -obs_b c0 10 0.5714280962693035 +observableId experimentId time simulation +obs_a 10 0.42857190373069665 +obs_b 10 0.5714280962693035 diff --git a/petabtests/cases/v2.0.0/pysb/0017/0017.py b/petabtests/cases/v2.0.0/pysb/0017/0017.py index a465be7..ef8aa25 100644 --- a/petabtests/cases/v2.0.0/pysb/0017/0017.py +++ b/petabtests/cases/v2.0.0/pysb/0017/0017.py @@ -1,7 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import ( DEFAULT_PYSB_FILE, @@ -31,56 +31,24 @@ """) # problem -------------------------------------------------------------------- - - -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["preeq_c0", "c0"], - "k1": [0.3, 0.8], - "B": [2.0, "NaN"], - "A": [0, 1], - } -).set_index([CONDITION_ID]) - -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - PREEQUILIBRATION_CONDITION_ID: ["preeq_c0", "preeq_c0"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [1, 10], - MEASUREMENT: [0.7, 0.1], - } +problem = Problem() +problem.add_condition( + "preeq_c0", k1=(VT_INITIAL, 0.3), B=(VT_INITIAL, 2.0), A=(VT_INITIAL, 0) ) - -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["A"], - NOISE_FORMULA: [0.5], - } -).set_index([OBSERVABLE_ID]) - -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["k2"], - PARAMETER_SCALE: [LIN], - LOWER_BOUND: [0], - UPPER_BOUND: [10], - NOMINAL_VALUE: [0.6], - ESTIMATE: [1], - } -).set_index(PARAMETER_ID) - -mapping_df = pd.DataFrame( - data={ - PETAB_ENTITY_ID: ["A", "B"], - MODEL_ENTITY_ID: ["A_() ** compartment", "B_() ** compartment"], - } -).set_index(PETAB_ENTITY_ID) +problem.add_condition("c0", k1=(VT_INITIAL, 0.8), A=(VT_INITIAL, 1)) +problem.add_experiment("e0", TIME_PREEQUILIBRATION, "preeq_c0", 0, "c0") +problem.add_observable("obs_a", "A", noise_formula=0.5) +problem.add_measurement("obs_a", "e0", time=1, measurement=0.7) +problem.add_measurement("obs_a", "e0", time=10, measurement=0.1) +problem.add_parameter( + "k2", lb=0, ub=10, nominal_value=0.6, scale=LIN, estimate=True +) +problem.add_mapping("A", "A_() ** compartment") +problem.add_mapping("B", "B_() ** compartment") # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) # simulate for far time point as steady state @@ -96,10 +64,11 @@ "(NaN in condition table). InitialAssignment to species overridden.", description=DESCRIPTION, model=DEFAULT_PYSB_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, - mapping_df=mapping_df, + parameter_df=problem.parameter_df, + mapping_df=problem.mapping_df, + experiment_dfs=[problem.experiment_df], ) diff --git a/petabtests/cases/v2.0.0/pysb/0017/_0017.yaml b/petabtests/cases/v2.0.0/pysb/0017/_0017.yaml index 0048e7e..5232ade 100644 --- a/petabtests/cases/v2.0.0/pysb/0017/_0017.yaml +++ b/petabtests/cases/v2.0.0/pysb/0017/_0017.yaml @@ -3,6 +3,8 @@ parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv mapping_files: - _mapping.tsv measurement_files: diff --git a/petabtests/cases/v2.0.0/pysb/0017/_conditions.tsv b/petabtests/cases/v2.0.0/pysb/0017/_conditions.tsv index 18cccad..f2ff4c5 100644 --- a/petabtests/cases/v2.0.0/pysb/0017/_conditions.tsv +++ b/petabtests/cases/v2.0.0/pysb/0017/_conditions.tsv @@ -1,3 +1,6 @@ -conditionId k1 B A -preeq_c0 0.3 2.0 0 -c0 0.8 NaN 1 +conditionId targetId valueType targetValue +preeq_c0 k1 initial 0.3 +preeq_c0 B initial 2.0 +preeq_c0 A initial 0.0 +c0 k1 initial 0.8 +c0 A initial 1.0 diff --git a/petabtests/cases/v2.0.0/pysb/0017/_experiments.tsv b/petabtests/cases/v2.0.0/pysb/0017/_experiments.tsv new file mode 100644 index 0000000..430d0ee --- /dev/null +++ b/petabtests/cases/v2.0.0/pysb/0017/_experiments.tsv @@ -0,0 +1,3 @@ +experimentId time conditionId +e0 -inf preeq_c0 +e0 0.0 c0 diff --git a/petabtests/cases/v2.0.0/pysb/0017/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0017/_measurements.tsv index a9a1cb0..6221e75 100644 --- a/petabtests/cases/v2.0.0/pysb/0017/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0017/_measurements.tsv @@ -1,3 +1,3 @@ -observableId preequilibrationConditionId simulationConditionId time measurement -obs_a preeq_c0 c0 1 0.7 -obs_a preeq_c0 c0 10 0.1 +observableId experimentId time measurement +obs_a e0 1 0.7 +obs_a e0 10 0.1 diff --git a/petabtests/cases/v2.0.0/pysb/0017/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0017/_parameters.tsv index 72b88de..75018a0 100644 --- a/petabtests/cases/v2.0.0/pysb/0017/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0017/_parameters.tsv @@ -1,2 +1,2 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -k2 lin 0 10 0.6 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0017/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0017/_simulations.tsv index 8155bb8..45f4ecf 100644 --- a/petabtests/cases/v2.0.0/pysb/0017/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0017/_simulations.tsv @@ -1,3 +1,3 @@ -observableId preequilibrationConditionId simulationConditionId time simulation -obs_a preeq_c0 c0 1 0.7847419896976019 -obs_a preeq_c0 c0 10 0.7142859518653484 +observableId experimentId time simulation +obs_a e0 1 0.7847419896976019 +obs_a e0 10 0.7142859518653484 diff --git a/petabtests/cases/v2.0.0/pysb/0018/0018.py b/petabtests/cases/v2.0.0/pysb/0018/0018.py index ee32ec7..a57ed72 100644 --- a/petabtests/cases/v2.0.0/pysb/0018/0018.py +++ b/petabtests/cases/v2.0.0/pysb/0018/0018.py @@ -1,7 +1,7 @@ from inspect import cleandoc -import pandas as pd -from petab.v1.C import * +from petab.v2 import Problem +from petab.v2.C import * from petabtests import DEFAULT_PYSB_FILE, PetabTestCase, analytical_a @@ -17,73 +17,46 @@ """) # problem -------------------------------------------------------------------- - -condition_df = pd.DataFrame( - data={ - CONDITION_ID: ["c0"], - } -).set_index([CONDITION_ID]) - -measurement_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a", "obs_a"], - SIMULATION_CONDITION_ID: ["c0", "c0"], - TIME: [0, 10], - MEASUREMENT: [0.7, 0.1], - } +problem = Problem() +problem.add_observable("obs_a", "A", noise_formula=0.5) +problem.add_measurement("obs_a", "", time=0, measurement=0.7) +problem.add_measurement("obs_a", "", time=10, measurement=0.1) +problem.add_parameter( + "maps_to_a0", lb=0, ub=10, nominal_value=1, scale=LIN, estimate=True +) +problem.add_parameter( + "b0", lb=0, ub=10, nominal_value=0, scale=LIN, estimate=True +) +problem.add_parameter( + "maps_to_k1", lb=0, ub=10, nominal_value=0.8, scale=LIN, estimate=True +) +problem.add_parameter( + "k2", lb=0, ub=10, nominal_value=0.6, scale=LIN, estimate=True ) -observable_df = pd.DataFrame( - data={ - OBSERVABLE_ID: ["obs_a"], - OBSERVABLE_FORMULA: ["A"], - NOISE_FORMULA: [0.5], - } -).set_index([OBSERVABLE_ID]) - -parameter_df = pd.DataFrame( - data={ - PARAMETER_ID: ["maps_to_a0", "b0", "maps_to_k1", "k2"], - PARAMETER_SCALE: [LIN] * 4, - LOWER_BOUND: [0] * 4, - UPPER_BOUND: [10] * 4, - NOMINAL_VALUE: [1, 0, 0.8, 0.6], - ESTIMATE: [1] * 4, - } -).set_index(PARAMETER_ID) - -mapping_df = pd.DataFrame( - data={ - PETAB_ENTITY_ID: [ - "maps_to_a0", - "maps_to_b0", - "maps_to_k1", - "maps_to_k2", - ], - MODEL_ENTITY_ID: ["a0", "b0", "k1", "k2"], - } -).set_index(PETAB_ENTITY_ID) - +problem.add_mapping("maps_to_a0", "a0") +problem.add_mapping("maps_to_b0", "b0") +problem.add_mapping("maps_to_k1", "k1") +problem.add_mapping("maps_to_k2", "k2") # solutions ------------------------------------------------------------------ -simulation_df = measurement_df.copy(deep=True).rename( +simulation_df = problem.measurement_df.copy(deep=True).rename( columns={MEASUREMENT: SIMULATION} ) simulation_df[SIMULATION] = [ analytical_a(t, 1, 0, 0.8, 0.6) for t in simulation_df[TIME] ] - case = PetabTestCase( id=18, brief="Parameters in mapping table.", description=DESCRIPTION, model=DEFAULT_PYSB_FILE, - condition_dfs=[condition_df], - observable_dfs=[observable_df], - measurement_dfs=[measurement_df], + condition_dfs=[problem.condition_df], + observable_dfs=[problem.observable_df], + measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], - parameter_df=parameter_df, - mapping_df=mapping_df, + parameter_df=problem.parameter_df, + mapping_df=problem.mapping_df, ) diff --git a/petabtests/cases/v2.0.0/pysb/0018/_0018.yaml b/petabtests/cases/v2.0.0/pysb/0018/_0018.yaml index 0048e7e..85b4cf4 100644 --- a/petabtests/cases/v2.0.0/pysb/0018/_0018.yaml +++ b/petabtests/cases/v2.0.0/pysb/0018/_0018.yaml @@ -1,8 +1,8 @@ format_version: 2.0.0 parameter_file: _parameters.tsv problems: -- condition_files: - - _conditions.tsv +- condition_files: [] + experiment_files: [] mapping_files: - _mapping.tsv measurement_files: diff --git a/petabtests/cases/v2.0.0/pysb/0018/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0018/_measurements.tsv index a497632..59bd3e4 100644 --- a/petabtests/cases/v2.0.0/pysb/0018/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0018/_measurements.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 +observableId experimentId time measurement +obs_a 0 0.7 +obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/pysb/0018/_parameters.tsv b/petabtests/cases/v2.0.0/pysb/0018/_parameters.tsv index ed47cec..c6dd51e 100644 --- a/petabtests/cases/v2.0.0/pysb/0018/_parameters.tsv +++ b/petabtests/cases/v2.0.0/pysb/0018/_parameters.tsv @@ -1,5 +1,5 @@ -parameterId parameterScale lowerBound upperBound nominalValue estimate -maps_to_a0 lin 0 10 1.0 1 -b0 lin 0 10 0.0 1 -maps_to_k1 lin 0 10 0.8 1 -k2 lin 0 10 0.6 1 +parameterId estimate nominalValue parameterScale lowerBound upperBound +maps_to_a0 1 1.0 lin 0 10 +b0 1 0.0 lin 0 10 +maps_to_k1 1 0.8 lin 0 10 +k2 1 0.6 lin 0 10 diff --git a/petabtests/cases/v2.0.0/pysb/0018/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0018/_simulations.tsv index c1339e4..8322fe9 100644 --- a/petabtests/cases/v2.0.0/pysb/0018/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0018/_simulations.tsv @@ -1,3 +1,3 @@ -observableId simulationConditionId time simulation -obs_a c0 0 1.0 -obs_a c0 10 0.42857190373069665 +observableId experimentId time simulation +obs_a 0 1.0 +obs_a 10 0.42857190373069665 From 564512fd7b384dc961fa03e62d3fc518bedc4399 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Thu, 19 Dec 2024 09:56:46 +0100 Subject: [PATCH 16/17] .. --- petabtests/cases/v1.0.0/sbml/0005/_model.xml | 2 +- petabtests/cases/v1.0.0/sbml/0011/_model.xml | 2 +- petabtests/cases/v1.0.0/sbml/0018/_model.xml | 2 +- petabtests/cases/v1.0.0/sbml/0018/model.xml | 2 +- petabtests/cases/v1.0.0/sbml/0019/_model.xml | 2 +- petabtests/cases/v2.0.0/sbml/0005/_model.xml | 2 +- petabtests/cases/v2.0.0/sbml/0011/_model.xml | 2 +- petabtests/cases/v2.0.0/sbml/0013/_model.xml | 2 +- petabtests/cases/v2.0.0/sbml/0018/_model.xml | 2 +- petabtests/cases/v2.0.0/sbml/0018/model.xml | 2 +- petabtests/cases/v2.0.0/sbml/0020/_model.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/petabtests/cases/v1.0.0/sbml/0005/_model.xml b/petabtests/cases/v1.0.0/sbml/0005/_model.xml index 0c56134..a6d4fba 100644 --- a/petabtests/cases/v1.0.0/sbml/0005/_model.xml +++ b/petabtests/cases/v1.0.0/sbml/0005/_model.xml @@ -1,5 +1,5 @@ - + diff --git a/petabtests/cases/v1.0.0/sbml/0011/_model.xml b/petabtests/cases/v1.0.0/sbml/0011/_model.xml index 3da37e6..20d64bd 100644 --- a/petabtests/cases/v1.0.0/sbml/0011/_model.xml +++ b/petabtests/cases/v1.0.0/sbml/0011/_model.xml @@ -1,5 +1,5 @@ - + diff --git a/petabtests/cases/v1.0.0/sbml/0018/_model.xml b/petabtests/cases/v1.0.0/sbml/0018/_model.xml index c3df580..30ffc31 100644 --- a/petabtests/cases/v1.0.0/sbml/0018/_model.xml +++ b/petabtests/cases/v1.0.0/sbml/0018/_model.xml @@ -1,5 +1,5 @@ - + diff --git a/petabtests/cases/v1.0.0/sbml/0018/model.xml b/petabtests/cases/v1.0.0/sbml/0018/model.xml index c3df580..30ffc31 100644 --- a/petabtests/cases/v1.0.0/sbml/0018/model.xml +++ b/petabtests/cases/v1.0.0/sbml/0018/model.xml @@ -1,5 +1,5 @@ - + diff --git a/petabtests/cases/v1.0.0/sbml/0019/_model.xml b/petabtests/cases/v1.0.0/sbml/0019/_model.xml index 3da37e6..20d64bd 100644 --- a/petabtests/cases/v1.0.0/sbml/0019/_model.xml +++ b/petabtests/cases/v1.0.0/sbml/0019/_model.xml @@ -1,5 +1,5 @@ - + diff --git a/petabtests/cases/v2.0.0/sbml/0005/_model.xml b/petabtests/cases/v2.0.0/sbml/0005/_model.xml index adf0666..67df968 100644 --- a/petabtests/cases/v2.0.0/sbml/0005/_model.xml +++ b/petabtests/cases/v2.0.0/sbml/0005/_model.xml @@ -1,5 +1,5 @@ - + diff --git a/petabtests/cases/v2.0.0/sbml/0011/_model.xml b/petabtests/cases/v2.0.0/sbml/0011/_model.xml index 3da37e6..20d64bd 100644 --- a/petabtests/cases/v2.0.0/sbml/0011/_model.xml +++ b/petabtests/cases/v2.0.0/sbml/0011/_model.xml @@ -1,5 +1,5 @@ - + diff --git a/petabtests/cases/v2.0.0/sbml/0013/_model.xml b/petabtests/cases/v2.0.0/sbml/0013/_model.xml index 3da37e6..20d64bd 100644 --- a/petabtests/cases/v2.0.0/sbml/0013/_model.xml +++ b/petabtests/cases/v2.0.0/sbml/0013/_model.xml @@ -1,5 +1,5 @@ - + diff --git a/petabtests/cases/v2.0.0/sbml/0018/_model.xml b/petabtests/cases/v2.0.0/sbml/0018/_model.xml index c3df580..30ffc31 100644 --- a/petabtests/cases/v2.0.0/sbml/0018/_model.xml +++ b/petabtests/cases/v2.0.0/sbml/0018/_model.xml @@ -1,5 +1,5 @@ - + diff --git a/petabtests/cases/v2.0.0/sbml/0018/model.xml b/petabtests/cases/v2.0.0/sbml/0018/model.xml index c3df580..30ffc31 100644 --- a/petabtests/cases/v2.0.0/sbml/0018/model.xml +++ b/petabtests/cases/v2.0.0/sbml/0018/model.xml @@ -1,5 +1,5 @@ - + diff --git a/petabtests/cases/v2.0.0/sbml/0020/_model.xml b/petabtests/cases/v2.0.0/sbml/0020/_model.xml index 3da37e6..20d64bd 100644 --- a/petabtests/cases/v2.0.0/sbml/0020/_model.xml +++ b/petabtests/cases/v2.0.0/sbml/0020/_model.xml @@ -1,5 +1,5 @@ - + From e9bd03d4eda9c6350d10f1c06d18e285105ca703 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Fri, 20 Dec 2024 12:11:25 +0100 Subject: [PATCH 17/17] .. --- petabtests/cases/v2.0.0/pysb/0006/0006.py | 4 ++-- petabtests/cases/v2.0.0/pysb/0006/_measurements.tsv | 4 ++-- petabtests/cases/v2.0.0/pysb/0006/_simulations.tsv | 4 ++-- petabtests/cases/v2.0.0/pysb/0009/0009.py | 1 + petabtests/cases/v2.0.0/pysb/0009/_0009.yaml | 3 ++- petabtests/cases/v2.0.0/pysb/0009/_experiments.tsv | 3 +++ petabtests/cases/v2.0.0/sbml/0001/_experiments.tsv | 2 -- petabtests/cases/v2.0.0/sbml/0002/_0002.yaml | 8 +++++--- petabtests/cases/v2.0.0/sbml/0002/_conditions.tsv | 2 -- petabtests/cases/v2.0.0/sbml/0003/_experiments.tsv | 2 -- petabtests/cases/v2.0.0/sbml/0004/_experiments.tsv | 2 -- petabtests/cases/v2.0.0/sbml/0005/_0005.yaml | 8 +++++--- petabtests/cases/v2.0.0/sbml/0006/_experiments.tsv | 2 -- petabtests/cases/v2.0.0/sbml/0007/_experiments.tsv | 2 -- petabtests/cases/v2.0.0/sbml/0008/_experiments.tsv | 2 -- petabtests/cases/v2.0.0/sbml/0009/_0009.yaml | 8 +++++--- petabtests/cases/v2.0.0/sbml/0010/_0010.yaml | 8 +++++--- petabtests/cases/v2.0.0/sbml/0011/_0011.yaml | 8 +++++--- petabtests/cases/v2.0.0/sbml/0012/_0012.yaml | 8 +++++--- petabtests/cases/v2.0.0/sbml/0013/_0013.yaml | 8 +++++--- petabtests/cases/v2.0.0/sbml/0014/_experiments.tsv | 2 -- petabtests/cases/v2.0.0/sbml/0015/_experiments.tsv | 2 -- petabtests/cases/v2.0.0/sbml/0016/_experiments.tsv | 2 -- petabtests/cases/v2.0.0/sbml/0017/_0017.yaml | 8 +++++--- petabtests/cases/v2.0.0/sbml/0017/_conditions.tsv | 1 - petabtests/cases/v2.0.0/sbml/0018/_0018.yaml | 8 +++++--- petabtests/cases/v2.0.0/sbml/0018/_conditions.tsv | 1 - petabtests/cases/v2.0.0/sbml/0019/0019.py | 5 ++--- petabtests/cases/v2.0.0/sbml/0019/_measurements.tsv | 4 ++-- petabtests/cases/v2.0.0/sbml/0019/_simulations.tsv | 4 ++-- petabtests/cases/v2.0.0/sbml/0020/_0020.yaml | 8 +++++--- petabtests/file.py | 6 ++++++ test/test_generate.py | 4 ++-- 33 files changed, 76 insertions(+), 68 deletions(-) create mode 100644 petabtests/cases/v2.0.0/pysb/0009/_experiments.tsv delete mode 100644 petabtests/cases/v2.0.0/sbml/0001/_experiments.tsv delete mode 100644 petabtests/cases/v2.0.0/sbml/0003/_experiments.tsv delete mode 100644 petabtests/cases/v2.0.0/sbml/0004/_experiments.tsv delete mode 100644 petabtests/cases/v2.0.0/sbml/0006/_experiments.tsv delete mode 100644 petabtests/cases/v2.0.0/sbml/0007/_experiments.tsv delete mode 100644 petabtests/cases/v2.0.0/sbml/0008/_experiments.tsv delete mode 100644 petabtests/cases/v2.0.0/sbml/0014/_experiments.tsv delete mode 100644 petabtests/cases/v2.0.0/sbml/0015/_experiments.tsv delete mode 100644 petabtests/cases/v2.0.0/sbml/0016/_experiments.tsv diff --git a/petabtests/cases/v2.0.0/pysb/0006/0006.py b/petabtests/cases/v2.0.0/pysb/0006/0006.py index fc638c6..d2a58d8 100644 --- a/petabtests/cases/v2.0.0/pysb/0006/0006.py +++ b/petabtests/cases/v2.0.0/pysb/0006/0006.py @@ -29,10 +29,10 @@ ) problem.add_measurement( - "obs_a", "c0", time=0, measurement=0.7, observable_parameters=(10,) + "obs_a", "", time=0, measurement=0.7, observable_parameters=(10,) ) problem.add_measurement( - "obs_a", "c0", time=10, measurement=0.1, observable_parameters=(15,) + "obs_a", "", time=10, measurement=0.1, observable_parameters=(15,) ) problem.add_parameter( diff --git a/petabtests/cases/v2.0.0/pysb/0006/_measurements.tsv b/petabtests/cases/v2.0.0/pysb/0006/_measurements.tsv index 16cb6a1..bcf38d9 100644 --- a/petabtests/cases/v2.0.0/pysb/0006/_measurements.tsv +++ b/petabtests/cases/v2.0.0/pysb/0006/_measurements.tsv @@ -1,3 +1,3 @@ observableId experimentId time measurement observableParameters -obs_a c0 0 0.7 10 -obs_a c0 10 0.1 15 +obs_a 0 0.7 10 +obs_a 10 0.1 15 diff --git a/petabtests/cases/v2.0.0/pysb/0006/_simulations.tsv b/petabtests/cases/v2.0.0/pysb/0006/_simulations.tsv index d9f49d5..27253c5 100644 --- a/petabtests/cases/v2.0.0/pysb/0006/_simulations.tsv +++ b/petabtests/cases/v2.0.0/pysb/0006/_simulations.tsv @@ -1,3 +1,3 @@ observableId experimentId time simulation observableParameters -obs_a c0 0 10.0 10 -obs_a c0 10 6.42857855596045 15 +obs_a 0 10.0 10 +obs_a 10 6.42857855596045 15 diff --git a/petabtests/cases/v2.0.0/pysb/0009/0009.py b/petabtests/cases/v2.0.0/pysb/0009/0009.py index ff15463..8c30e6f 100644 --- a/petabtests/cases/v2.0.0/pysb/0009/0009.py +++ b/petabtests/cases/v2.0.0/pysb/0009/0009.py @@ -72,4 +72,5 @@ measurement_dfs=[problem.measurement_df], simulation_dfs=[simulation_df], parameter_df=problem.parameter_df, + experiment_dfs=[problem.experiment_df], ) diff --git a/petabtests/cases/v2.0.0/pysb/0009/_0009.yaml b/petabtests/cases/v2.0.0/pysb/0009/_0009.yaml index df06036..4e0d35b 100644 --- a/petabtests/cases/v2.0.0/pysb/0009/_0009.yaml +++ b/petabtests/cases/v2.0.0/pysb/0009/_0009.yaml @@ -3,7 +3,8 @@ parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv - experiment_files: [] + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv model_files: diff --git a/petabtests/cases/v2.0.0/pysb/0009/_experiments.tsv b/petabtests/cases/v2.0.0/pysb/0009/_experiments.tsv new file mode 100644 index 0000000..430d0ee --- /dev/null +++ b/petabtests/cases/v2.0.0/pysb/0009/_experiments.tsv @@ -0,0 +1,3 @@ +experimentId time conditionId +e0 -inf preeq_c0 +e0 0.0 c0 diff --git a/petabtests/cases/v2.0.0/sbml/0001/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0001/_experiments.tsv deleted file mode 100644 index 9ae6a66..0000000 --- a/petabtests/cases/v2.0.0/sbml/0001/_experiments.tsv +++ /dev/null @@ -1,2 +0,0 @@ -experimentId conditionId time -experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0002/_0002.yaml b/petabtests/cases/v2.0.0/sbml/0002/_0002.yaml index c3170c2..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0002/_0002.yaml +++ b/petabtests/cases/v2.0.0/sbml/0002/_0002.yaml @@ -1,14 +1,16 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv - observable_files: - - _observables.tsv model_files: _model: language: sbml location: _model.xml -extensions: [] + observable_files: + - _observables.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0002/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0002/_conditions.tsv index aba08a4..61ad42d 100644 --- a/petabtests/cases/v2.0.0/sbml/0002/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0002/_conditions.tsv @@ -1,5 +1,3 @@ conditionId targetId targetValue valueType c0 a0 0.8 constant c1 a0 0.9 constant -c0 b0 constant -c1 b0 constant diff --git a/petabtests/cases/v2.0.0/sbml/0003/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0003/_experiments.tsv deleted file mode 100644 index 9ae6a66..0000000 --- a/petabtests/cases/v2.0.0/sbml/0003/_experiments.tsv +++ /dev/null @@ -1,2 +0,0 @@ -experimentId conditionId time -experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0004/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0004/_experiments.tsv deleted file mode 100644 index 9ae6a66..0000000 --- a/petabtests/cases/v2.0.0/sbml/0004/_experiments.tsv +++ /dev/null @@ -1,2 +0,0 @@ -experimentId conditionId time -experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0005/_0005.yaml b/petabtests/cases/v2.0.0/sbml/0005/_0005.yaml index c3170c2..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0005/_0005.yaml +++ b/petabtests/cases/v2.0.0/sbml/0005/_0005.yaml @@ -1,14 +1,16 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv - observable_files: - - _observables.tsv model_files: _model: language: sbml location: _model.xml -extensions: [] + observable_files: + - _observables.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0006/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0006/_experiments.tsv deleted file mode 100644 index 9ae6a66..0000000 --- a/petabtests/cases/v2.0.0/sbml/0006/_experiments.tsv +++ /dev/null @@ -1,2 +0,0 @@ -experimentId conditionId time -experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0007/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0007/_experiments.tsv deleted file mode 100644 index 9ae6a66..0000000 --- a/petabtests/cases/v2.0.0/sbml/0007/_experiments.tsv +++ /dev/null @@ -1,2 +0,0 @@ -experimentId conditionId time -experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0008/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0008/_experiments.tsv deleted file mode 100644 index 9ae6a66..0000000 --- a/petabtests/cases/v2.0.0/sbml/0008/_experiments.tsv +++ /dev/null @@ -1,2 +0,0 @@ -experimentId conditionId time -experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0009/_0009.yaml b/petabtests/cases/v2.0.0/sbml/0009/_0009.yaml index c3170c2..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0009/_0009.yaml +++ b/petabtests/cases/v2.0.0/sbml/0009/_0009.yaml @@ -1,14 +1,16 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv - observable_files: - - _observables.tsv model_files: _model: language: sbml location: _model.xml -extensions: [] + observable_files: + - _observables.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0010/_0010.yaml b/petabtests/cases/v2.0.0/sbml/0010/_0010.yaml index c3170c2..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0010/_0010.yaml +++ b/petabtests/cases/v2.0.0/sbml/0010/_0010.yaml @@ -1,14 +1,16 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv - observable_files: - - _observables.tsv model_files: _model: language: sbml location: _model.xml -extensions: [] + observable_files: + - _observables.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0011/_0011.yaml b/petabtests/cases/v2.0.0/sbml/0011/_0011.yaml index c3170c2..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0011/_0011.yaml +++ b/petabtests/cases/v2.0.0/sbml/0011/_0011.yaml @@ -1,14 +1,16 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv - observable_files: - - _observables.tsv model_files: _model: language: sbml location: _model.xml -extensions: [] + observable_files: + - _observables.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0012/_0012.yaml b/petabtests/cases/v2.0.0/sbml/0012/_0012.yaml index c3170c2..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0012/_0012.yaml +++ b/petabtests/cases/v2.0.0/sbml/0012/_0012.yaml @@ -1,14 +1,16 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv - observable_files: - - _observables.tsv model_files: _model: language: sbml location: _model.xml -extensions: [] + observable_files: + - _observables.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0013/_0013.yaml b/petabtests/cases/v2.0.0/sbml/0013/_0013.yaml index c3170c2..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0013/_0013.yaml +++ b/petabtests/cases/v2.0.0/sbml/0013/_0013.yaml @@ -1,14 +1,16 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv - observable_files: - - _observables.tsv model_files: _model: language: sbml location: _model.xml -extensions: [] + observable_files: + - _observables.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0014/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0014/_experiments.tsv deleted file mode 100644 index 9ae6a66..0000000 --- a/petabtests/cases/v2.0.0/sbml/0014/_experiments.tsv +++ /dev/null @@ -1,2 +0,0 @@ -experimentId conditionId time -experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0015/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0015/_experiments.tsv deleted file mode 100644 index 9ae6a66..0000000 --- a/petabtests/cases/v2.0.0/sbml/0015/_experiments.tsv +++ /dev/null @@ -1,2 +0,0 @@ -experimentId conditionId time -experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0016/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0016/_experiments.tsv deleted file mode 100644 index 9ae6a66..0000000 --- a/petabtests/cases/v2.0.0/sbml/0016/_experiments.tsv +++ /dev/null @@ -1,2 +0,0 @@ -experimentId conditionId time -experiment____c0 c0 0 diff --git a/petabtests/cases/v2.0.0/sbml/0017/_0017.yaml b/petabtests/cases/v2.0.0/sbml/0017/_0017.yaml index c3170c2..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0017/_0017.yaml +++ b/petabtests/cases/v2.0.0/sbml/0017/_0017.yaml @@ -1,14 +1,16 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv - observable_files: - - _observables.tsv model_files: _model: language: sbml location: _model.xml -extensions: [] + observable_files: + - _observables.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0017/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0017/_conditions.tsv index 287e74a..b8d6da1 100644 --- a/petabtests/cases/v2.0.0/sbml/0017/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0017/_conditions.tsv @@ -2,6 +2,5 @@ conditionId targetId targetValue valueType preeq_c0 k1 0.3 constant c0 k1 0.8 constant preeq_c0 B 2.0 initial -c0 B initial preeq_c0 A 0.0 initial c0 A 1.0 initial diff --git a/petabtests/cases/v2.0.0/sbml/0018/_0018.yaml b/petabtests/cases/v2.0.0/sbml/0018/_0018.yaml index c3170c2..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0018/_0018.yaml +++ b/petabtests/cases/v2.0.0/sbml/0018/_0018.yaml @@ -1,14 +1,16 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv - observable_files: - - _observables.tsv model_files: _model: language: sbml location: _model.xml -extensions: [] + observable_files: + - _observables.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0018/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0018/_conditions.tsv index 287e74a..b8d6da1 100644 --- a/petabtests/cases/v2.0.0/sbml/0018/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0018/_conditions.tsv @@ -2,6 +2,5 @@ conditionId targetId targetValue valueType preeq_c0 k1 0.3 constant c0 k1 0.8 constant preeq_c0 B 2.0 initial -c0 B initial preeq_c0 A 0.0 initial c0 A 1.0 initial diff --git a/petabtests/cases/v2.0.0/sbml/0019/0019.py b/petabtests/cases/v2.0.0/sbml/0019/0019.py index d2441db..ddcaac1 100644 --- a/petabtests/cases/v2.0.0/sbml/0019/0019.py +++ b/petabtests/cases/v2.0.0/sbml/0019/0019.py @@ -18,9 +18,8 @@ # problem -------------------------------------------------------------------- problem = Problem() # TODO use mapping here -problem.add_condition("c0") -problem.add_measurement("obs_a", "c0", 0, 0.7) -problem.add_measurement("obs_a", "c0", 10, 0.1) +problem.add_measurement("obs_a", "", 0, 0.7) +problem.add_measurement("obs_a", "", 10, 0.1) problem.add_observable("obs_a", "maps_to_A", 0.5) problem.add_parameter("a0", lb=0, ub=10, nominal_value=1, scale=LIN) problem.add_parameter("maps_to_b0", lb=0, ub=10, nominal_value=0, scale=LIN) diff --git a/petabtests/cases/v2.0.0/sbml/0019/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0019/_measurements.tsv index 25969da..59bd3e4 100644 --- a/petabtests/cases/v2.0.0/sbml/0019/_measurements.tsv +++ b/petabtests/cases/v2.0.0/sbml/0019/_measurements.tsv @@ -1,3 +1,3 @@ observableId experimentId time measurement -obs_a c0 0 0.7 -obs_a c0 10 0.1 +obs_a 0 0.7 +obs_a 10 0.1 diff --git a/petabtests/cases/v2.0.0/sbml/0019/_simulations.tsv b/petabtests/cases/v2.0.0/sbml/0019/_simulations.tsv index 3b04603..8322fe9 100644 --- a/petabtests/cases/v2.0.0/sbml/0019/_simulations.tsv +++ b/petabtests/cases/v2.0.0/sbml/0019/_simulations.tsv @@ -1,3 +1,3 @@ observableId experimentId time simulation -obs_a c0 0 1.0 -obs_a c0 10 0.42857190373069665 +obs_a 0 1.0 +obs_a 10 0.42857190373069665 diff --git a/petabtests/cases/v2.0.0/sbml/0020/_0020.yaml b/petabtests/cases/v2.0.0/sbml/0020/_0020.yaml index c3170c2..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0020/_0020.yaml +++ b/petabtests/cases/v2.0.0/sbml/0020/_0020.yaml @@ -1,14 +1,16 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv - observable_files: - - _observables.tsv model_files: _model: language: sbml location: _model.xml -extensions: [] + observable_files: + - _observables.tsv diff --git a/petabtests/file.py b/petabtests/file.py index 4219be2..188507b 100644 --- a/petabtests/file.py +++ b/petabtests/file.py @@ -258,6 +258,12 @@ def write_problem( tmp_exp_file = Path(dir_, "experiments.tsv") if tmp_exp_file.exists(): tmp_exp_file.rename(exp_file) + # update in yaml + with open(yaml_path) as f: + config = yaml.safe_load(f) + config[PROBLEMS][0][EXPERIMENT_FILES] = ["_experiments.tsv"] + with open(yaml_path, "w") as f: + yaml.dump(config, f, default_flow_style=False) format_version = 2 # FIXME Until a first libpetab with petab.v1 subpackage is released diff --git a/test/test_generate.py b/test/test_generate.py index ba5482f..790a157 100644 --- a/test/test_generate.py +++ b/test/test_generate.py @@ -22,7 +22,7 @@ def test_create_case(): Mostly for debugging purposes. """ - format_ = "pysb" + format_ = "sbml" version = "v2.0.0" - id_ = "0002" + id_ = "0019" create_case(format_=format_, version=version, id_=id_)