Kinetica.jl API
Analysis
CRN I/O
Kinetica.ODESolveOutput
— TypeODESolveOutput(solvemethod<:AbstractODESolveMethod, sol<:AbstractODESolution, sd::SpeciesData, rd::RxData)
Data container for output of CRN ODE solutions.
Binds together all data required for analysis of network ODE solution results. Used as an input for many of the automated plotting functions in Kinetica.jl.
Also used for results IO, can be completely deconstructed into a package-independent dictionary tree for saving as binary JSON (BSON) with save_output
. Can be reconstructed from such a BSON file with load_output
.
Contains fields for:
- CRN
SpeciesData
after simulation (sd
) - CRN
RxData
after simulation (rd
) - Kinetic simulation solution, usually a DiffEq
ODESolution
o/e (sol
) DiffEqArray
of precalculated rate constants, if discrete rate update method was used (sol_k
)Dict
ofDiffEqArray
s for variable conditions, if solved simultaneously with species concentrations (sol_vcs
)ODESimulationParams
used for kinetic simulation (pars
)ConditionSet
used for kinetic simulation (conditions
)
Kinetica.save_output
— Functionsave_output(out::ODESolveOutput, saveto::String)
Saves the output of a CRN ODE solution to BSON file.
Avoids massive file sizes and attempts to maintain forward compatibility by breaking down large structs into their base arrays and values, such that they can be reconstructed when loaded back in.
The resulting BSON file is therefore a dictionary tree, which can be read in using only Julia's base library and OrderedCollections if all else fails using BSON.load
directly.
However, the original ODESolveOutput
can be mostly reconstructed by instead calling load_output()
. Some data is necessarily lost or converted to a Symbol for reference - mostly data concerning the internals of ODESolution
s.
Kinetica.load_output
— Functionload_output(outfile::String)
Loads in the results from a CRN ODE solution generated by save_output
.
Reconstructs an ODESolveOutput
from a dictionary tree in the BSON file outfile
. Note that some data is lost in the serialisation process, see the documentation of save_output
for details.
Graphing
Catalyst.Graph
— MethodGraph(sd::SpeciesData, rd::RxData[, graph_attrs, species_attrs, rxn_attrs, edge_attrs, use_smiles=false, remove_inactive_species=true])
Creates a Graphviz graph from the supplied CRN.
Copies the functionality in Catalyst's ReactionSystem
graphing utilities (see https://github.com/SciML/Catalyst.jl/blob/master/src/graphs.jl), but makes them usable on raw Kinetica CRNs. This includes reworking node names, as Symbolics.jl's 'arrays of symbolic expressions' are not currently supported in the Catalyst implementation.
Also extends this functionalty by allowing passing of graph attributes directly to Graphviz through the graph_attrs
keyword argument. When this is nothing
, the default Catalyst graph (drawn using the dot
layout) is returned. When given a Dict{Symbol, String}
of graph keywords, these are applied to the generated graph.
Similarly, node attributes for species and reaction nodes can be passed through species_attrs
and rxn_attrs
respectively. Global edge attributes can be passed through edge_attrs
, but individual edges may still set their own properties.
Additionally allows for plotting with SMILES node labels. This is disabled by default, as many of the special characters in SMILES cannot currently be rendered properly. The exploration level in which species and reactions were found is also exported as a node attribute.
The resulting Catalyst.Graph
can be rendered in a notebook, or saved to file using Catalyst.savegraph
, both of which are reexported by Kinetica.