Skip to content

Commit a02214b

Browse files
committed
Add test case with estimated initial conditions specified via the conditions table
Closes #62
1 parent b31ef75 commit a02214b

26 files changed

+590
-2
lines changed

petabtests/cases/v1.0.0/sbml/0011/0011.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
This case tests initial concentrations in the condition table.
1212
For species `B`, the initial concentration is specified in the condition
13-
table, while for `A` it is given via an assignment rule in the SBML model.
13+
table, while for `A` it is given via an initial assignment in the SBML model.
1414
1515
## Model
1616

petabtests/cases/v1.0.0/sbml/0011/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
This case tests initial concentrations in the condition table.
66
For species `B`, the initial concentration is specified in the condition
7-
table, while for `A` it is given via an assignment rule in the SBML model.
7+
table, while for `A` it is given via an initial assignment in the SBML model.
88

99
## Model
1010

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from inspect import cleandoc
2+
3+
import pandas as pd
4+
from petab.C import *
5+
6+
from petabtests import PetabTestCase, analytical_a
7+
8+
DESCRIPTION = cleandoc("""
9+
## Objective
10+
11+
This case tests handling of initial concentrations that are specified
12+
in the conditions table. For species `A`, the initial concentration is
13+
estimated for species `B` the initial concentration is specified in the
14+
parameters table.
15+
16+
## Model
17+
18+
A simple conversion reaction `A <=> B` in a single compartment, following
19+
mass action kinetics.
20+
""")
21+
22+
# problem --------------------------------------------------------------------
23+
24+
condition_df = pd.DataFrame(data={
25+
CONDITION_ID: ['c0'],
26+
'A': ["initial_A"],
27+
'B': ["initial_B"],
28+
}).set_index([CONDITION_ID])
29+
30+
measurement_df = pd.DataFrame(data={
31+
OBSERVABLE_ID: ['obs_a', 'obs_a'],
32+
SIMULATION_CONDITION_ID: ['c0', 'c0'],
33+
TIME: [0, 10],
34+
MEASUREMENT: [0.7, 0.1]
35+
})
36+
37+
observable_df = pd.DataFrame(data={
38+
OBSERVABLE_ID: ['obs_a'],
39+
OBSERVABLE_FORMULA: ['A'],
40+
NOISE_FORMULA: [0.5]
41+
}).set_index([OBSERVABLE_ID])
42+
43+
parameter_df = pd.DataFrame(data={
44+
PARAMETER_ID: ['k1', 'k2', 'initial_A', 'initial_B'],
45+
PARAMETER_SCALE: [LIN, LIN, LOG10, LIN],
46+
LOWER_BOUND: [0] * 4,
47+
UPPER_BOUND: [10] * 4,
48+
NOMINAL_VALUE: [0.8, 0.6, 1, 2],
49+
ESTIMATE: [1] * 3 + [0],
50+
}).set_index(PARAMETER_ID)
51+
52+
# solutions ------------------------------------------------------------------
53+
54+
simulation_df = measurement_df.copy(deep=True).rename(
55+
columns={MEASUREMENT: SIMULATION})
56+
simulation_df[SIMULATION] = [analytical_a(t, 1, 2, 0.8, 0.6)
57+
for t in simulation_df[TIME]]
58+
59+
case = PetabTestCase(
60+
id=19,
61+
brief="Simulation. InitialAssignment to species overridden.",
62+
description=DESCRIPTION,
63+
model='conversion_modified.xml',
64+
condition_dfs=[condition_df],
65+
observable_dfs=[observable_df],
66+
measurement_dfs=[measurement_df],
67+
simulation_dfs=[simulation_df],
68+
parameter_df=parameter_df,
69+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# PEtab test case 0019
2+
3+
## Objective
4+
5+
This case tests handling of initial concentrations that are specified
6+
in the conditions table. For species `A`, the initial concentration is
7+
estimated for species `B` the initial concentration is specified in the
8+
parameters table.
9+
10+
## Model
11+
12+
A simple conversion reaction `A <=> B` in a single compartment, following
13+
mass action kinetics.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
format_version: 1
2+
parameter_file: _parameters.tsv
3+
problems:
4+
- condition_files:
5+
- _conditions.tsv
6+
measurement_files:
7+
- _measurements.tsv
8+
observable_files:
9+
- _observables.tsv
10+
sbml_files:
11+
- _model.xml
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
chi2: 5.98367121577545
2+
llh: -3.44341831317718
3+
simulation_files:
4+
- _simulations.tsv
5+
tol_chi2: 0.001
6+
tol_llh: 0.001
7+
tol_simulations: 0.001
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
conditionId A B
2+
c0 initial_A initial_B
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
observableId simulationConditionId time measurement
2+
obs_a c0 0 0.7
3+
obs_a c0 10 0.1
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<sbml xmlns="http://www.sbml.org/sbml/level2/version4" level="2" version="4">
3+
<model id="conversion_reaction_0" name="Conversion Reaction 0">
4+
5+
<listOfUnitDefinitions>
6+
<unitDefinition id="volume" name="volume">
7+
<listOfUnits>
8+
<unit kind="litre" exponent="1" scale="-3" multiplier="1"/>
9+
</listOfUnits>
10+
</unitDefinition>
11+
<unitDefinition id="substance" name="substance">
12+
<listOfUnits>
13+
<unit kind="mole" exponent="1" scale="-3" multiplier="1"/>
14+
</listOfUnits>
15+
</unitDefinition>
16+
</listOfUnitDefinitions>
17+
18+
<listOfCompartments>
19+
<compartment id="compartment" name="compartment" spatialDimensions="3" size="1" constant="true">
20+
</compartment>
21+
</listOfCompartments>
22+
23+
<listOfSpecies>
24+
<species id="A" name="A" compartment="compartment" initialConcentration="1" boundaryCondition="false" constant="false">
25+
</species>
26+
<species id="B" name="B" compartment="compartment" initialConcentration="1" boundaryCondition="false" constant="false">
27+
</species>
28+
</listOfSpecies>
29+
30+
<listOfParameters>
31+
<parameter id="a0" name="a0" value="1" constant="true">
32+
</parameter>
33+
<parameter id="k1" name="k1" value="0" constant="true">
34+
</parameter>
35+
<parameter id="k2" name="k2" value="0" constant="true">
36+
</parameter>
37+
</listOfParameters>
38+
39+
<listOfInitialAssignments>
40+
<initialAssignment symbol="A">
41+
<math xmlns="http://www.w3.org/1998/Math/MathML">
42+
<ci> a0 </ci>
43+
</math>
44+
</initialAssignment>
45+
</listOfInitialAssignments>
46+
47+
<listOfReactions>
48+
<reaction id="fwd" name="fwd" reversible="false">
49+
<listOfReactants>
50+
<speciesReference species="A" stoichiometry="1"/>
51+
</listOfReactants>
52+
<listOfProducts>
53+
<speciesReference species="B" stoichiometry="1"/>
54+
</listOfProducts>
55+
<kineticLaw>
56+
<math xmlns="http://www.w3.org/1998/Math/MathML">
57+
<apply>
58+
<times/>
59+
<ci> compartment </ci>
60+
<ci> k1 </ci>
61+
<ci> A </ci>
62+
</apply>
63+
</math>
64+
</kineticLaw>
65+
</reaction>
66+
<reaction id="rev" name="rev" reversible="false">
67+
<listOfReactants>
68+
<speciesReference species="B" stoichiometry="1"/>
69+
</listOfReactants>
70+
<listOfProducts>
71+
<speciesReference species="A" stoichiometry="1"/>
72+
</listOfProducts>
73+
<kineticLaw>
74+
<math xmlns="http://www.w3.org/1998/Math/MathML">
75+
<apply>
76+
<times/>
77+
<ci> compartment </ci>
78+
<ci> k2 </ci>
79+
<ci> B </ci>
80+
</apply>
81+
</math>
82+
</kineticLaw>
83+
</reaction>
84+
</listOfReactions>
85+
86+
</model>
87+
</sbml>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
observableId observableFormula noiseFormula
2+
obs_a A 0.5
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameterId parameterScale lowerBound upperBound nominalValue estimate
2+
k1 lin 0 10 0.8 1
3+
k2 lin 0 10 0.6 1
4+
initial_A log10 0 10 1.0 1
5+
initial_B lin 0 10 2.0 0
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
observableId simulationConditionId time simulation
2+
obs_a c0 0 1.0
3+
obs_a c0 10 1.2857140481346516
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<sbml xmlns="http://www.sbml.org/sbml/level2/version4" level="2" version="4">
3+
<model id="conversion_reaction_0" name="Conversion Reaction 0">
4+
5+
<listOfUnitDefinitions>
6+
<unitDefinition id="volume" name="volume">
7+
<listOfUnits>
8+
<unit kind="litre" exponent="1" scale="-3" multiplier="1"/>
9+
</listOfUnits>
10+
</unitDefinition>
11+
<unitDefinition id="substance" name="substance">
12+
<listOfUnits>
13+
<unit kind="mole" exponent="1" scale="-3" multiplier="1"/>
14+
</listOfUnits>
15+
</unitDefinition>
16+
</listOfUnitDefinitions>
17+
18+
<listOfCompartments>
19+
<compartment id="compartment" name="compartment" spatialDimensions="3" size="1" constant="true">
20+
</compartment>
21+
</listOfCompartments>
22+
23+
<listOfSpecies>
24+
<species id="A" name="A" compartment="compartment" initialConcentration="1" boundaryCondition="false" constant="false">
25+
</species>
26+
<species id="B" name="B" compartment="compartment" initialConcentration="1" boundaryCondition="false" constant="false">
27+
</species>
28+
</listOfSpecies>
29+
30+
<listOfParameters>
31+
<parameter id="a0" name="a0" value="1" constant="true">
32+
</parameter>
33+
<parameter id="k1" name="k1" value="0" constant="true">
34+
</parameter>
35+
<parameter id="k2" name="k2" value="0" constant="true">
36+
</parameter>
37+
</listOfParameters>
38+
39+
<listOfInitialAssignments>
40+
<initialAssignment symbol="A">
41+
<math xmlns="http://www.w3.org/1998/Math/MathML">
42+
<ci> a0 </ci>
43+
</math>
44+
</initialAssignment>
45+
</listOfInitialAssignments>
46+
47+
<listOfReactions>
48+
<reaction id="fwd" name="fwd" reversible="false">
49+
<listOfReactants>
50+
<speciesReference species="A" stoichiometry="1"/>
51+
</listOfReactants>
52+
<listOfProducts>
53+
<speciesReference species="B" stoichiometry="1"/>
54+
</listOfProducts>
55+
<kineticLaw>
56+
<math xmlns="http://www.w3.org/1998/Math/MathML">
57+
<apply>
58+
<times/>
59+
<ci> compartment </ci>
60+
<ci> k1 </ci>
61+
<ci> A </ci>
62+
</apply>
63+
</math>
64+
</kineticLaw>
65+
</reaction>
66+
<reaction id="rev" name="rev" reversible="false">
67+
<listOfReactants>
68+
<speciesReference species="B" stoichiometry="1"/>
69+
</listOfReactants>
70+
<listOfProducts>
71+
<speciesReference species="A" stoichiometry="1"/>
72+
</listOfProducts>
73+
<kineticLaw>
74+
<math xmlns="http://www.w3.org/1998/Math/MathML">
75+
<apply>
76+
<times/>
77+
<ci> compartment </ci>
78+
<ci> k2 </ci>
79+
<ci> B </ci>
80+
</apply>
81+
</math>
82+
</kineticLaw>
83+
</reaction>
84+
</listOfReactions>
85+
86+
</model>
87+
</sbml>

petabtests/cases/v1.0.0/sbml/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,7 @@ Simulation. Preequilibration. One species reinitialized, one not (NaN in conditi
7070

7171
Simulation. Preequilibration and RateRules. One state reinitialized, one not (NaN in condition table). InitialAssignment to species overridden.
7272

73+
# [0019](0019/)
74+
75+
Simulation. InitialAssignment to species overridden.
76+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from inspect import cleandoc
2+
3+
import pandas as pd
4+
from petab.C import *
5+
6+
from petabtests import PetabTestCase, analytical_a
7+
8+
DESCRIPTION = cleandoc("""
9+
## Objective
10+
11+
This case tests handling of initial concentrations that are specified
12+
in the conditions table. For species `A`, the initial concentration is
13+
estimated for species `B` the initial concentration is specified in the
14+
parameters table.
15+
16+
## Model
17+
18+
A simple conversion reaction `A <=> B` in a single compartment, following
19+
mass action kinetics.
20+
""")
21+
22+
# problem --------------------------------------------------------------------
23+
24+
condition_df = pd.DataFrame(data={
25+
CONDITION_ID: ['c0'],
26+
'A': ["initial_A"],
27+
'B': ["initial_B"],
28+
}).set_index([CONDITION_ID])
29+
30+
measurement_df = pd.DataFrame(data={
31+
OBSERVABLE_ID: ['obs_a', 'obs_a'],
32+
SIMULATION_CONDITION_ID: ['c0', 'c0'],
33+
TIME: [0, 10],
34+
MEASUREMENT: [0.7, 0.1]
35+
})
36+
37+
observable_df = pd.DataFrame(data={
38+
OBSERVABLE_ID: ['obs_a'],
39+
OBSERVABLE_FORMULA: ['A'],
40+
NOISE_FORMULA: [0.5]
41+
}).set_index([OBSERVABLE_ID])
42+
43+
parameter_df = pd.DataFrame(data={
44+
PARAMETER_ID: ['k1', 'k2', 'initial_A', 'initial_B'],
45+
PARAMETER_SCALE: [LIN, LIN, LOG10, LIN],
46+
LOWER_BOUND: [0] * 4,
47+
UPPER_BOUND: [10] * 4,
48+
NOMINAL_VALUE: [0.8, 0.6, 1, 2],
49+
ESTIMATE: [1] * 3 + [0],
50+
}).set_index(PARAMETER_ID)
51+
52+
# solutions ------------------------------------------------------------------
53+
54+
simulation_df = measurement_df.copy(deep=True).rename(
55+
columns={MEASUREMENT: SIMULATION})
56+
simulation_df[SIMULATION] = [analytical_a(t, 1, 2, 0.8, 0.6)
57+
for t in simulation_df[TIME]]
58+
59+
case = PetabTestCase(
60+
id=20,
61+
brief="Simulation. InitialAssignment to species overridden.",
62+
description=DESCRIPTION,
63+
model='conversion_modified.xml',
64+
condition_dfs=[condition_df],
65+
observable_dfs=[observable_df],
66+
measurement_dfs=[measurement_df],
67+
simulation_dfs=[simulation_df],
68+
parameter_df=parameter_df,
69+
)

0 commit comments

Comments
 (0)