Skip to content

testsuite.cases

The semantic cases of the SBML Test Suite on disk.

A case is a directory cases/semantic/NNNNN/ with the model in several encodings, NNNNN-settings.txt with the simulation and the tolerances, NNNNN-results.csv with the expected results and NNNNN-model.m with the description and the tags. SemanticCase reads the two metadata files, and SemanticSuite is a directory of cases, downloaded from a release of the suite and cached.

SemanticCase dataclass

SemanticCase(
    cid,
    path,
    model_path,
    start,
    duration,
    steps,
    variables,
    amount,
    concentration,
    absolute_tolerance,
    relative_tolerance,
    component_tags=frozenset(),
    test_tags=frozenset(),
    test_type="",
    generated_by="",
    packages=frozenset(),
)

A semantic case of the SBML Test Suite.

Attributes:

Name Type Description
cid str

identifier of the case, i.e. its directory name such as 00028.

path Path

directory of the case.

model_path Path

the model which is simulated, the newest encoding present.

start float

start time of the simulation.

duration float

end time of the simulation.

steps int

number of steps, so the results have steps + 1 points.

variables list[str]

the columns the results are compared on, without time.

amount list[str]

the variables which are compared as an amount.

concentration list[str]

the variables which are compared as a concentration.

absolute_tolerance float

absolute tolerance of the comparison.

relative_tolerance float

relative tolerance of the comparison.

component_tags frozenset[str]

SBML components the case uses, e.g. EventWithDelay.

test_tags frozenset[str]

what the case tests, e.g. NonConstantParameter.

test_type str

kind of the case, TimeCourse for the cases which are run.

generated_by str

Analytic or Numeric, how the results were produced.

packages frozenset[str]

SBML packages the case needs, e.g. fbc.

encoding property

encoding

Get the SBML encoding which is simulated, e.g. l3v2.

selections property

selections

Get the roadrunner selections of the compared variables.

A variable of the concentration list is the concentration of a species, i.e. [S1], everything else is read under its own identifier. time is always selected first.

settings staticmethod

settings(path)

Read the settings file of a case.

Parameters:

Name Type Description Default
path Path

NNNNN-settings.txt of the case.

required

Returns:

Type Description
dict[str, str]

The keys of the file with their raw values, values may be empty.

tags staticmethod

tags(path)

Read the tags of the description of a case.

The description is prose with a header of key: value lines; only the single line keys of the header are read, i.e. not the synopsis.

Parameters:

Name Type Description Default
path Path

NNNNN-model.m of the case.

required

Returns:

Type Description
dict[str, str]

The tag keys with their raw values.

from_directory classmethod

from_directory(path)

Read a case from its directory.

A case which is not a timecourse simulation is not read: the flux balance cases have no duration and the stochastic cases are not part of the semantic suite.

Parameters:

Name Type Description Default
path Path

directory of the case, named after its identifier.

required

Returns:

Type Description
SemanticCase | None

The case, or None if it is not a timecourse case or has no

SemanticCase | None

model in a known encoding.

model_of staticmethod

model_of(path, cid)

Get the model of a case in the newest encoding it provides.

Parameters:

Name Type Description Default
path Path

directory of the case.

required
cid str

identifier of the case.

required

Returns:

Type Description
Path | None

The SBML file, or None if the case has none.

expected

expected()

Read the results a correct simulator produces.

The time column is time in most cases and Time in others, so it is renamed; the columns of the variables are named as the settings name them.

Returns:

Type Description
DataFrame

The expected results with a time column and one column per

DataFrame

variable of the case.

SemanticSuite dataclass

SemanticSuite(path, version)

The semantic cases of a release of the SBML Test Suite.

Attributes:

Name Type Description
path Path

directory which holds the case directories.

version str

release of the suite, e.g. 3.5.0.

cases

cases()

Iterate the timecourse cases of the suite, by identifier.

Yields:

Type Description
SemanticCase

Every case which is a timecourse simulation, in the order of the

SemanticCase

case identifiers.

case

case(cid)

Get a single case by its identifier.

Parameters:

Name Type Description Default
cid str

identifier of the case, e.g. 00028.

required

Returns:

Type Description
SemanticCase

The case.

Raises:

Type Description
ValueError

if the suite has no such timecourse case.

cache_path staticmethod

cache_path(version)

Get the directory a release of the suite is unpacked into.

SBMLSIM_TEST_SUITE_PATH overrides it, e.g. for an offline machine which has the cases somewhere else. Otherwise it is the user cache, i.e. XDG_CACHE_HOME or ~/.cache.

Parameters:

Name Type Description Default
version str

release of the suite.

required

Returns:

Type Description
Path

The directory the cases of the release live in.

latest_version classmethod

latest_version()

Get the newest release of the suite from GitHub.

Returns:

Type Description
str

The tag of the newest release, e.g. 3.5.0.

cached classmethod

cached(version=SUITE_VERSION)

Get a release of the suite if it is already on this machine.

Parameters:

Name Type Description Default
version str

release of the suite.

SUITE_VERSION

Returns:

Type Description
SemanticSuite | None

The suite, or None if it was not downloaded yet.

load classmethod

load(version=SUITE_VERSION)

Get a release of the suite, downloading it if it is not cached.

Parameters:

Name Type Description Default
version str

release of the suite.

SUITE_VERSION

Returns:

Type Description
SemanticSuite

The suite with its cases unpacked in the cache.

Raises:

Type Description
OSError

if the release cannot be downloaded.