convertReactions() gains a "cvode"
format (alias "sundialr") for the ‘sundialr’ package. It
writes the same model as "R" but for sundialr’s calling
convention: 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.
convertReactions() gains a
"R-reactions" format (alias
"deSolve-reactions"). It writes the same deSolve model as
"R" but keeps the reactions 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.
Models can now gain components, not only have existing ones
edited. addParameter(), addCompartment() and
addSpecies() add those components,
addReaction() adds a reaction from named reactant/product
stoichiometries, a modifier list and a rate law, and
addAssignmentRule() and addRateRule() add
rules. removeParameter(), removeSpecies(),
removeCompartment() and removeRule() remove
components other than reactions, each refusing while remaining math or
structure still references the component. Every adder validates before
it mutates, so a rejected edit leaves the model unchanged.
New functions expose a reaction’s structure, not only its rate
law. getReactionStoichiometry() returns the reactants,
products and modifiers of every reaction with their stoichiometries, and
getReactionParameters() returns each reaction’s local
parameters under the prefixed names
(<reaction>_<parameter>) that
convertReactions() gives them, so they match the parameters
in generated code. getReactionTable() gains a
Compartment column.
Models can now be edited and written back to SBML:
setParameterValue(), setCompartmentSize(),
setSpeciesIC() and setRateLaw() change a
loaded model in place, copyModel() makes an independent
copy, and writeSBML() validates the model and writes it to
a file. A value setter warns when an initial assignment or assignment
rule overrides the value it sets. setRateLaw() parses an
infix formula, refuses one naming an id the reaction cannot see, and
keeps the reaction’s local parameters. removeReaction()
deletes a reaction, refusing while remaining math reads its rate or one
of its stoichiometries.
Fixed a memory leak in getModel(). When R collected
a model, the pointer freed the model but leaked the SBML document that
owns it. It now frees the document, and the model with it.
getModel() now refuses a file that contains no
model, with an error naming the file. It used to return a pointer that
the query functions then rejected with the unhelpful error “external
pointer is not valid”.
The package now builds for WebAssembly, so it runs in webR (R in
the browser). Building with webR’s rwasm used to fail
configuring the bundled ‘libSBML’, because cmake searched the build
machine for libxml2 and zlib. When the compiler is emcc,
the build now passes cmake emscripten’s toolchain file and the
WebAssembly libxml2 and zlib.
Installation no longer fails when
parallel::detectCores() cannot count the physical cores and
returns NA, as it did under rwasm. ‘libSBML’
then builds on two cores.
<new>.-lsbml-static, which picked up a system
‘libSBML’ installed by Linux distributions whenever R’s own library
flags put the system directory first. This made the package fail to load
on CRAN’s clang sanitizer check (undefined symbol
unzGoToFirstFile).convertReactions() no longer relies on ‘libSBML’ to
create the parameter for a stoichiometry set by a rule. On CRAN’s macOS
machines, that parameter was missing and the conversion failed.getModel() and the query functions list a model’s
species, parameters, compartments, reactions, rules, events and function
definitions.convertReactions() writes a model as simulation code
for ‘deSolve’, ‘mrgsolve’, ‘rxode2’, ‘MATLAB’, ‘Julia’ or ‘ubiquity’.
Generated deSolve code is checked against the SBML Test Suite, where
1007 of the 1011 cases in scope pass.