Skip to content

testsuite.cases

The semantic test cases of the SBML test suite.

A case is a directory NNNNN with the model in several SBML levels and versions, NNNNN-settings.txt (simulation settings and tolerances), NNNNN-results.csv (expected timecourse) and NNNNN-model.m (tags and the test type). The suite is downloaded from its GitHub release into a cache on first use.

TestSuiteError

Bases: RuntimeError

The test suite cannot be obtained or a case cannot be read.

Settings dataclass

Settings(
    start,
    duration,
    steps,
    variables,
    absolute,
    relative,
    amount,
    concentration,
)

Simulation settings of a case (NNNNN-settings.txt).

end property

end

End time of the simulation.

Case dataclass

Case(
    id,
    case_dir,
    sbml_path,
    settings,
    expected,
    test_tags,
    component_tags,
    test_type,
    name="",
)

One semantic test case.

expected is None for a case without expected results (e.g. a model from a model repository): the roadrunner simulation of the original model becomes the expected results for the later stages. name is a display name (e.g. the model name), empty for the SBML test suite cases.

packages property

packages

SBML packages the case uses, from the component tags.

cache_dir

cache_dir()

Root of the cache, SBML2CELLML_CACHE or ~/.cache/sbml2cellml.

ensure_suite

ensure_suite(version=SUITE_VERSION, cache=None)

Directory of the semantic cases, downloaded and unpacked on first use.

Parameters:

Name Type Description Default
version str

release of the test suite.

SUITE_VERSION
cache Path | None

cache root, cache_dir() by default.

None

Returns:

Type Description
Path

The semantic/ directory with one subdirectory per case.

Raises:

Type Description
TestSuiteError

if the download fails or the archive has not the expected layout.

parse_settings

parse_settings(text)

Parse a settings file.

Cases of a test type other than TimeCourse (e.g. FluxBalanceSteadyState) leave start, duration and steps empty; they parse to 0 and are never used because skip_reason filters them out before a run.

Parameters:

Name Type Description Default
text str

content of NNNNN-settings.txt.

required

Returns:

Type Description
Settings

The settings.

Raises:

Type Description
TestSuiteError

if start, duration or steps is missing.

parse_model_info

parse_model_info(text)

Parse the key: values lines of a NNNNN-model.m file.

A model file opens with a comment marker on its own line, a blank line, the header block of key: value pairs, a blank line and then the prose description (a few files carry an extra "Previous version of this file:" comment line before the marker, or wrap a value like synopsis onto its own blank-line-separated continuation). Only the header block is parsed: the paragraphs (blocks separated by a blank line) up to and including the first genuine key: value paragraph, plus at most one further blank-line gap, so a wrapped value does not cut the header short but prose describing the model later in the file (typically several paragraphs further, e.g. a "Note:" line) is not mistaken for more of it.

Parameters:

Name Type Description Default
text str

content of the file.

required

Returns:

Type Description
dict[str, list[str]]

The values per key, e.g. testTags, componentTags, testType.

load_case

load_case(case_dir)

Read a case directory.

Parameters:

Name Type Description Default
case_dir Path

directory NNNNN.

required

Returns:

Type Description
Case

The case; sbml_path is None when there is no L3V2 file.

Raises:

Type Description
TestSuiteError

if the settings, results or model file is missing.

skip_reason

skip_reason(case)

Why a case is not run, None if it is runnable.

load_cases

load_cases(root, ids=None)

Read the cases of a suite directory.

Parameters:

Name Type Description Default
root Path

the semantic/ directory.

required
ids list[str] | None

case ids to read, all when None.

None

Returns:

Type Description
list[Case]

The cases sorted by id.