Package {r2sbml}


Type: Package
Title: Read 'SBML' Models and Convert Them to Simulation Code
Version: 0.3.0
Description: Reads models in the Systems Biology Markup Language ('SBML') (Hucka et al. (2003) <doi:10.1093/bioinformatics/btg015>) through the bundled 'libSBML' library (Bornstein et al. (2008) <doi:10.1093/bioinformatics/btn051>). Lists a model's species, parameters, compartments, reactions, rules, events and function definitions, and converts the model into ready-to-run simulation code for 'deSolve', 'mrgsolve', 'rxode2', 'MATLAB', 'Julia' or 'ubiquity'. Parameter values, compartment sizes and species initial values can be edited, and the model written back to an 'SBML' file.
URL: https://sn248.github.io/r2sbml/, https://github.com/sn248/r2sbml
BugReports: https://github.com/sn248/r2sbml/issues
Encoding: UTF-8
Language: en-GB
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
Copyright: See file inst/COPYRIGHTS
Imports: Rcpp (≥ 0.12.6)
Suggests: deSolve, knitr, mrgsolve, rmarkdown, rxode2, sundialr, testthat (≥ 3.0.0), ubiquity
VignetteBuilder: knitr
LinkingTo: Rcpp
Biarch: TRUE
SystemRequirements: cmake, libxml2
Config/roxygen2/version: 8.1.1
NeedsCompilation: yes
Packaged: 2026-11-29 01:23:51 UTC; quantilogy
Author: Satyaprakash Nayak [aut, cre, cph], Sarah M. Keating [ctb] (Author of 'libSBML' and of the example code adapted in src/convertReactions.cpp and src/getMath.cpp), Frank T. Bergmann [ctb] (Author of 'libSBML' and of the example code adapted in src/convertReactions.cpp and src/getMath.cpp), Lucian P. Smith [ctb] (Author of 'libSBML'), Brett G. Olivier [ctb] (Author of 'libSBML'), Akiya Jouraku [ctb] (Author of 'libSBML'), Michael Hucka [ctb] (Author of 'libSBML'), Ben Bornstein [ctb] (Author of 'libSBML'), Jeroen Ooms [ctb] (Windows build support), California Institute of Technology [cph] (Copyright holder of 'libSBML', 2002-2020), EMBL European Bioinformatics Institute [cph] (Copyright holder of 'libSBML', 2009-2018), University of Heidelberg [cph] (Copyright holder of 'libSBML', 2013-2020), University College London [cph] (Copyright holder of 'libSBML', 2020), Japan Science and Technology Agency [cph] (Copyright holder of 'libSBML', 2002-2005), Gilles Vollant [cph] (Author of MiniZip, bundled with 'libSBML'), Mathias Svensson [cph] (Contributor to MiniZip, bundled with 'libSBML'), Even Rouault [cph] (Contributor to MiniZip, bundled with 'libSBML'), Nathan Moinvaziri [cph] (Contributor to MiniZip, bundled with 'libSBML'), Terry Thorsen [cph] (Contributor to MiniZip, bundled with 'libSBML'), Info-ZIP [cph] (Copyright holder of encryption code in MiniZip, bundled with 'libSBML'), Ludwig Schwardt [cph] (Author of the zlib iostream wrappers bundled with 'libSBML'), Kevin Ruland [cph] (Author of the zlib iostream wrappers bundled with 'libSBML'), M. Petra Baranski [cph] (Author of 'maddy', bundled with 'libSBML'), Tim Gromeyer [cph] (Author of 'html2md', bundled with 'libSBML')
Maintainer: Satyaprakash Nayak <satyaprakash.nayak@gmail.com>
Repository: CRAN
Date/Publication: 2026-11-29 03:50:02 UTC

Add a component to a model

Description

Add a parameter, compartment or species to a loaded model, in place. The new component needs an id that is a valid SBML id and not already used in the model.

Usage

addParameter(input_model, id, value = NULL, constant = TRUE)

addCompartment(
  input_model,
  id,
  size = NULL,
  spatialDimensions = 3,
  constant = TRUE
)

addSpecies(
  input_model,
  id,
  compartment,
  initial = NULL,
  as = "amount",
  hasOnlySubstanceUnits = FALSE,
  boundaryCondition = FALSE,
  constant = FALSE
)

Arguments

input_model

a model pointer from getModel()

id

the id of the new component

value

a parameter's value; NULL (the default) or NA leaves it unset

constant

whether the component is constant (species default FALSE, parameter and compartment default TRUE)

size

a compartment's size; NULL or NA leaves it unset

spatialDimensions

a compartment's spatial dimensions (default 3)

compartment

the id of the compartment a new species lives in

initial

a species' initial value; NULL or NA leaves it unset

as

whether a species' initial is an "amount" or a "concentration"

hasOnlySubstanceUnits

whether the species is measured as an amount

boundaryCondition

whether the species is a boundary species

Details

As with the setters the model changes in place; use copyModel() first to keep the original, and see editModel. A new species names the compartment it lives in, which must already exist. writeSBML() runs the full consistency checks, so a model an edit leaves inconsistent is reported there.

Value

the model pointer, invisibly, so calls can be chained

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)
addParameter(model, "kdeg", 0.1)
addCompartment(model, "cell", 1)
addSpecies(model, "P2", "comp", 0, as = "concentration")
getParameterTable(model)

Add a reaction

Description

Add a reaction to a loaded model, in place, with its reactants, products, modifiers and (optionally) a rate law.

Usage

addReaction(
  input_model,
  id,
  reactants = NULL,
  products = NULL,
  modifiers = NULL,
  rateLaw = NULL,
  reversible = FALSE
)

Arguments

input_model

a model pointer from getModel()

id

the id of the new reaction

reactants

a named numeric vector of reactant stoichiometries, or NULL

products

a named numeric vector of product stoichiometries, or NULL

modifiers

a character vector of modifier species ids, or NULL

rateLaw

the rate law, a single string; NULL adds no kinetic law

reversible

whether the reaction is reversible (default FALSE)

Details

reactants and products are named numeric vectors mapping a species id to its stoichiometry, e.g. c(E = 1, S = 1); modifiers is a character vector of species ids. Every species named must already be in the model (add it first with addSpecies()). rateLaw is an infix formula in the same Level 3 syntax setRateLaw() takes, over the model's compartments, species, parameters and reactions; local parameters are not added here, so name global parameters (add them with addParameter()). Anything unresolved, or an unknown species, is an error and the model is left unchanged.

Value

the model pointer, invisibly, so calls can be chained

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)
addParameter(model, "kdeg", 0.1)
addReaction(model, "deg", reactants = c(P = 1), rateLaw = "comp * kdeg * P")
getReactionTable(model)
getReactionStoichiometry(model)

Add a rule

Description

Add an assignment rule (the variable equals the formula at all times) or a rate rule (the formula is the variable's time derivative) to a loaded model, in place.

Usage

addAssignmentRule(input_model, variable, formula)

addRateRule(input_model, variable, formula)

Arguments

input_model

a model pointer from getModel()

variable

the id the rule sets

formula

the rule's math, a single string

Details

variable must be a non-constant species, compartment, parameter or species reference the model already has, and not already set by another rule. The formula is an infix formula in the same Level 3 syntax setRateLaw() takes; an unresolved name is an error and the model is left unchanged. To start from a fresh parameter, add it with addParameter(model, id, constant = FALSE) first.

Value

the model pointer, invisibly, so calls can be chained

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)
addParameter(model, "Etot", constant = FALSE)
addAssignmentRule(model, "Etot", "E + ES")
getRuleMath(model)

Convert an SBML model to simulation code

Description

Writes the model's mass balances, rules and parameters as code for the chosen simulation tool, ready to simulate.

Usage

convertReactions(infile, outfile, format = "R")

Arguments

infile

input SBML file name, or a model from getModel()

outfile

output file name

format

output code format, one of 'R'/'deSolve' (default), 'mrgsolve', 'nlmixr2' (or 'rxode2'), 'MATLAB', 'Julia', 'ubiquity', 'R-reactions' (/'deSolve-reactions') or 'cvode' (/'sundialr'). An unrecognised format is an error.

'cvode' writes the same model as 'R' for the 'sundialr' package: an ODE model is solved with cvode() and an algebraic-rule (DAE) model with ida(). The right-hand side is identical to the 'R' output; only the calling convention differs (sundialr passes unnamed vectors and the function returns the derivative, or residual, vector rather than a list), so assignment-rule variables are computed but not returned in the solution.

'R-reactions' writes the same deSolve model as 'R', but with the reactions kept as data: r2sbml_reactions lists each reaction's equation and rate law (as an unevaluated expression), r2sbml_S is the stoichiometry matrix, and massBalances() assembles the right-hand side from them, so a reader can rebuild it after editing a rate or a parameter. It integrates to the same trajectory as 'R'. Algebraic-rule (DAE) models, rule-set stoichiometries and a reaction id used as a rate in other math are not supported in this format; use 'R' for those.

Details

The first argument is either the path to an SBML file or a model already read with getModel(). Passing a loaded model converts a copy of it, so the model you keep in R is left unchanged – an edited model can be converted directly, with no round-trip through a temporary file.

Value

NULL invisibly

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
out_file <- tempfile(fileext = ".R")
convertReactions(sbml_file, out_file, format = "R")
out_file_mrg <- tempfile(fileext = ".cpp")
convertReactions(sbml_file, out_file_mrg, format = "mrgsolve")
out_file_rx <- tempfile(fileext = ".R")
convertReactions(sbml_file, out_file_rx, format = "nlmixr2")
out_file_m <- tempfile(fileext = ".m")
convertReactions(sbml_file, out_file_m, format = "MATLAB")
out_file_jl <- tempfile(fileext = ".jl")
convertReactions(sbml_file, out_file_jl, format = "Julia")
out_file_ub <- tempfile(fileext = ".txt")
convertReactions(sbml_file, out_file_ub, format = "ubiquity")
out_file_cv <- tempfile(fileext = ".R")
convertReactions(sbml_file, out_file_cv, format = "cvode")
model <- getModel(sbml_file)
out_file_model <- tempfile(fileext = ".R")
convertReactions(model, out_file_model, format = "R")

Copy a model

Description

Edits made with setParameterValue(), setCompartmentSize() and setSpeciesIC() change a model in place, and every R variable that holds the same pointer sees them: model2 <- model copies the pointer, not the model. copyModel() makes an independent copy of the whole SBML document, so the two can be edited separately.

Usage

copyModel(input_model)

Arguments

input_model

a model pointer from getModel()

Value

an external pointer to the copy

Examples

sbml_file <- system.file("examples", "sbmlmutlicompartment.xml", package = "r2sbml")
model <- getModel(sbml_file)
edited <- copyModel(model)
setParameterValue(edited, "k1", 1000)
getParameterTable(model)$Value[1]
getParameterTable(edited)$Value[1]

Check an SBML file for errors

Description

Reads the file and prints the number of diagnostics libSBML reports, then the diagnostics themselves.

Usage

echoSBML(filename)

Arguments

filename

input file name

Value

the number of diagnostics, as an integer

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
echoSBML(sbml_file)

Edit a model's values

Description

Set the value of a parameter, the size of a compartment, or the initial value of a species, in place.

Usage

setParameterValue(input_model, id, value)

setCompartmentSize(input_model, id, value)

setSpeciesIC(input_model, id, value, as)

Arguments

input_model

a model pointer from getModel()

id

the id of the parameter, compartment or species

value

the new value, a single number; NA unsets it

as

for setSpeciesIC(), whether value is an "amount" or a "concentration"

Details

The model is changed in place, unlike an ordinary R object: every variable that holds the same pointer sees the edit. Use copyModel() first to keep the original. The query functions show the edit straight away, and convertReactions() and writeSBML() use it.

A species carries an initial amount or an initial concentration, never both, so setSpeciesIC() needs to be told which value is: it sets that attribute and unsets the other.

An unknown id is an error. When an initial assignment or an assignment rule sets the component, the new value is stored but has no effect, and a warning says so; a rate rule starts from the new value, so it does have one.

Value

the model pointer, invisibly, so calls can be chained

Examples

sbml_file <- system.file("examples", "sbmlmutlicompartment.xml", package = "r2sbml")
model <- getModel(sbml_file)
setParameterValue(model, "k1", 1000)
setCompartmentSize(model, "nucleus", 2)
setSpeciesIC(model, "X", 0.5, as = "concentration")
getParameterTable(model)
getSpeciesTable(model)

Names of the compartments in a model

Description

Returns the name where one is set and falls back to the id otherwise, the same rule getSpeciesNames() uses. Previously this returned the id unconditionally while getSpeciesNames() returned the name, so the two disagreed about what a "name" was. For a model whose compartments set no name – which is all ten of the bundled examples – the result is unchanged.

Usage

getCmtNames(input_model)

Arguments

input_model

input should be an SBML Model

Value

a character vector, one entry per compartment, in model order

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)
getCmtNames(model)

Sizes of the compartments in a model

Description

Reports each compartment's declared size, as the file states it.

Usage

getCmtSizes(input_model)

Arguments

input_model

input should be an SBML Model

Value

a numeric vector, one entry per compartment, in model order

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)
getCmtSizes(model)

Print the events of a model

Description

Prints each event's trigger and assignments as infix math.

Usage

getEventMath(input_model)

Arguments

input_model

input should be an SBML Model

Value

0; called for the printed output

Examples

sbml_file <- system.file("examples", "sbmlevent.xml", package = "r2sbml")
model <- getModel(sbml_file)
getEventMath(model)

Print the function definitions of a model

Description

Prints each function definition's arguments and body as infix math.

Usage

getFunctionDefinition(input_model)

Arguments

input_model

input should be an SBML Model

Value

0; called for the printed output

Examples

sbml_file <- system.file("examples", "sbmlfunctiondefinition.xml", package = "r2sbml")
model <- getModel(sbml_file)
getFunctionDefinition(model)

Read an SBML model

Description

Reads an SBML file and keeps the parsed document alive for the other query functions. A file with error- or fatal-severity diagnostics, or with no model in it, is an error; lesser diagnostics are raised as warnings.

Usage

getModel(filename)

Arguments

filename

input file name, should end with .xml

Value

an external pointer to the model, to pass to the other functions

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)

Number of species in a model

Description

Counts the species the model declares.

Usage

getNumSpecies(input_model)

Arguments

input_model

input should be an SBML model

Value

an integer, the number of species

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)
getNumSpecies(model)

Table of the parameters in a model

Description

Lists each global parameter with its declared value and units.

Usage

getParameterTable(input_model)

Arguments

input_model

input should be an SBML Model

Value

a data frame with one row per parameter and columns Number, ID, Name, Value and Units

Examples

sbml_file <- system.file("examples", "sbmlassignmentrules.xml", package = "r2sbml")
model <- getModel(sbml_file)
getParameterTable(model)

Print the rate laws of a model

Description

Prints each reaction's kinetic law as infix math.

Usage

getReactionMath(input_model)

Arguments

input_model

input should be an SBML Model

Value

0; called for the printed output

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)
getReactionMath(model)

Local parameters of each reaction

Description

Returns every reaction's local (kinetic-law) parameters as a long table. The parameter name carries the reaction id as a prefix, ⁠<reaction>_<parameter>⁠, which is the global name convertReactions() gives it when it promotes local parameters, so the names here match the parameters in generated simulation code (e.g. a local kon in reaction veq is reported as veq_kon).

Usage

getReactionParameters(input_model)

Arguments

input_model

input should be an SBML Model

Value

a data frame with columns Reaction (the reaction id), Parameter (the prefixed name ⁠<reaction>_<parameter>⁠), Local (the parameter id as written inside the kinetic law) and Value (NA when the parameter leaves its value unset). A model whose reactions have no local parameters yields a zero-row data frame.

See Also

getReactionTable() and getReactionStoichiometry().

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)
getReactionParameters(model)

Reactants, products and modifiers of each reaction

Description

Returns the species references of every reaction as a long (tidy) table, one row per participating species, so a reaction with two reactants and one product contributes three rows. This is the structure that getReactionTable() leaves out: it gives the rate law but not which species the reaction consumes or produces.

Usage

getReactionStoichiometry(input_model)

Arguments

input_model

input should be an SBML Model

Value

a data frame with columns Reaction (the reaction id), Species (the species id), Role ("reactant", "product" or "modifier") and Stoichiometry (the stoichiometry of a reactant or product, or NA for a modifier or when the reaction leaves it unset, e.g. because a rule or initial assignment sets it)

See Also

getReactionTable() and getReactionParameters().

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)
getReactionStoichiometry(model)

Table of the reactions in a model

Description

Lists each reaction with its rate law written as infix math.

Usage

getReactionTable(input_model)

Arguments

input_model

input should be an SBML Model

Value

a data frame with one row per reaction and columns Number, ID, Name, Reversible, Compartment (the reaction's compartment, "" when unset) and RateLaw

See Also

getReactionStoichiometry() for the reactants and products of each reaction, and getReactionParameters() for its local parameters.

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)
getReactionTable(model)

Print the rules of a model

Description

Prints each rule as infix math; an algebraic rule is printed as f = 0.

Usage

getRuleMath(input_model)

Arguments

input_model

input should be an SBML Model

Value

0; called for the printed output

Examples

sbml_file <- system.file("examples", "sbmlassignmentrules.xml", package = "r2sbml")
model <- getModel(sbml_file)
getRuleMath(model)

Initial values of the species in a model

Description

A species carries initialAmount or initialConcentration, never both, and the unset one reads back as NaN. Asking only for the concentration therefore returned NaN for every species in an amount-based model. This returns whichever attribute the model actually sets.

Usage

getSpeciesIC(input_model)

Arguments

input_model

input should be an SBML Model

Details

The value is reported as the file states it, with no unit conversion, so a model that mixes amount-valued and concentration-valued species yields a vector that mixes units too – getSpeciesTable() shows which column each species used. This deliberately differs from convertReactions(), which must divide an amount by the compartment volume because the ODE it generates integrates concentrations.

A species that sets neither attribute – its value comes from an initial assignment or a rule – is reported as NA, not 0.

Value

a named numeric vector, one entry per species, named by species id

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)
getSpeciesIC(model)

Names of the species in a model

Description

SBML separates id, which every species must have, from name, which is an optional human-readable label. Most models in the wild set only id, so returning name alone gave a vector of empty strings. This returns the name where one is set and falls back to the id otherwise, which is how SBML tools conventionally display a species. getCmtNames() follows the same rule. Use getSpeciesTable() when you need the two columns separately.

Usage

getSpeciesNames(input_model)

Arguments

input_model

input should be an SBML Model

Value

a character vector, one entry per species, in model order

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)
getSpeciesNames(model)

Table of the species in a model

Description

Lists each species with its initial value, compartment and flags.

Usage

getSpeciesTable(input_model)

Arguments

input_model

input should be an SBML Model

Value

a data frame with one row per species and columns Number, Name, ID, InitialConcentration, InitialAmount, Compartment, CompartmentVol, BoundaryCondition and Constant

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)
getSpeciesTable(model)

Summarise an SBML file

Description

Prints the file's SBML level and version and how many of each component its model has.

Usage

printSBML(filename)

Arguments

filename

filename should be the name of the xml file

Value

0 on success and 1 when the file has errors or no model; called for the printed summary

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
printSBML(sbml_file)

Remove a component

Description

Remove a parameter, species, compartment or rule from a loaded model, in place. To remove a reaction, use removeReaction().

Usage

removeParameter(input_model, id)

removeSpecies(input_model, id)

removeCompartment(input_model, id)

removeRule(input_model, variable)

Arguments

input_model

a model pointer from getModel()

id

the id of the parameter, species or compartment to remove

variable

the variable whose rule to remove

Details

Removal of a parameter, species or compartment is refused, and the model left unchanged, while something that stays behind still uses it: math that reads the id, a conversion factor pointing at a parameter, a reaction whose species references a removed species, or a species or reaction in a removed compartment. The error lists what uses it. removeRule() takes the variable an assignment or rate rule sets and removes that rule; the variable then keeps its declared value.

Value

the model pointer, invisibly, so calls can be chained

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)
addParameter(model, "tmp", 1)
removeParameter(model, "tmp")

Remove a reaction

Description

Delete a reaction from a model, in place, with its species references and kinetic law (local parameters included).

Usage

removeReaction(input_model, id)

Arguments

input_model

a model pointer from getModel()

id

the id of the reaction

Details

Removal is refused, and the model left unchanged, when something that stays behind still uses the reaction: math that reads its id (in Level 3 that is the reaction's rate) or the id of one of its species references (that is a stoichiometry), or a rule, initial assignment or event assignment that sets such a stoichiometry. The error lists what uses it.

The species stay. A species no other reaction or rule changes keeps its initial value from then on. As with the other setters the model changes in place; use copyModel() first to keep the original. To switch a reaction off but keep it, set its rate law to zero with setRateLaw(model, id, "0").

Value

the model pointer, invisibly, so calls can be chained

Examples

sbml_file <- system.file("examples", "sbmlmutlicompartment.xml", package = "r2sbml")
model <- getModel(sbml_file)
removeReaction(model, "degradation")
getReactionMath(model)

Replace a reaction's rate law

Description

Parse an infix formula and make it the kinetic law of a reaction, in place.

Usage

setRateLaw(input_model, id, formula)

Arguments

input_model

a model pointer from getModel()

id

the id of the reaction

formula

the new rate law, a single string

Details

formula uses libSBML's Level 3 infix syntax, the same syntax getReactionMath() prints: k1 * S, Vmax * S / (Km + S), S^2, exp(-k * time), and calls to the model's function definitions. Every name in it must be a compartment, species, parameter, reaction or species reference of the model, one of the reaction's local parameters, or a function definition; anything else is an error and the model is left unchanged.

The reaction's local parameters are kept, whether or not the new formula uses them. A reaction without a kinetic law gets one. As with the other setters the model changes in place; see editModel. writeSBML() runs the full consistency checks, so it reports units that do not add up as warnings.

Value

the model pointer, invisibly, so calls can be chained

Examples

sbml_file <- system.file("examples", "sbmlsimple.xml", package = "r2sbml")
model <- getModel(sbml_file)
# vcat's local parameter kcat is kept, so the new law can still use it
setRateLaw(model, "vcat", "comp * kcat * ES / (1 + P)")
getReactionMath(model)

Write a model to an SBML file

Description

Writes the model, with any edits made by setParameterValue(), setCompartmentSize() or setSpeciesIC(), to an SBML file.

Usage

writeSBML(input_model, filename)

Arguments

input_model

a model pointer from getModel()

filename

output file name, conventionally ending in .xml

Details

The model is first run through libSBML's consistency checks. A model with error- or fatal-severity diagnostics is not written, so an edit can never leave an invalid file behind; lesser diagnostics are raised as a warning and the file is written anyway, the rule getModel() applies when reading. Because these checks are more thorough than the ones made on reading, a model getModel() accepted can still be refused here.

libSBML writes the whole document in its own layout, so a diff against the original file shows changes of indentation and attribute order besides the edits. The SBML level and version are kept.

Value

NULL invisibly

Examples

sbml_file <- system.file("examples", "sbmlmutlicompartment.xml", package = "r2sbml")
model <- getModel(sbml_file)
setParameterValue(model, "k1", 1000)
out_file <- tempfile(fileext = ".xml")
writeSBML(model, out_file)
getParameterTable(getModel(out_file))