Commit 8ce374a2 authored by anand jain's avatar anand jain
Browse files

Model -> SBML.Model

parent 6f0f0807
......@@ -5,12 +5,12 @@ This package provides a straightforward way to load model- and
simulation-relevant information from SBML files.
The library provides a single function [`readSBML`](@ref) to load a
[`Model`](@ref):
[`SBML.Model`](@ref):
```julia
julia> using SBML
julia> mdl = readSBML("Ec_core_flux1.xml")
Model()
SBML.Model()
julia> mdl.compartments
2-element Array{String,1}:
......
......@@ -75,11 +75,11 @@ function get_optional_double(x::VPtr, is_sym, get_sym)::Maybe{Float64}
end
"""
function readSBML(fn::String)::Model
function readSBML(fn::String)::SBML.Model
Read the SBML from a XML file in `fn` and return the contained `Model`.
Read the SBML from a XML file in `fn` and return the contained `SBML.Model`.
"""
function readSBML(fn::String)::Model
function readSBML(fn::String)::SBML.Model
doc = ccall(sbml(:readSBML), VPtr, (Cstring,), fn)
try
n_errs = ccall(sbml(:SBMLDocument_getNumErrors), Cuint, (VPtr,), doc)
......@@ -138,12 +138,12 @@ end
""""
function extractModel(mdl::VPtr)::Model
function extractModel(mdl::VPtr)::SBML.Model
Take the `SBMLModel_t` pointer and extract all information required to make a
valid [`Model`](@ref) structure.
valid [`SBML.Model`](@ref) structure.
"""
function extractModel(mdl::VPtr)::Model
function extractModel(mdl::VPtr)::SBML.Model
# get the FBC plugin pointer (FbcModelPlugin_t)
mdl_fbc = ccall(sbml(:SBase_getPlugin), VPtr, (VPtr, Cstring), mdl, "fbc")
......
......@@ -18,7 +18,7 @@ of `Unit`. For example, the unit "per square megahour", Mh^(-2), is written as:
Compound units (such as "volt-amperes" and "dozens of yards per ounce") are
built from multiple `UnitPart`s; see the definition of field `units` in
[`Model`](@ref).
[`SBML.Model`](@ref).
"""
struct UnitPart
kind::String
......
"""
function getS(m::Model; zeros=spzeros)::Tuple{Vector{String},Vector{String},AbstractMatrix{Float64}}
function getS(m::SBML.Model; zeros=spzeros)::Tuple{Vector{String},Vector{String},AbstractMatrix{Float64}}
Extract the vector of species (aka metabolite) identifiers, vector of reaction
identifiers, and the (dense) stoichiometry matrix from an existing `Model`.
identifiers, and the (dense) stoichiometry matrix from an existing `SBML.Model`.
Returns a tuple with these values.
The matrix is sparse by default (initially constructed by
......@@ -10,7 +10,7 @@ The matrix is sparse by default (initially constructed by
argument `zeros`; e.g. running with `zeros=zeros` will produce a dense matrix.
"""
function getS(
m::Model;
m::SBML.Model;
zeros = spzeros,
)::Tuple{Vector{String},Vector{String},AbstractMatrix{Float64}}
rows = [k for k in keys(m.species)]
......@@ -25,30 +25,30 @@ function getS(
end
"""
function getLBs(m::Model)::Vector{Tuple{Float64,String}}
function getLBs(m::SBML.Model)::Vector{Tuple{Float64,String}}
Extract a vector of lower bounds of reaction rates from the model. All bounds
are accompanied with the unit of the corresponding value (this behavior is
based on SBML specification).
"""
function getLBs(m::Model)::Vector{Tuple{Float64,String}}
function getLBs(m::SBML.Model)::Vector{Tuple{Float64,String}}
return broadcast(x -> x.lb, values(m.reactions))
end
"""
function getUBs(m::Model)::Vector{Tuple{Float64,String}}
function getUBs(m::SBML.Model)::Vector{Tuple{Float64,String}}
Likewise to `getLBs`, extract the upper bounds.
"""
function getUBs(m::Model)::Vector{Tuple{Float64,String}}
function getUBs(m::SBML.Model)::Vector{Tuple{Float64,String}}
return broadcast(x -> x.ub, values(m.reactions))
end
"""
function getOCs(m::Model)::Vector{Float64}
function getOCs(m::SBML.Model)::Vector{Float64}
Extract the vector of objective coefficients of each reaction.
"""
function getOCs(m::Model)::Vector{Float64}
function getOCs(m::SBML.Model)::Vector{Float64}
return broadcast(x -> x.oc, values(m.reactions))
end
using Test, SHA, SparseArrays
using SBML
using SBML: Model, Reaction, Species
import Pkg
@testset "SBML test suite" begin
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment