Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LCSB-BioCore
SBML.jl
Commits
4164057d
Unverified
Commit
4164057d
authored
Jul 19, 2021
by
Miroslav Kratochvil
🚴
Committed by
GitHub
Jul 19, 2021
Browse files
Merge pull request #122 from giordano/mg/renamings
Rename some functions to something easier understand
parents
6ac1c0cb
49ef7951
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/SBML.jl
View file @
4164057d
...
...
@@ -18,7 +18,7 @@ include("utils.jl")
sbml
(
sym
::
Symbol
)
=
dlsym
(
SBML_jll
.
libsbml_handle
,
sym
)
export
readSBML
,
readSBMLFromString
,
getS
,
getLBs
,
getUBs
,
getOCs
export
readSBML
,
readSBMLFromString
,
stoichiometry_matrix
,
flux_bounds
,
flux_objective
export
set_level_and_version
,
libsbml_convert
,
convert_simplify_math
end
# module
src/utils.jl
View file @
4164057d
"""
function
getS
(m::SBML.Model; zeros=spzeros)::Tuple{Vector{String},Vector{String},AbstractMatrix{Float64}}
function
stoichiometry_matrix
(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 `SBML.Model`.
...
...
@@ -9,7 +9,7 @@ The matrix is sparse by default (initially constructed by
`SparseArrays.spzeros`). You can fill in a custom empty matrix constructed to
argument `zeros`; e.g. running with `zeros=zeros` will produce a dense matrix.
"""
function
getS
(
function
stoichiometry_matrix
(
m
::
SBML
.
Model
;
zeros
=
spzeros
,
)
::
Tuple
{
Vector
{
String
},
Vector
{
String
},
AbstractMatrix
{
Float64
}}
...
...
@@ -25,29 +25,22 @@ function getS(
end
"""
getLB
s(m::SBML.Model)::Vector{Tuple{Float64,String}}
flux_bound
s(m::SBML.Model)::
NTuple{2,
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).
Extract
the
vector
s
of lower
and upper
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).
"""
getLBs
(
m
::
SBML
.
Model
)
::
Vector
{
Tuple
{
Float64
,
String
}}
=
broadcast
(
x
->
x
.
lb
,
values
(
m
.
reactions
))
flux_bounds
(
m
::
SBML
.
Model
)
::
NTuple
{
2
,
Vector
{
Tuple
{
Float64
,
String
}}}
=
(
broadcast
(
x
->
x
.
lb
,
values
(
m
.
reactions
)),
broadcast
(
x
->
x
.
ub
,
values
(
m
.
reactions
)))
"""
getUBs(m::SBML.Model)::Vector{Tuple{Float64,String}}
Likewise to [`getLBs`](@ref), extract the upper bounds.
"""
getUBs
(
m
::
SBML
.
Model
)
::
Vector
{
Tuple
{
Float64
,
String
}}
=
broadcast
(
x
->
x
.
ub
,
values
(
m
.
reactions
))
"""
getOCs(m::SBML.Model)::Vector{Float64}
flux_objective(m::SBML.Model)::Vector{Float64}
Extract the vector of objective coefficients of each reaction.
"""
getOCs
(
m
::
SBML
.
Model
)
::
Vector
{
Float64
}
=
broadcast
(
x
->
x
.
oc
,
values
(
m
.
reactions
))
flux_objective
(
m
::
SBML
.
Model
)
::
Vector
{
Float64
}
=
broadcast
(
x
->
x
.
oc
,
values
(
m
.
reactions
))
"""
initial_amounts(m::SBML.Model; convert_concentrations = false)
...
...
test/ecoli_flux.jl
View file @
4164057d
...
...
@@ -26,11 +26,11 @@ end
@test
length
(
mdl
.
compartments
)
==
2
mets
,
rxns
,
S
=
getS
(
mdl
)
mets
,
rxns
,
S
=
stoichiometry_matrix
(
mdl
)
@test
typeof
(
S
)
<:
AbstractMatrix
{
Float64
}
@test
typeof
(
getS
(
mdl
;
zeros
=
spzeros
)[
3
])
<:
SparseMatrixCSC
{
Float64
}
@test
typeof
(
getS
(
mdl
;
zeros
=
zeros
)[
3
])
==
Matrix
{
Float64
}
@test
typeof
(
stoichiometry_matrix
(
mdl
;
zeros
=
spzeros
)[
3
])
<:
SparseMatrixCSC
{
Float64
}
@test
typeof
(
stoichiometry_matrix
(
mdl
;
zeros
=
zeros
)[
3
])
==
Matrix
{
Float64
}
@test
length
(
mets
)
==
77
@test
length
(
rxns
)
==
77
...
...
@@ -41,17 +41,16 @@ end
@test
mets
[
10
:
12
]
==
[
"M_akg_e"
,
"M_fum_c"
,
"M_pyr_c"
]
@test
rxns
[
10
:
12
]
==
[
"R_H2Ot"
,
"R_PGL"
,
"R_EX_glc_e_"
]
lbs
=
getLBs
(
mdl
)
ubs
=
getUBs
(
mdl
)
ocs
=
getOCs
(
mdl
)
lbs
,
ubs
=
flux_bounds
(
mdl
)
ocs
=
flux_objective
(
mdl
)
@test
length
(
ocs
)
==
length
(
mets
)
@test
ocs
[
40
]
==
1.0
deleteat!
(
ocs
,
40
)
@test
all
(
ocs
.==
0.0
)
@test
length
(
getLB
s
(
mdl
))
==
length
(
rxns
)
@test
length
(
getUB
s
(
mdl
))
==
length
(
rxns
)
@test
length
(
flux_bound
s
(
mdl
)
[
1
]
)
==
length
(
rxns
)
@test
length
(
flux_bound
s
(
mdl
)
[
2
]
)
==
length
(
rxns
)
getunit
((
val
,
unit
))
=
unit
@test
all
([
broadcast
(
getunit
,
lbs
)
broadcast
(
getunit
,
ubs
)]
.==
"mmol_per_gDW_per_hr"
)
...
...
test/loadmodels.jl
View file @
4164057d
...
...
@@ -94,7 +94,7 @@ sbmlfiles = [
@test
typeof
(
mdl
)
==
Model
mets
,
rxns
,
_
=
getS
(
mdl
)
mets
,
rxns
,
_
=
stoichiometry_matrix
(
mdl
)
@test
length
(
mets
)
==
expected_mets
@test
length
(
rxns
)
==
expected_rxns
...
...
cylon-x
🤖
@cylon-x
mentioned in commit
f81aa84f
·
Jul 19, 2021
mentioned in commit
f81aa84f
mentioned in commit f81aa84f830ff257c724730eb2b2f53d09485a9d
Toggle commit list
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