Skip to content
Merged
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
65 changes: 65 additions & 0 deletions petabtests/cases/v2.0.0/sbml/0028/0028.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
from inspect import cleandoc

from petab.v2.C import *
from petab.v2 import Problem
from petabtests import PetabV2TestCase, analytical_a, analytical_b, DEFAULT_SBML_FILE

DESCRIPTION = cleandoc("""
## Objective

This case tests applies a PEtab condition at a non-initial time point,
where the condition is triggered at a time point that does not have any
measurements.

## Model

A simple conversion reaction `A <=> B` in a single compartment, following
mass action kinetics.
""")

# problem --------------------------------------------------------------------
a0 = 1
b0 = 1
k1 = 0.8
k2 = 0.6
problem = Problem()

problem.add_condition(
"condition1",
"condition1",
A="A + 5.0",
)
problem.add_experiment("experiment1", 0, "", 7, "condition1")


problem.add_observable("obs_a", "A", noise_formula="0.5")
problem.add_measurement("obs_a", experiment_id="experiment1", time=0, measurement=0.7)
problem.add_measurement("obs_a", experiment_id="experiment1", time=10, measurement=0.1)

problem.add_parameter("k1", lb=0, ub=10, nominal_value=k1, estimate=True)
problem.add_parameter("k2", lb=0, ub=10, nominal_value=k2, estimate=True)


# solutions ------------------------------------------------------------------

simulation_df = problem.measurement_df.copy(deep=True).rename(
columns={MEASUREMENT: SIMULATION}
)
# in the model, concentrations are used, which do not depend on the
# compartment size, so that the species values should stay the same
a7 = analytical_a(7.0, a0=a0, b0=b0, k1=k1, k2=k2)
b7 = analytical_b(7.0, a0=a0, b0=b0, k1=k1, k2=k2)
simulation_df[SIMULATION] = [
a0,
analytical_a(3.0, a0=(a7 + 5.0), b0=b7, k1=k1, k2=k2)
]

case = PetabV2TestCase.from_problem(
id=28,
brief="Simulation. None t0 condition applied at time-point "
"without measurements.",
description=DESCRIPTION,
model=DEFAULT_SBML_FILE,
problem=problem,
simulation_df=simulation_df,
)
12 changes: 12 additions & 0 deletions petabtests/cases/v2.0.0/sbml/0028/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# PEtab test case 0028

## Objective

This case tests applies a PEtab condition at a non-initial time point,
where the condition is triggered at a time point that does not have any
measurements.

## Model

A simple conversion reaction `A <=> B` in a single compartment, following
mass action kinetics.
17 changes: 17 additions & 0 deletions petabtests/cases/v2.0.0/sbml/0028/_0028.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
condition_files:
- _conditions.tsv
experiment_files:
- _experiments.tsv
format_version: 2.0.0
mapping_files:
- _mapping.tsv
measurement_files:
- _measurements.tsv
model_files:
model_0:
language: sbml
location: _model.xml
observable_files:
- _observables.tsv
parameter_files:
- _parameters.tsv
7 changes: 7 additions & 0 deletions petabtests/cases/v2.0.0/sbml/0028/_0028_solution.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
chi2: 35.00133792381521
llh: -17.95225166719706
simulation_files:
- _simulations.tsv
tol_chi2: 0.001
tol_llh: 0.001
tol_simulations: 0.001
2 changes: 2 additions & 0 deletions petabtests/cases/v2.0.0/sbml/0028/_conditions.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
conditionId targetId targetValue
condition1 A A + 5.0
3 changes: 3 additions & 0 deletions petabtests/cases/v2.0.0/sbml/0028/_experiments.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
experimentId time conditionId
experiment1 0.0
experiment1 7.0 condition1
2 changes: 2 additions & 0 deletions petabtests/cases/v2.0.0/sbml/0028/_mapping.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
petabEntityId modelEntityId name
condition1 condition1
3 changes: 3 additions & 0 deletions petabtests/cases/v2.0.0/sbml/0028/_measurements.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
modelId observableId experimentId time measurement observableParameters noiseParameters
obs_a experiment1 0.0 0.7
obs_a experiment1 10.0 0.1
94 changes: 94 additions & 0 deletions petabtests/cases/v2.0.0/sbml/0028/_model.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level2/version4" level="2" version="4">
<model id="conversion_reaction_0" name="Conversion Reaction 0">

<listOfUnitDefinitions>
<unitDefinition id="volume" name="volume">
<listOfUnits>
<unit kind="litre" exponent="1" scale="-3" multiplier="1"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="substance" name="substance">
<listOfUnits>
<unit kind="mole" exponent="1" scale="-3" multiplier="1"/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>

<listOfCompartments>
<compartment id="compartment" name="compartment" spatialDimensions="3" size="1" constant="true">
</compartment>
</listOfCompartments>

<listOfSpecies>
<species id="A" name="A" compartment="compartment" initialConcentration="2" boundaryCondition="false" constant="false">
</species>
<species id="B" name="B" compartment="compartment" initialConcentration="2" boundaryCondition="false" constant="false">
</species>
</listOfSpecies>

<listOfParameters>
<parameter id="a0" name="a0" value="1" constant="true">
</parameter>
<parameter id="b0" name="b0" value="1" constant="true">
</parameter>
<parameter id="k1" name="k1" value="0" constant="true">
</parameter>
<parameter id="k2" name="k2" value="0" constant="true">
</parameter>
</listOfParameters>

<listOfInitialAssignments>
<initialAssignment symbol="A">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<ci> a0 </ci>
</math>
</initialAssignment>
<initialAssignment symbol="B">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<ci> b0 </ci>
</math>
</initialAssignment>
</listOfInitialAssignments>

<listOfReactions>
<reaction id="fwd" name="fwd" reversible="false">
<listOfReactants>
<speciesReference species="A" stoichiometry="1"/>
</listOfReactants>
<listOfProducts>
<speciesReference species="B" stoichiometry="1"/>
</listOfProducts>
<kineticLaw>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<times/>
<ci> compartment </ci>
<ci> k1 </ci>
<ci> A </ci>
</apply>
</math>
</kineticLaw>
</reaction>
<reaction id="rev" name="rev" reversible="false">
<listOfReactants>
<speciesReference species="B" stoichiometry="1"/>
</listOfReactants>
<listOfProducts>
<speciesReference species="A" stoichiometry="1"/>
</listOfProducts>
<kineticLaw>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<times/>
<ci> compartment </ci>
<ci> k2 </ci>
<ci> B </ci>
</apply>
</math>
</kineticLaw>
</reaction>
</listOfReactions>

</model>
</sbml>
2 changes: 2 additions & 0 deletions petabtests/cases/v2.0.0/sbml/0028/_observables.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
observableId observableName observableFormula noiseFormula noiseDistribution observablePlaceholders noisePlaceholders
obs_a A 0.500000000000000 normal
3 changes: 3 additions & 0 deletions petabtests/cases/v2.0.0/sbml/0028/_parameters.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
parameterId lowerBound upperBound nominalValue estimate priorDistribution priorParameters
k1 0.0 10.0 0.8 true
k2 0.0 10.0 0.6 true
3 changes: 3 additions & 0 deletions petabtests/cases/v2.0.0/sbml/0028/_simulations.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
modelId observableId experimentId time simulation observableParameters noiseParameters
obs_a experiment1 0.0 1.0
obs_a experiment1 10.0 3.0428446239911824
4 changes: 4 additions & 0 deletions petabtests/cases/v2.0.0/sbml/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,7 @@ Simulation. Estimated initial value via math expressions in conditions table.

Simulation. Condition-specific parameters defined via math expressions in the parameter table.

# [0028](0028/)

Simulation. None t0 condition applied at time-point without measurements.