Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update petab v2 tests #80

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion petabtests/cases/v1.0.0/sbml/0005/_model.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by libAntimony version v2.14.0 with libSBML version 5.20.2. -->
<!-- Created by libAntimony version v2.15.0 with libSBML version 5.20.2. -->
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" version="2">
<model metaid="petab_test_0011" id="petab_test_0011">
<listOfCompartments>
Expand Down
2 changes: 1 addition & 1 deletion petabtests/cases/v1.0.0/sbml/0011/_model.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by libAntimony version v2.14.0 with libSBML version 5.20.2. -->
<!-- Created by libAntimony version v2.15.0 with libSBML version 5.20.2. -->
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" version="2">
<model metaid="petab_test_0011" id="petab_test_0011">
<listOfCompartments>
Expand Down
2 changes: 1 addition & 1 deletion petabtests/cases/v1.0.0/sbml/0018/_model.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by libAntimony version v2.14.0 with libSBML version 5.20.2. -->
<!-- Created by libAntimony version v2.15.0 with libSBML version 5.20.2. -->
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" version="2">
<model metaid="petab_test_0018" id="petab_test_0018">
<listOfCompartments>
Expand Down
2 changes: 1 addition & 1 deletion petabtests/cases/v1.0.0/sbml/0018/model.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by libAntimony version v2.14.0 with libSBML version 5.20.2. -->
<!-- Created by libAntimony version v2.15.0 with libSBML version 5.20.2. -->
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" version="2">
<model metaid="petab_test_0018" id="petab_test_0018">
<listOfCompartments>
Expand Down
2 changes: 1 addition & 1 deletion petabtests/cases/v1.0.0/sbml/0019/_model.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by libAntimony version v2.14.0 with libSBML version 5.20.2. -->
<!-- Created by libAntimony version v2.15.0 with libSBML version 5.20.2. -->
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" version="2">
<model metaid="petab_test_0011" id="petab_test_0011">
<listOfCompartments>
Expand Down
53 changes: 15 additions & 38 deletions petabtests/cases/v2.0.0/pysb/0001/0001.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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] = [
Expand All @@ -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,
)
4 changes: 2 additions & 2 deletions petabtests/cases/v2.0.0/pysb/0001/_0001.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
6 changes: 3 additions & 3 deletions petabtests/cases/v2.0.0/pysb/0001/_measurements.tsv
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions petabtests/cases/v2.0.0/pysb/0001/_parameters.tsv
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions petabtests/cases/v2.0.0/pysb/0001/_simulations.tsv
Original file line number Diff line number Diff line change
@@ -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
70 changes: 27 additions & 43 deletions petabtests/cases/v2.0.0/pysb/0002/0002.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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,
)
2 changes: 2 additions & 0 deletions petabtests/cases/v2.0.0/pysb/0002/_0002.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ parameter_file: _parameters.tsv
problems:
- condition_files:
- _conditions.tsv
experiment_files:
- _experiments.tsv
measurement_files:
- _measurements.tsv
model_files:
Expand Down
6 changes: 3 additions & 3 deletions petabtests/cases/v2.0.0/pysb/0002/_conditions.tsv
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions petabtests/cases/v2.0.0/pysb/0002/_experiments.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
experimentId time conditionId
e0 0 c0
e1 0 c1
10 changes: 5 additions & 5 deletions petabtests/cases/v2.0.0/pysb/0002/_measurements.tsv
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions petabtests/cases/v2.0.0/pysb/0002/_parameters.tsv
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions petabtests/cases/v2.0.0/pysb/0002/_simulations.tsv
Original file line number Diff line number Diff line change
@@ -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
62 changes: 22 additions & 40 deletions petabtests/cases/v2.0.0/pysb/0003/0003.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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] = [
Expand All @@ -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,
)
4 changes: 2 additions & 2 deletions petabtests/cases/v2.0.0/pysb/0003/_0003.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Loading
Loading