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/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/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..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 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/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/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/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 diff --git a/petabtests/cases/v2.0.0/pysb/0006/0006.py b/petabtests/cases/v2.0.0/pysb/0006/0006.py index 79400ca..d2a58d8 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", "", time=0, measurement=0.7, observable_parameters=(10,) +) +problem.add_measurement( + "obs_a", "", 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..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 simulationConditionId time measurement observableParameters -obs_a c0 0 0.7 10 -obs_a c0 10 0.1 15 +observableId experimentId time measurement observableParameters +obs_a 0 0.7 10 +obs_a 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..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 simulationConditionId time simulation observableParameters -obs_a c0 0 10.0 10 -obs_a c0 10 6.42857855596045 15 +observableId experimentId time simulation observableParameters +obs_a 0 10.0 10 +obs_a 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 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..8c30e6f 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,10 @@ 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, + 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 493b4f8..4e0d35b 100644 --- a/petabtests/cases/v2.0.0/pysb/0009/_0009.yaml +++ b/petabtests/cases/v2.0.0/pysb/0009/_0009.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/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/_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/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 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 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 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 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 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..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 c0 0 0.7 -obs_a c0 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/0002/_0002.yaml b/petabtests/cases/v2.0.0/sbml/0002/_0002.yaml index b1337e7..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0002/_0002.yaml +++ b/petabtests/cases/v2.0.0/sbml/0002/_0002.yaml @@ -1,12 +1,15 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv model_files: - model_0: + _model: language: sbml location: _model.xml observable_files: diff --git a/petabtests/cases/v2.0.0/sbml/0002/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0002/_conditions.tsv index 6524332..61ad42d 100644 --- a/petabtests/cases/v2.0.0/sbml/0002/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0002/_conditions.tsv @@ -1,3 +1,3 @@ -conditionId a0 b0 -c0 0.8 -c1 0.9 +conditionId targetId targetValue valueType +c0 a0 0.8 constant +c1 a0 0.9 constant 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 9dbc71c..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 @@ -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/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..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 c0 0 0.7 0.5;2 -obs_a c0 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/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..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 c0 0 0.7 -obs_a c0 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/0005/_0005.yaml b/petabtests/cases/v2.0.0/sbml/0005/_0005.yaml index b1337e7..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0005/_0005.yaml +++ b/petabtests/cases/v2.0.0/sbml/0005/_0005.yaml @@ -1,12 +1,15 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv model_files: - model_0: + _model: language: sbml location: _model.xml observable_files: 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/0005/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0005/_experiments.tsv new file mode 100644 index 0000000..a566778 --- /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/0005/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0005/_measurements.tsv index 6016b73..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 @@ -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/_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/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..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 c0 0 0.7 10 -obs_a c0 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/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..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 c0 10 0.2 -obs_b c0 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/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..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 c0 0 0.7 -obs_a c0 10 0.1 -obs_a c0 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/0009/_0009.yaml b/petabtests/cases/v2.0.0/sbml/0009/_0009.yaml index b1337e7..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0009/_0009.yaml +++ b/petabtests/cases/v2.0.0/sbml/0009/_0009.yaml @@ -1,12 +1,15 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv model_files: - model_0: + _model: language: sbml location: _model.xml observable_files: 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/0009/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0009/_experiments.tsv new file mode 100644 index 0000000..998f34d --- /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/0009/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0009/_measurements.tsv index a9a1cb0..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 @@ -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/_0010.yaml b/petabtests/cases/v2.0.0/sbml/0010/_0010.yaml index b1337e7..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0010/_0010.yaml +++ b/petabtests/cases/v2.0.0/sbml/0010/_0010.yaml @@ -1,12 +1,15 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv model_files: - model_0: + _model: language: sbml location: _model.xml observable_files: 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/0010/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0010/_experiments.tsv new file mode 100644 index 0000000..998f34d --- /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/0010/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0010/_measurements.tsv index a9a1cb0..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 @@ -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/0011/_0011.yaml b/petabtests/cases/v2.0.0/sbml/0011/_0011.yaml index b1337e7..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0011/_0011.yaml +++ b/petabtests/cases/v2.0.0/sbml/0011/_0011.yaml @@ -1,12 +1,15 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv model_files: - model_0: + _model: language: sbml location: _model.xml observable_files: 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/0011/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0011/_experiments.tsv new file mode 100644 index 0000000..9ae6a66 --- /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/0011/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0011/_measurements.tsv index a497632..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 @@ -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/_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/0012/_0012.yaml b/petabtests/cases/v2.0.0/sbml/0012/_0012.yaml index b1337e7..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0012/_0012.yaml +++ b/petabtests/cases/v2.0.0/sbml/0012/_0012.yaml @@ -1,12 +1,15 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv model_files: - model_0: + _model: language: sbml location: _model.xml observable_files: 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/0012/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0012/_experiments.tsv new file mode 100644 index 0000000..9ae6a66 --- /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/0012/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0012/_measurements.tsv index a497632..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 @@ -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/_0013.yaml b/petabtests/cases/v2.0.0/sbml/0013/_0013.yaml index b1337e7..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0013/_0013.yaml +++ b/petabtests/cases/v2.0.0/sbml/0013/_0013.yaml @@ -1,12 +1,15 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv model_files: - model_0: + _model: language: sbml location: _model.xml observable_files: 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/0013/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0013/_experiments.tsv new file mode 100644 index 0000000..9ae6a66 --- /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/0013/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0013/_measurements.tsv index a497632..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 @@ -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/_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/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..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 c0 0 0.7 0.5;2 -obs_a c0 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/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..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 c0 0 0.7 noise -obs_a c0 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/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..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 c0 10 0.2 -obs_b c0 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/0017/_0017.yaml b/petabtests/cases/v2.0.0/sbml/0017/_0017.yaml index b1337e7..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0017/_0017.yaml +++ b/petabtests/cases/v2.0.0/sbml/0017/_0017.yaml @@ -1,12 +1,15 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv model_files: - model_0: + _model: language: sbml location: _model.xml observable_files: diff --git a/petabtests/cases/v2.0.0/sbml/0017/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0017/_conditions.tsv index 18cccad..b8d6da1 100644 --- a/petabtests/cases/v2.0.0/sbml/0017/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/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 targetValue valueType +preeq_c0 k1 0.3 constant +c0 k1 0.8 constant +preeq_c0 B 2.0 initial +preeq_c0 A 0.0 initial +c0 A 1.0 initial 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..998f34d --- /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/0017/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0017/_measurements.tsv index a9a1cb0..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 @@ -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/0018/_0018.yaml b/petabtests/cases/v2.0.0/sbml/0018/_0018.yaml index b1337e7..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0018/_0018.yaml +++ b/petabtests/cases/v2.0.0/sbml/0018/_0018.yaml @@ -1,12 +1,15 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv model_files: - model_0: + _model: language: sbml location: _model.xml observable_files: diff --git a/petabtests/cases/v2.0.0/sbml/0018/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0018/_conditions.tsv index 18cccad..b8d6da1 100644 --- a/petabtests/cases/v2.0.0/sbml/0018/_conditions.tsv +++ b/petabtests/cases/v2.0.0/sbml/0018/_conditions.tsv @@ -1,3 +1,6 @@ -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 +preeq_c0 A 0.0 initial +c0 A 1.0 initial 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..998f34d --- /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/0018/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0018/_measurements.tsv index b3885d3..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 @@ -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/_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/0019/0019.py b/petabtests/cases/v2.0.0/sbml/0019/0019.py index 55a9921..ddcaac1 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,40 @@ """) # 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_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) +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..86402e6 100644 --- a/petabtests/cases/v2.0.0/sbml/0019/_0019.yaml +++ b/petabtests/cases/v2.0.0/sbml/0019/_0019.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/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/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0019/_measurements.tsv index a497632..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 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/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/0019/_simulations.tsv b/petabtests/cases/v2.0.0/sbml/0019/_simulations.tsv index c1339e4..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 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/sbml/0020/_0020.yaml b/petabtests/cases/v2.0.0/sbml/0020/_0020.yaml index b1337e7..8b85ee0 100644 --- a/petabtests/cases/v2.0.0/sbml/0020/_0020.yaml +++ b/petabtests/cases/v2.0.0/sbml/0020/_0020.yaml @@ -1,12 +1,15 @@ +extensions: [] format_version: 2.0.0 parameter_file: _parameters.tsv problems: - condition_files: - _conditions.tsv + experiment_files: + - _experiments.tsv measurement_files: - _measurements.tsv model_files: - model_0: + _model: language: sbml location: _model.xml observable_files: 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/0020/_experiments.tsv b/petabtests/cases/v2.0.0/sbml/0020/_experiments.tsv new file mode 100644 index 0000000..9ae6a66 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0020/_experiments.tsv @@ -0,0 +1,2 @@ +experimentId conditionId time +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 a497632..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 @@ -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/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 @@ - + 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..681b3f0 100644 --- a/petabtests/cases/v2.0.0/sbml/0021/_0021.yaml +++ b/petabtests/cases/v2.0.0/sbml/0021/_0021.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/sbml/0021/_conditions.tsv b/petabtests/cases/v2.0.0/sbml/0021/_conditions.tsv deleted file mode 100644 index f15e327..0000000 --- a/petabtests/cases/v2.0.0/sbml/0021/_conditions.tsv +++ /dev/null @@ -1,2 +0,0 @@ -conditionId -c0 diff --git a/petabtests/cases/v2.0.0/sbml/0021/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0021/_measurements.tsv index 687cf08..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 -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/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..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 -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 diff --git a/petabtests/core.py b/petabtests/core.py index 9812977..2341b84 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,69 +46,31 @@ 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: case_dir = get_case_dir( format_=format_, version=version, id_=case_id ) - logger.info("# ", format_, version, case_id, 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] + logger.info( + f"Processing {version}/{format_} #{case_id} at {case_dir}" + ) + + 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, - 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" @@ -112,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) @@ -125,3 +145,19 @@ 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.""" + 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() diff --git a/petabtests/file.py b/petabtests/file.py index 1ed9bd2..188507b 100644 --- a/petabtests/file.py +++ b/petabtests/file.py @@ -6,10 +6,17 @@ 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 +from pprint import pprint +import logging +from petab.v2.C import EXPERIMENT_FILES + +logger = logging.getLogger("petab_test_suite") + __all__ = [ "get_case_dir", @@ -38,9 +45,11 @@ 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: + """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) @@ -48,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) @@ -75,6 +87,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, @@ -82,13 +95,14 @@ 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 ---------- 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. @@ -109,8 +123,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,10 +166,17 @@ 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] = {} + 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_, @@ -191,6 +215,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" @@ -198,7 +232,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 +240,32 @@ 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 + + # 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) + # 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 try: # new petab version @@ -222,16 +282,18 @@ 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." ) 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 +342,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], ) @@ -299,6 +362,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" 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 diff --git a/test/test_generate.py b/test/test_generate.py index 40238be..790a157 100644 --- a/test/test_generate.py +++ b/test/test_generate.py @@ -1,15 +1,28 @@ -from petabtests.core import create +from petabtests.core import create_all from petabtests.C import CASES_DIR import sys import subprocess +from petabtests.core import create_case + 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 ) 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_ = "sbml" + version = "v2.0.0" + id_ = "0019" + create_case(format_=format_, version=version, id_=id_)