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. A comparison of SBMLImporter.jl to SBMLToolkit.jl, listing the packages' differences, can be found towards the end of 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 the latest Julia version.

Tutorial

SBMLImporter import SBML models as 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 Langevin SDE simulations, 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 (prnbng) and a CallbackSet (cb). The ParsedReactionSystem includes the reaction system (prnbng.rn), a map for the initial condition values of each specie (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.

Jump simulations

To perform jump simulations (e.g. using Gillespie's algorithm), convert the reaction system (prnbng.rn) into a JumpProblem (which requires first creating an intermediary DiscreteProblem).

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 simulated 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 jump simulations, see JumpProcesses.jl's documentation.

Warn

For efficient jump 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 simulated 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 StochasticDiffEq.jl's documentation.

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 simulated 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 OrdinaryDiffEq.jl's documentation.

Citation

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