Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Gitlab will go into maintenance Friday 3rd February from 9:00 to 10:00
Open sidebar
LCSB-BioCore
SBML.jl
Commits
8ce374a2
Commit
8ce374a2
authored
May 28, 2021
by
anand jain
Browse files
Model -> SBML.Model
parent
6f0f0807
Changes
5
Hide whitespace changes
Inline
Side-by-side
docs/src/index.md
View file @
8ce374a2
...
...
@@ -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
}
:
...
...
src/readsbml.jl
View file @
8ce374a2
...
...
@@ -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
")
...
...
src/structs.jl
View file @
8ce374a2
...
...
@@ -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
...
...
src/utils.jl
View file @
8ce374a2
"""
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
test/runtests.jl
View file @
8ce374a2
using
Test
,
SHA
,
SparseArrays
using
SBML
using
SBML
:
Model
,
Reaction
,
Species
import
Pkg
@testset
"SBML test suite"
begin
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment