Home

Awesome

SBMLToolkit

Join the chat at https://julialang.zulipchat.com #sciml-bridged Global Docs

codecov Build Status

ColPrac: Contributor's Guide on Collaborative Practices for Community Packages SciML Code Style

SBMLToolkit.jl is a lightweight tool to import models specified in the Systems Biology Markup Language (SBML) into the Julia SciML ecosystem. There are multiple ways to specify the same model in SBML. Please help us improving SBMLToolkit.jl by creating a GitHub issue if you experience errors when converting your SBML model.

SBMLToolkit uses the SBML.jl wrapper of the libSBML library to lower dynamical SBML models into completed dynamical systems. If you would like to import BioNetGen models use the writeSBML() export function or import the .net file with ReactionNetworkImporters.jl. For constrained-based modeling, please have a look at COBREXA.jl. We also recommend trying SBMLImporter.jl. While SBMLToolkit.jl has a slightly cleaner interface, SBMLImporter.jl respects directionality of events, can output concentrations or amounts, and provides better simulation performance for models including time-triggered events and SBML piecewise expressions.

Installation

To install SBMLToolkit.jl, use the Julia package manager:

using Pkg
Pkg.add("SBMLToolkit")

Tutorial

SBML models can be simulated with the following steps (note that sol is in absolute quantities rather than concentrations):

using SBMLToolkit, OrdinaryDiffEq

odesys = readSBML("my_model.xml", ODESystemImporter())

tspan = (0.0, 1.0)
prob = ODEProblem(odesys, [], tspan, [])
sol = solve(prob, Tsit5())

While this imports an ODESystem directly, you can also import a Catalyst.jl ReactionSystem:

using SBMLToolkit

rs = readSBML("my_model.xml", ReactionSystemImporter())

One common case where this is useful is if you want to run stochastic instead of ODE simulations.

In the very unlikely case that you need fine-grained control over the SBML import, you can create an SBML.jl Model (we strongly recommend manually running checksupport_file("my_model.xml") before)

using SBML

mdl = readSBML("my_model.xml", doc -> begin
    set_level_and_version(3, 2)(doc)
    convert_promotelocals_expandfuns(doc)
end)

The conversion to SBML level 3 version 2 is necessary, because older versions are not well supported in SBMLToolkit. convert_promotelocals_expandfuns basically flattens the SBML before the import. Once you have obtained the Model, you can convert it to a ReactionSystem and ODESystem.

using SBMLToolkit

rs = ReactionSystem(mdl)
odesys = convert(ODESystem, rs)

License

The package is released under the MIT license.

Questions and comments

Please use GitHub issues and the #sciml-sysbio channel in the Julia Slack workspace with any questions or comments.

Citation

If you use SBMLToolkit.jl in your research, please cite this paper:

@article{lang_sbmltoolkitjl_2024,
	title = {{SBMLToolkit}.jl: a {Julia} package for importing {SBML} into the {SciML} ecosystem},
	doi = {10.1515/jib-2024-0003},
	journal = {Journal of Integrative Bioinformatics},
	author = {Lang, Paul F. and Jain, Anand and Rackauckas, Christopher},
	year = {2024},
}