Skip to content

API

SBMLImporter.load_SBML Function
julia
load_SBML(path; massaction=false, kwargs...)

Import an SBML model into a ReactionNetwork that can be simulated as a JumpProblem for Gillespie simulations, a SDEProblem for chemical Langevin simulations, or an ODEProblem for deterministic simulations.

The keyword massaction should be set to true if the model reactions follow chemical mass action kinetics. This is because the most efficient JumpProblem (Gillespie) simulators require mass action jumps, for more details see here. For how to check if a model follows mass action kinetics, see the FAQ in the documentation.

Note

The massaction keyword argument is only relevant for jump simulations. If you import the model as a SDEProblem or an ODEProblem, you can (and should) ignore this keyword argument.

Keyword arguments

  • complete::Bool=true: Whether or not to mark the returned Catalyst ReactionSystem as complete. Only a complete system can be used for simulations, while only an incomplete system can be composed with other systems. For more details, see the Catalyst.jl documentation.

  • ifelse_to_callback::Bool=true: Rewrite ifelse (SBML piecewise) expressions to callbacks. This improves simulation runtime and stability. Strongly recomended to set to true.

  • inline_assignment_rules::Bool=false: Inline SBML assignment rules into model equations. Recommended for importing large models. However, if set to true, it is not possible to access assignment rule variables via sol[:var].

  • inline_kineticlaw_parameters::Bool=true: Inline (hardcode) SBML kinetic law parameter values into the model equations. Kinetic law parameters are parameters defined only in the kinetic law field of an SBML reaction. It is recommended to inline them as there might be duplicate IDs, e.g., the same kinetic law parameter redefined for different reactions. If they are not inlined, they are promoted to model parameters (with the same status as parameters in the SBML file).

  • write_to_file=false: Write the parsed SBML model to a Julia file in the same directory as the SBML file.

  • model_as_string::Bool=false: Whether the model (path) is provided as a string.

Returns

  • rn: A Catalyst reaction network/system that can be converted to a JumpProblem, SDEProblem, or ODEProblem. Initial values and parameter values can be accessed via Catalyst maps:

    • get_u0_map(rn) returns a map from species to initial values.

    • get_parameter_map(rn) returns a map from parameters to values.

  • cbset: A CallbackSet containing SBML events and callbacks generated from SBML piecewise expressions (when ifelse_to_callback=true).

source
SBMLImporter.getcompartment Function
julia
getcompartment(s)

For an SBML specie s, get its associated SBML compartment.

If s does not have a compartment, or is not a specie, nothing is returned.

Example

julia
# Get compartment for first model specie
using SBMLImporter, Catalyst
rn, cb = load_SBML(path_SBML)
sbml_species = species(rn)
c = getcompartment(sbml_species[1])
source