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
39f0ea09
Commit
39f0ea09
authored
Feb 26, 2021
by
Miroslav Kratochvil
🚴
Browse files
output sparse S matrix
parent
2263ee90
Changes
4
Hide whitespace changes
Inline
Side-by-side
Manifest.toml
View file @
39f0ea09
...
...
@@ -39,6 +39,10 @@ git-tree-sha1 = "8e924324b2e9275a51407a4e06deb3455b1e359f"
uuid
=
"94ce4f54-9a6c-5748-9c1c-f9c7231a4531"
version
=
"1.16.0+7"
[[LinearAlgebra]]
deps
=
["Libdl"]
uuid
=
"37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
[[Logging]]
uuid
=
"56ddb016-857b-54e1-b83d-db4d58db5568"
...
...
@@ -77,6 +81,10 @@ uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
[[Sockets]]
uuid
=
"6462fe0b-24de-5631-8697-dd941f90decc"
[[SparseArrays]]
deps
=
[
"LinearAlgebra"
,
"Random"
]
uuid
=
"2f01184e-e22b-5df5-ae63-d93ebab69eaf"
[[Test]]
deps
=
[
"Distributed"
,
"InteractiveUtils"
,
"Logging"
,
"Random"
]
uuid
=
"8dfed614-e22c-5e08-85e1-65c5234f0b40"
...
...
Project.toml
View file @
39f0ea09
...
...
@@ -8,6 +8,7 @@ Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Pkg
=
"44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
SBML_jll
=
"bb12108a-f4ef-5f88-8ef3-0b33ff7017f1"
SHA
=
"ea8e919c-243c-51af-8825-aaa63cd721ce"
SparseArrays
=
"2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test
=
"8dfed614-e22c-5e08-85e1-65c5234f0b40"
[compat]
...
...
src/SBML.jl
View file @
39f0ea09
module
SBML
using
SBML_jll
,
Libdl
,
Pkg
using
SparseArrays
include
(
"structs.jl"
)
include
(
"version.jl"
)
...
...
src/utils.jl
View file @
39f0ea09
"""
function getS(m::Model)::Tuple{Vector{String},Vector{String},Matrix{Float64}}
function getS(m::Model
; zeros=spzeros
)::Tuple{Vector{String},Vector{String},
Abstract
Matrix{Float64}}
Extract the vector of species (aka metabolite) identifiers, vector of reaction
identifiers, and the (dense) stoichiometry matrix from an existing `Model`.
Returns a tuple with these values.
"""
function
getS
(
m
::
Model
)
::
Tuple
{
Vector
{
String
},
Vector
{
String
},
Matrix
{
Float64
}}
#TODO this will need a sparse version and faster row ID lookup
rows
=
[
k
for
k
in
keys
(
m
.
species
)]
#TODO this too
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
(
m
::
Model
;
zeros
=
spzeros
,
)
::
Tuple
{
Vector
{
String
},
Vector
{
String
},
AbstractMatrix
{
Float64
}}
rows
=
[
k
for
k
in
keys
(
m
.
species
)]
cols
=
[
k
for
k
in
keys
(
m
.
reactions
)]
rowsd
=
Dict
(
k
=>
i
for
(
i
,
k
)
in
enumerate
(
rows
))
S
=
zeros
(
Float64
,
length
(
rows
),
length
(
cols
))
for
ri
=
1
:
length
(
cols
)
stoi
=
m
.
reactions
[
cols
[
ri
]]
.
stoichiometry
S
[
index
in
(
keys
(
stoi
),
rows
),
ri
]
.=
values
(
stoi
)
for
col
=
1
:
length
(
cols
)
stoi
=
m
.
reactions
[
cols
[
col
]]
.
stoichiometry
S
[
get
index
.
(
Ref
(
rowsd
),
keys
(
stoi
)),
col
]
.=
values
(
stoi
)
end
return
rows
,
cols
,
S
end
...
...
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