Functions
Models
BSTModelKit.jl
provides a set of tools for constructing and solving S-system BST representations. Models are represented by the BSTModel
type, which is a mutable composite type holding information about the model structure and parameters:
BSTModelKit.BSTModel
— Typemutable struct BSTModel <: AbstractBSTModel
Mutable holding structure for the BST model object. This object is used to store all the data that is needed to simulate the model. The object is passed to the evaluate
function to simulate the model. A BSTModel
object is created using the build
function.
Fields
number_of_dynamic_states::Int64
: The number of dynamic states in the model.number_of_static_states::Int64
: The number of static states in the model.list_of_dynamic_species::Array{String,1}
: A list of the dynamic species in the model.list_of_static_species::Array{String,1}
: A list of the static species in the model.list_of_reactions::Array{String,1}
: A list of the reactions in the model.total_species_list::Array{String,1}
: A list of all the species in the model.static_factors_array::Array{Float64,1}
: A list of the static factors in the model.initial_condition_array::Array{Float64,1}
: A list of the initial conditions for the dynamic states.S::Array{Float64,2}
: The stoichiometry matrix.G::Array{Float64,2}
: The exponent matrix.α::Array{Float64,1}
: The rate constant vector.
Metadata fields
author::String
: The author of the model.version::String
: The version of the model.date::String
: The date the model was created.description::String
: A description of the model.
Models can be constructed from a variety of file formats in combination with the build
function:
BSTModelKit.build
— Functionbuild(path::String) -> BSTModel
This function is used to build a BSTModel
object from a model file. The model file can be in one of the following formats: bst, txt, jld2, dat, net, toml
. The function will parse the file and build the model object.
Arguments
path::String
: The path to the model file.
Returns
- A
BSTModel
object. See theBSTModel
documentation for more information on the fields of the model object.
Once a model instance is constructed, it can be saved to a file or loaded from a file using the savemodel
and loadmodel
functions:
BSTModelKit.loadmodel
— Functionloadmodel(path::String) -> AbstractBSTModel
This function is used to load a BSTModel
object from a file. The file can be in one of the following formats: JLD2. The function will load the model object from the file specified by the path
argument.
Arguments
path::String
: The path to the file where the model object will be loaded from.
Returns
- A
BSTModel
object that was loaded from the file.
BSTModelKit.savemodel
— Functionsavemodel(path::String, model::T) -> Bool where T <: AbstractBSTModel
This function is used to save a BSTModel
object to a file. The file can be in one of the following formats: JLD2. The function will save the model object to the file specified by the path
argument.
Arguments
path::String
: The path to the file where the model object will be saved.model::T
: TheBSTModel
object that will be saved to the file.
Returns
- A boolean indicating if the model object was saved successfully.
Solving
BSTModelKit.evaluate
— Functionevaluate(model::BSTModel; tspan::Tuple{Float64,Float64} = (0.0,20.0), Δt::Float64 = 0.01,
input::Union{Nothing,Function} = nothing) -> Tuple{Array{Float64,1}, Array{Float64,2}}
This function is used to evaluate the model object that has been built using the build
function. The evaluate
function will return a tuple with two elements: a vector of time points and a matrix of state values.
Arguments
model::BSTModel
: A model object that has been built using thebuild
function.tspan::Tuple{Float64,Float64}
: A tuple that defines the time span for the simulation. The default is(0.0,20.0)
.Δt::Float64
: The time step for the simulation. The default is0.01
.input::Union{Nothing,Function}
: An optional input function that can be used to drive the simulation. The default isnothing
.
Returns
- A tuple with two elements:
Array{Float64,1}
: A vector of time points.Array{Float64,2}
: A matrix of state values.
BSTModelKit.steadystate
— Functionsteadystate(model::BSTModel; tspan::Tuple{Float64,Float64} = (0.0,20.0), Δt::Float64 = 0.01, input::Union{Nothing,Function} = nothing) -> Array{Float64,1}
The steadystate
function is used to evaluate the steady state of the model object that has been built using the build
function.
Arguments
model::BSTModel
: A model object that has been built using thebuild
function.tspan::Tuple{Float64,Float64}
: A tuple that defines the time span for the simulation. The default is(0.0,20.0)
.Δt::Float64
: The time step for the simulation. The default is0.01
.input::Union{Nothing,Function}
: An optional input function that can be used to drive the simulation. The default isnothing
.
Returns
- A vector of state values that represent the steady state of the system.
Sensitivity Analysis
BSTModelKit.sobol
— Functionsobol(performance::Function, L::Array{Float64,1}, U::Array{Float64,1};
number_of_samples::Int64 = 1000, orders::Array{Int64,1} = [0, 1, 2])
The sobol
function is a wrapper around the gsa
function that uses the Sobol method to perform a global sensitivity analysis.
Arguments
performance::Function
: a function that takes a vector of parameters and returns a scalar performance metric.L::Array{Float64,1}
: a vector of lower bounds for the parameters.U::Array{Float64,1}
: a vector of upper bounds for the parameters.number_of_samples::Int64
: the number of samples to use in the analysis.orders::Array{Int64,1}
: the orders of sensitivity to compute.
Returns
- a
SobolResult
object.
BSTModelKit.morris
— Functionmorris(performance::Function, L::Array{Float64,1}, U::Array{Float64,1};
number_of_samples::Int64 = 1000) -> Array{Float64,2}
The morris
function is a wrapper around the gsa
function that uses the Morris method to perform a global sensitivity analysis.
Arguments
performance::Function
: a function that takes a vector of parameters and returns a scalar performance metric.L::Array{Float64,1}
: a vector of lower bounds for the parameters.U::Array{Float64,1}
: a vector of upper bounds for the parameters.number_of_samples::Int64
: the number of samples to use in the analysis.
Returns
- a matrix of results where the first column is the mean and the second column is the variance of the sensitivity analysis.
Utility
Base.indexin
— Functionindexin(dd::Dict{String,Any},species_symbol::String;
key="total_species_list")::Union{Nothing,Int}
The indexin
function is a utility function that returns the index of a species in the total species list of a model.
Arguments
dd::Dict{String,Any}
: a dictionary that contains the model data.species_symbol::String
: the symbol of the species to find.key::String
: the key in the dictionary that contains the total species list.
Returns
- an integer that represents the index of the species in the total species list, or
nothing
if the species is not found.