SBMLImporter.jl

SBMLImporter.jl is an importer for dynamic models defined in the Systems Biology Markup Language (SBML). It supports most SBML features, such as events, dynamic compartment sizes, and rate, assignment, and algebraic rules. For a complete list of supported features see here. For differences compared to SBMLToolkit.jl see the README.

To perform parameter estimation for a SBML model, see PEtab.jl.

Installation

To install SBMLImporter.jl in the Julia REPL enter

julia> ] add SBMLImporter

or alternatively

julia> using Pkg; Pkg.add("SBMLImporter")

SBMLImporter.jl is compatible with Julia version 1.6 and above. For best performance we strongly recommend using Julia version 1.10.

Tutorial

SBMLImporter import SBML models into a Catalyst ReactionSystem. This provides several benefits, such as symbolic model pre-processing for efficient simulations. The imported ReactionSystem can be converted to a JumpProblem for Gillespie simulations, a SDEProblem for simulations based on the Langevin SDE, or an ODEProblem for deterministic ODE simulations

As example, consider the Brusselator model (the SBML file can be downloaded from here). The first step is to import the model with load_SBML:

using SBMLImporter
prnbng, cb = load_SBML(path_SBML)

This returns two outputs a ParsedReactionSystem (rprnbng) and a CallbackSet (cb). The ParsedReactionSystem includes the reaction system (prnbng.rn), a map for the initial values of each species (prnbng.u₀), and a map setting the model parameter values (prnbng.p). The CallbackSet holds any potential SBML events, along with SBML piecewise functions that have been parsed into events.

Gillespie simulations

To perform Gillespie simulations, convert the reaction-system prnbng.rn into a JumpProblem.

using JumpProcesses
tspan = (0.0, 10.0)
dprob = DiscreteProblem(prnbng.rn, prnbng.u₀, tspan, prnbng.p)
jprob = JumpProblem(prnbng.rn, dprob, Direct())

The JumpProblem can be solved with any solver from the JumpProcesses.jl package, such as the SSAStepper:

using Plots
sol = solve(jprob, SSAStepper(), callback=cb)
plot(sol; lw=2)
Example block output

For more information on Gillespie simulations, see the documentation for JumpProcesses.jl.

Warn

For efficient Gillespie simulations two conditions must be met: the model should be a mass-action model and each species should have units amount. This translates to ensuring that every species has the attribute hasOnlySubstanceUnits=true, and no rule variables are used in the kinetic math expressions for the SBML reactions.

SDE simulations

To perform SDE simulations, convert the reaction-system prnbng.rn into a SDEProblem.

using StochasticDiffEq
tspan = (0.0, 10.0)
sprob = SDEProblem(prnbng.rn, prnbng.u₀, tspan, prnbng.p)

The SDEProblem can be solved with any solver from the StochasticDiffEq.jl package, such as the LambaEM solver:

sol = solve(sprob, LambaEM(), callback=cb)
plot(sol; lw=2)
Example block output

For more information on SDE simulations, see the documentation for StochasticDiffEq.jl.

ODE simulations

To perform ODE simulations, convert the reaction-system prnbng.rn into an ODEProblem.

using ModelingToolkit, OrdinaryDiffEq
tspan = (0.0, 10.0)
sys = convert(ODESystem, prnbng.rn)
oprob = ODEProblem(sys, prnbng.u₀, tspan, prnbng.p, jac=true)

Here jac=true means that the ODE Jacobian is computed symbolically which can help with simulation performance. The ODEProblem can be solved with any solver from the OrdinaryDiffEq.jl package, such as the Rodas5 solver:

sol = solve(oprob, Rodas5(), callback=cb)
plot(sol; lw=2)
Example block output

For more information on ODE simulations, see the documentation for OrdinaryDiffEq.jl.

Citation

We will soon publish a paper you can cite if you found SBMLImporter.jl helpful in your work.