|
| 1 | +from inspect import cleandoc |
| 2 | + |
| 3 | +from petab.v2.C import * |
| 4 | +from petab.v2 import Problem |
| 5 | +from petabtests import PetabV2TestCase, analytical_a, analytical_b, DEFAULT_SBML_FILE |
| 6 | + |
| 7 | +DESCRIPTION = cleandoc(""" |
| 8 | +## Objective |
| 9 | +
|
| 10 | +This case tests applies a PEtab condition at a non-initial time point, |
| 11 | +where the condition is triggered at a time point that does not have any |
| 12 | +measurements. |
| 13 | +
|
| 14 | +## Model |
| 15 | +
|
| 16 | +A simple conversion reaction `A <=> B` in a single compartment, following |
| 17 | +mass action kinetics. |
| 18 | +""") |
| 19 | + |
| 20 | +# problem -------------------------------------------------------------------- |
| 21 | +a0 = 1 |
| 22 | +b0 = 1 |
| 23 | +k1 = 0.8 |
| 24 | +k2 = 0.6 |
| 25 | +problem = Problem() |
| 26 | + |
| 27 | +problem.add_condition( |
| 28 | + "condition1", |
| 29 | + "condition1", |
| 30 | + A="A + 5.0", |
| 31 | +) |
| 32 | +problem.add_experiment("experiment1", 0, "", 7, "condition1") |
| 33 | + |
| 34 | + |
| 35 | +problem.add_observable("obs_a", "A", noise_formula="0.5") |
| 36 | +problem.add_measurement("obs_a", experiment_id="experiment1", time=0, measurement=0.7) |
| 37 | +problem.add_measurement("obs_a", experiment_id="experiment1", time=10, measurement=0.1) |
| 38 | + |
| 39 | +problem.add_parameter("k1", lb=0, ub=10, nominal_value=k1, estimate=True) |
| 40 | +problem.add_parameter("k2", lb=0, ub=10, nominal_value=k2, estimate=True) |
| 41 | + |
| 42 | + |
| 43 | +# solutions ------------------------------------------------------------------ |
| 44 | + |
| 45 | +simulation_df = problem.measurement_df.copy(deep=True).rename( |
| 46 | + columns={MEASUREMENT: SIMULATION} |
| 47 | +) |
| 48 | +# in the model, concentrations are used, which do not depend on the |
| 49 | +# compartment size, so that the species values should stay the same |
| 50 | +a7 = analytical_a(7.0, a0=a0, b0=b0, k1=k1, k2=k2) |
| 51 | +b7 = analytical_b(7.0, a0=a0, b0=b0, k1=k1, k2=k2) |
| 52 | +simulation_df[SIMULATION] = [ |
| 53 | + a0, |
| 54 | + analytical_a(3.0, a0=(a7 + 5.0), b0=b7, k1=k1, k2=k2) |
| 55 | +] |
| 56 | + |
| 57 | +case = PetabV2TestCase.from_problem( |
| 58 | + id=28, |
| 59 | + brief="Simulation. None t0 condition applied at time-point " |
| 60 | + "without measurements.", |
| 61 | + description=DESCRIPTION, |
| 62 | + model=DEFAULT_SBML_FILE, |
| 63 | + problem=problem, |
| 64 | + simulation_df=simulation_df, |
| 65 | +) |
0 commit comments