The BioSimulators conventions for command-line applications and Python APIs for biosimulation tools are sets of requirements for the syntax and semantics of the inputs and outputs of biosimulation software tools. The conventions ensure that simulation tools can be consistently executed with the same input arguments (a path to a COMBINE/OMEX archive that defines models and simulations and a path to save the outputs of the simulation experiments defined in the archive) and that the simulation tools produce consistent outputs (reports and plots at consistent paths in consistent formats).
BioSimulators encourages developers to provide two interfaces for two purposes:
In most cases, we recommend that developers create BioSimulators-compliant interfaces in three steps:
biosimulators_utils.simulator.cli.build_cli to
construct a command-line application from their Python API.
For validation, simulation tools MUST provide Docker images whose entrypoints are BioSimulators-compliant command-line applications. Simulation tools are also OPTIONALLY encouraged to provide BioSimulators-compliant APIs.
Simulation tools should support the following command-line arguments:
-i, --archive: A path to a COMBINE/OMEX archive
which contains descriptions of one or more simulation tasks.
-o, --out-dir: The path where the outputs (reports
and plots) of the simulation tasks should be saved.
-h, --help: An optional argument that instructs
the command-line application to print help information about itself.
-v, --version: An optional argument that instructs
the command-line application to report its version and the versions of
any critical dependencies.
As an example, below is the documentation for the command-line
application for the tellurium
usage: tellurium [-h] [-d] [-q] -i ARCHIVE [-o OUT_DIR] [-v]
BioSimulators-compliant command-line interface to the tellurium simulation program <http://tellurium.analogmachine.org>.
optional arguments:
-h, --help show this help message and exit
-d, --debug full application debug mode
-q, --quiet suppress all console output
-i ARCHIVE, --archive ARCHIVE
Path to a COMBINE/OMEX archive file which contains one or more SED-ML-
encoded simulation experiments
-o OUT_DIR, --out-dir OUT_DIR
Directory to save outputs
-v, --version show program's version number and exit
Python APIs should be Python modules which provide the following attributes and methods:
__version__ (str): Version of the API
(e.g., 0.1.0).
get_simulator_version (() -> str):
Get the version of the underyling simulation tool (e.g.,
1.0.0).
preprocess_sed_task ((task: Task, variables: list[Variable]) -> Any): Preprocess the information required to execute a SED-ML task. This
method enables users to efficiently execute multiple simulation steps
(using exec_sed_task) without unnecessary duplicate
computations, such as to import models from files, validate models,
and identify suitable algorithms.
exec_sed_task ((task: Task, variables: list[Variable], preprocessed_task:Any=None)
-> Tuple[VariableResults, TaskLog]): Execute a single SED-ML task involving a single simulation of a
single model and return the predicted value of each requested output
variable and a log of the execution of the simulation.
exec_sed_doc ((doc: SedDocument, variables: list[Variable]) ->
Tuple[ReportResults, SedDocumentLog]): Execute a single SED-ML document involving one or more simulations
of one or more models and return data for each SED-ML report and plot
and a log of the execution of the simulations, reports, and plots.
exec_sedml_docs_in_combine_archive ((archive_filename: str, out_dir: str, return_results: bool = False)
-> Tuple[SedDocumentResults, CombineArchiveLog]): Execute all of the tasks in all of the SED-ML files in a
COMBINE/OMEX archive, export all of the requested reports and plots,
optionally return the result of each output, and return a log of the
execution of the archive.
More information about the required method signatures is available in
the simulator template
Both command-line interfaces and Python APIs should also support the following conventions:
sedml:model,
sedml:changeAttribute
sedml:steadyState, sedml:oneStep, or
sedml:uniformTimeCourse.
sedml:task.
sedml:algorithm,
sedml:algorithmParameter.
sedml:dataGenerator
sedml:report..pdf
{{ '{ ' }} out-dir {{ ' }' }}/reports.h5. Plots should be
saved to {{ '{ ' }} out-dir {{ ' }' }}/plots.zip.
To further support consistent execution of simulations with other
simulation tools, command-line interfaces and Python APIs are also
encouraged to implement the following environment variables. The
Dockerfiles for simulation tools should use the
ENV directive to indicate the variables they support and
their default values.
ALGORITHM_SUBSTITUTION_POLICY: This environment variable enables users to control if and how the
simulator substitutes algorithms with other
mathematically-equivalent or similar algorithms.
BioSimulators recognizes the increasing levels of substitution
listed below. Simulation tools are encouraged to use
SIMILAR_VARIABLES as the default value for
ALGORITHM_SUBSTITUTION_POLICY.
A recommended matrix of algorithm substitutions is available from
the KiSAO ontology
When alternate algorithms are substituted, BioSimulators recommends that simulation tools ignore SED algorithm parameters as algorithm parameters can have different meanings in the context of different algorithms.
For algorithm substitution level NONE, BioSimulators
recommends that simulation tools raise errors for unsupported
algorithm parameters and unsupported values of algorithm parameters.
For higher substitution levels, BioSimulators recommends that
simulation tools skip unsupported parameters and unsupported values
and raise warnings when parameters are skipped.
NONE: Tools should strictly interpret SED-ML
simulations, and raise errors on the execution of SED-ML files
that involve unsupported algorithms. For example, a simulation
tool that only supports the Stochastic Simulation Algorithm (SSA,
KISAO_0000029) should raise errors on SED-ML files that request
simulations with the Next Reaction Method (NRM, KISAO_0000027). In
many cases, this level will effectively constrain the execution of
a SED-ML document to a specific implementation of an algorithm by
a specific simulation tool.
SAME_METHOD: Algorithms can be substituted with
different realizations of the same method. For example, GLPK's
implementation of the Simplex method could be substituted with
SciPy's implementation.
SAME_MATH: Tools should execute simulations with
alternative mathematically-equivalent algorithms, and raise errors
on the execution of SED-ML files which request algorithms that are
mathematically distinct from those implemented by the tool. When
tools execute alternative mathematically-equivalent algorithms,
they should issue warnings to this effect. For example, a
simulation tool that only supports SSA should execute simulations
that request NRM with a warning, and raise an error on SED-ML
files that request the tau-leaping method (KISAO_0000039).
SIMILAR_APPROXIMATIONS: Algorithms can be substituted
with others that make similar approximations to the same
mathematics. For example, CVODE could be substituted with LSODA or
the Fehlberg method. Tau leaping could be substituted with
partitioned tau leaping.
DISTINCT_APPROXIMATIONS: Algorithms can be
substituted with others that make distinct approximations to the
same math. For example, SSA could be substituted with tau leaping
or the Pahle hybrid method.
DISTINCT_SCALES: Algorithms can be substituted with
others that make distinct approximations to the same math that
substantially differ in their scales. For example, SSA could be
substituted with CVODE.
SAME_VARIABLES: Algorithms that predict the same
output variables can be substituted. For example, FBA could be
substituted with parsimonious FBA.
SIMILAR_VARIABLES (recommended default): Algorithms
that predict similar output variables can be substituted. For
example, FBA could be substituted with geometric FBA.
SAME_FRAMEWORK: Tools should execute simulations with
alternative algorithms, including algorithms that are not
mathematically equivalent, and issue warnings when alternative
algorithms are executed.
ANY: Tools can execute simulations with any
alternative algorithm. Note, switching to any other algorithm can
substantially change the interpretation of a simulation (e.g.,
switching SSA to CVODE loses all information about the variance of
a simulation).
VERBOSE: Indicates whether a simulator should display detailed information
about the execution of each task.
BioSimulators recognizes the following values.
0, false (any case)1, true (any case)To ensure consistent execution of simulation experiments, command-line applications and Python APIs should adopt the conventions described below for the execution of COMBINE/OMEX archives.
omex:content whose
format attribute starts with
http://identifiers.org/combine.specifications/sed-ml.
omex:content[@master='true']). When a COMBINE/OMEX
archive contains a single master file, simulation tools should only
execute this file. Note, if the master file is not a SED-ML document,
then no simualtions should be executed. When a COMBINE/OMEX archive
doesn't have a master file, all SED-ML documents should be executed.
To ensure consistent execution of simulation experiments, command-line applications and Python APIs should adopt the conventions described below for the execution of SED-ML files.
Substitution of alternative simulation algorithms.
Because no simulation tool implements every simulation algorithm,
simulation tools are encouraged to execute SED-ML simulations with
alternative algorithms (close KiSAO terms) when the tool does not
support the requested algorithm
(sedml:algorithm/@kisaoID). For example, a tool which
only implements the Stochastic Simulation Algorithm (SSA,
KISAO_0000029) could choose to execute simulations that request the
Next Reaction Method (NRM, KISAO_0000027), a
mathematically-equivalent method, with SSA.
Simulation tools are encouraged to use the KiSAO ontology to systematically identify related simulation algorithms.
When a tool uses an alternative algorithm, the tool should issue a warning message to the user that indicates that an alternative algorithm was used.
Tools which choose to execute alternative algorithms should support
the ALGORITHM_SUBSTITUTION_POLICY environment variable
(see above).
Below are helpful tools for implementing command-line applications and Python APIs to the above specifications: