File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44Python tool to access the model collection.
55"""
66
7- from .base import get_problem , get_problem_yaml_path
7+ from .base import get_problem , get_problem_yaml_path , get_simulation_df
88from .C import MODEL_DIRS , MODELS , MODELS_DIR
99from .overview import get_overview_df
1010from importlib .metadata import PackageNotFoundError , version
Original file line number Diff line number Diff line change 66
77from .C import MODELS_DIR
88
9+ import pandas as pd
10+
911
1012def get_problem_yaml_path (id_ : str ) -> Path :
1113 """Get the path to the PEtab problem YAML file.
@@ -40,3 +42,21 @@ def get_problem(id_: str) -> petab.Problem:
4042 yaml_file = get_problem_yaml_path (id_ )
4143 petab_problem = petab .Problem .from_yaml (yaml_file )
4244 return petab_problem
45+
46+
47+ def get_simulation_df (id_ : str ) -> pd .DataFrame | None :
48+ """Get the simulation dataframe for the benchmark collection problem with
49+ the given name.
50+
51+ Parameters
52+ ----------
53+ id_: Problem name, as in `benchmark_models_petab.MODELS`.
54+
55+ Returns
56+ -------
57+ The simulation dataframe if it exists, else None.
58+ """
59+ path = Path (MODELS_DIR , id_ , f"simulatedData_{ id_ } .tsv" )
60+ if path .is_file ():
61+ return petab .get_simulation_df (path )
62+ return None
Original file line number Diff line number Diff line change @@ -14,3 +14,8 @@ def test_get_problem():
1414 """Test whether extracting a petab problem works."""
1515 problem = models .get_problem (models .MODELS [0 ])
1616 assert problem .measurement_df is not None
17+
18+
19+ def test_get_simulation_df ():
20+ assert models .get_simulation_df ("Elowitz_Nature2000" ).empty is False
21+ assert models .get_simulation_df ("not a problem name" ) is None
You can’t perform that action at this time.
0 commit comments