petab_v2.testsuite
The cases of the PEtab test suite on disk.
The test suite has a group of
cases per model format and the cases of the math of PEtab, below
petabtests/cases/v2.0.0, and the cases of PEtab v1 below
petabtests/cases/v1.0.0. sbmlsim reads PEtab v2 only, a case of PEtab v1
is converted to PEtab v2 with its simulations once, see
sbmlsim.fit.petab_v2.conversion, and run as a case of PEtab v2:
| group | case | compared |
|---|---|---|
sbml |
PetabCase |
log-likelihood, chi2, simulations, log prior, log posterior |
v1/sbml |
PetabCase |
the same, of the case of PEtab v1 converted to PEtab v2 |
math |
MathCase |
the value of an expression of math_tests.yaml |
A case of a model is a directory named by its number with the problem
_<id>.yaml, the solution _<id>_solution.yaml and the simulations it
names. It is read with PetabReader, simulated at the nominal values of its
parameter table (PetabReader.nominal_parameters) and compared with the
tolerances of its solution. A math case compiles its expression with
sbmlsim.simulator.formula.compile_formula, which is what the formulas of
conditions, observables and noise are evaluated with. The cases of PySB
models (pysb) are not run, sbmlsim simulates SBML.
The suite has no releases, so it is pinned by a commit. PetabSuite is the
directory of the cases of both versions with the download, the conversion
and the cache of the commit.
CaseStatus
¶
Bases: StrEnum
The outcome of a case.
CaseResult
dataclass
¶
PetabCase
dataclass
¶
A case of a model of the PEtab v2 test suite.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
Path
|
the directory of the case. |
cid |
str
|
the number of the case, the name of its directory. |
group |
str
|
the group of the case, the format of its model. |
problem_file |
Path
|
the YAML file of the problem. |
solution |
dict[str, Any]
|
the content of the solution. |
from_directory
classmethod
¶
Read a case from its directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
the directory of the case. |
required |
group
|
str
|
the group of the case. |
SBML
|
Returns:
| Type | Description |
|---|---|
PetabCase
|
The case. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the directory has no problem or no solution, or is a case of PEtab v1 which could not be converted. |
run
¶
Run the case.
Returns:
| Type | Description |
|---|---|
CaseResult
|
The outcome, |
MathCase
dataclass
¶
A case of the math of PEtab.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
int
|
the position of the case in |
expression |
str
|
the math expression. |
expected |
float | str
|
its value, a number or a symbolic expression. |
run
¶
Compile the expression and compare its value.
A symbolic expression is evaluated with both at values of its symbols.
Returns:
| Type | Description |
|---|---|
CaseResult
|
The outcome, |
PetabSuite
dataclass
¶
The cases of a commit of the PEtab test suite.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
Path
|
the directory of the cases of the suite, i.e.
|
commit |
str
|
the commit of the suite. |
cache_path
staticmethod
¶
Get the directory a commit of the suite is unpacked into.
SBMLSIM_PETAB_SUITE_PATH overrides it. Otherwise it is
sbmlsim/petab-test-suite/<commit> in the user cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commit
|
str
|
the commit of the suite. |
PETAB_SUITE_COMMIT
|
Returns:
| Type | Description |
|---|---|
Path
|
The directory the cases of the commit live in. |
cached
classmethod
¶
Get a commit of the suite if it is already on this machine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commit
|
str
|
the commit of the suite. |
PETAB_SUITE_COMMIT
|
Returns:
| Type | Description |
|---|---|
PetabSuite | None
|
The suite, or |
load
classmethod
¶
Get a commit of the suite, downloading and converting it once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commit
|
str
|
the commit of the suite. |
PETAB_SUITE_COMMIT
|
Returns:
| Type | Description |
|---|---|
PetabSuite
|
The suite with its cases unpacked in the cache and the cases of |
PetabSuite
|
PEtab v1 converted to PEtab v2. |
Raises:
| Type | Description |
|---|---|
OSError
|
if the commit cannot be downloaded. |
convert
¶
Convert the cases of PEtab v1 which are not converted yet.
A case is converted with its simulations into the directory of the
group v1/sbml, its solution names the converted simulations. A case
which cannot be converted gets the file CONVERSION_ERROR with the
reason instead of its problem, which PetabCase.run reports.
case_ids
¶
Get the numbers of the cases of a group of models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
str
|
the group, see |
SBML
|
Returns:
| Type | Description |
|---|---|
list[str]
|
The names of the case directories, sorted, empty for a group the |
list[str]
|
suite does not have. |
run_case
¶
Run a case of a group of models, error for one which cannot be read.
run
¶
Run the cases of the suite.
Returns:
| Type | Description |
|---|---|
list[CaseResult]
|
The results of the groups |
list[CaseResult]
|
cases, in this order. |