Skip to content

Commit

Permalink
Add test cases for PEtab v2.0.0 (#53)
Browse files Browse the repository at this point in the history
including test cases for multilanguage proposal  PEtab-dev/PEtab#538
  • Loading branch information
dweindl authored Feb 28, 2023
1 parent 1720558 commit ca54880
Show file tree
Hide file tree
Showing 579 changed files with 4,998 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .ci_pip_reqs.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pytest
flake8
https://github.com/petab-dev/libpetab-python/archive/develop.zip
https://github.com/petab-dev/libpetab-python/archive/model_pysb.zip
4 changes: 3 additions & 1 deletion .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ jobs:
pip install -e .
- name: Run tests
run: |
python -m flake8 --exclude=build,doc,tmp,petabtests/cases/pysb/*/_model.py,petabtests/cases/pysb/*/conversion_modified_pysb.py,petabtests/conversion_pysb.py --extend-ignore=F403,F405
python -m flake8 \
--exclude=build,doc,tmp,_model.py,conversion_modified_pysb.py,conversion_pysb.py \
--extend-ignore=F403,F405
pytest test
2 changes: 0 additions & 2 deletions petabtests/C.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
BASE_DIR = Path(__file__).parent

CASES_DIR = BASE_DIR / 'cases'
SBML_DIR = CASES_DIR / 'sbml'
PYSB_DIR = CASES_DIR / 'pysb'

DEFAULT_SBML_FILE = BASE_DIR / 'conversion.xml'
DEFAULT_PYSB_FILE = BASE_DIR / 'conversion_pysb.py'
Expand Down
1 change: 0 additions & 1 deletion petabtests/cases/sbml

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
format_version: 1
format_version: 2.0.0
parameter_file: _parameters.tsv
problems:
- condition_files:
- _conditions.tsv
measurement_files:
- _measurements.tsv
model_files:
model_0:
language: pysb
location: _model.py
observable_files:
- _observables.tsv
sbml_files:
- _model.py
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
format_version: 1
format_version: 2.0.0
parameter_file: _parameters.tsv
problems:
- condition_files:
- _conditions.tsv
measurement_files:
- _measurements.tsv
model_files:
model_0:
language: pysb
location: _model.py
observable_files:
- _observables.tsv
sbml_files:
- _model.py
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
format_version: 1
format_version: 2.0.0
parameter_file: _parameters.tsv
problems:
- condition_files:
- _conditions.tsv
measurement_files:
- _measurements.tsv
model_files:
model_0:
language: pysb
location: _model.py
observable_files:
- _observables.tsv
sbml_files:
- _model.py
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
format_version: 1
format_version: 2.0.0
parameter_file: _parameters.tsv
problems:
- condition_files:
- _conditions.tsv
measurement_files:
- _measurements.tsv
model_files:
model_0:
language: pysb
location: _model.py
observable_files:
- _observables.tsv
sbml_files:
- _model.py
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
format_version: 1
format_version: 2.0.0
parameter_file: _parameters.tsv
problems:
- condition_files:
- _conditions.tsv
measurement_files:
- _measurements.tsv
model_files:
model_0:
language: pysb
location: _model.py
observable_files:
- _observables.tsv
sbml_files:
- _model.py
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
format_version: 1
format_version: 2.0.0
parameter_file: _parameters.tsv
problems:
- condition_files:
- _conditions.tsv
measurement_files:
- _measurements.tsv
model_files:
model_0:
language: pysb
location: _model.py
observable_files:
- _observables.tsv
sbml_files:
- _model.py
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
format_version: 1
format_version: 2.0.0
parameter_file: _parameters.tsv
problems:
- condition_files:
- _conditions.tsv
measurement_files:
- _measurements.tsv
model_files:
model_0:
language: pysb
location: _model.py
observable_files:
- _observables.tsv
sbml_files:
- _model.py
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
format_version: 1
format_version: 2.0.0
parameter_file: _parameters.tsv
problems:
- condition_files:
- _conditions.tsv
measurement_files:
- _measurements.tsv
model_files:
model_0:
language: pysb
location: _model.py
observable_files:
- _observables.tsv
sbml_files:
- _model.py
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
format_version: 1
format_version: 2.0.0
parameter_file: _parameters.tsv
problems:
- condition_files:
- _conditions.tsv
measurement_files:
- _measurements.tsv
model_files:
model_0:
language: pysb
location: _model.py
observable_files:
- _observables.tsv
sbml_files:
- _model.py
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
83 changes: 83 additions & 0 deletions petabtests/cases/v2.0.0/pysb/0010/0010.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from inspect import cleandoc

import pandas as pd
from petab.C import *

from petabtests import DEFAULT_PYSB_FILE, PetabTestCase, analytical_a

DESCRIPTION = cleandoc("""
## Objective
This case tests support for partial preequilibration.
The model is to be simulated for a preequilibration condition and a
simulation condition.
Species `B` is to be reinitialized after preequilibration.
For `A` the preequilibration result is to be used.
## Model
A simple conversion reaction `A <=> B` in a single compartment, following
mass action kinetics.
""")

# 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]
})

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(
columns={MEASUREMENT: SIMULATION})
# simulate for far time point as steady state
steady_state_a = analytical_a(1000, 1, 0, 0.3, 0.6)
# use steady state as initial state
simulation_df[SIMULATION] = [
analytical_a(t, steady_state_a, 1, 0.8, 0.6)
for t in simulation_df[TIME]]

case = PetabTestCase(
id=10,
brief="Simulation. Preequilibration. One species reinitialized, one not. "
"InitialAssignment to species overridden.",
description=DESCRIPTION,
model=DEFAULT_PYSB_FILE,
condition_dfs=[condition_df],
observable_dfs=[observable_df],
measurement_dfs=[measurement_df],
simulation_dfs=[simulation_df],
parameter_df=parameter_df,
mapping_df=mapping_df,
)
File renamed without changes.
14 changes: 14 additions & 0 deletions petabtests/cases/v2.0.0/pysb/0010/_0010.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
format_version: 2.0.0
parameter_file: _parameters.tsv
problems:
- condition_files:
- _conditions.tsv
mapping_file: _mapping.tsv
measurement_files:
- _measurements.tsv
model_files:
model_0:
language: pysb
location: _model.py
observable_files:
- _observables.tsv
File renamed without changes.
3 changes: 3 additions & 0 deletions petabtests/cases/v2.0.0/pysb/0010/_mapping.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
petabEntityId modelEntityId
A A_() ** compartment
B B_() ** compartment
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
73 changes: 73 additions & 0 deletions petabtests/cases/v2.0.0/pysb/0011/0011.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
from inspect import cleandoc

import pandas as pd
from petab.C import *

from petabtests import PetabTestCase, analytical_a

DESCRIPTION = cleandoc("""
## Objective
This case tests initial concentrations in the condition table.
For species `B`, the initial concentration is specified in the condition
table, while for `A` it is given via an assignment rule in the SBML model.
## Model
A simple conversion reaction `A <=> B` in a single compartment, following
mass action kinetics.
""")

# problem --------------------------------------------------------------------

condition_df = pd.DataFrame(data={
CONDITION_ID: ['c0'],
'B': [2]
}).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: ['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)

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

simulation_df = measurement_df.copy(deep=True).rename(
columns={MEASUREMENT: SIMULATION})
simulation_df[SIMULATION] = [analytical_a(t, 1, 2, 0.8, 0.6)
for t in simulation_df[TIME]]

case = PetabTestCase(
id=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],
simulation_dfs=[simulation_df],
parameter_df=parameter_df,
mapping_df=mapping_df,
)
File renamed without changes.
14 changes: 14 additions & 0 deletions petabtests/cases/v2.0.0/pysb/0011/_0011.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
format_version: 2.0.0
parameter_file: _parameters.tsv
problems:
- condition_files:
- _conditions.tsv
mapping_file: _mapping.tsv
measurement_files:
- _measurements.tsv
model_files:
model_0:
language: pysb
location: _model.py
observable_files:
- _observables.tsv
File renamed without changes.
3 changes: 3 additions & 0 deletions petabtests/cases/v2.0.0/pysb/0011/_mapping.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
petabEntityId modelEntityId
A A_() ** compartment
B B_() ** compartment
File renamed without changes.
Loading

0 comments on commit ca54880

Please sign in to comment.