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
a085176e
Unverified
Commit
a085176e
authored
Feb 26, 2021
by
Laurent Heirendt
✈
Committed by
GitHub
Feb 26, 2021
Browse files
Merge pull request #19 from LCSB-BioCore/mk-sparse
Support sparse S matrix output
parents
2263ee90
a99e4767
Changes
7
Hide whitespace changes
Inline
Side-by-side
Manifest.toml
View file @
a085176e
...
...
@@ -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 @
a085176e
name
=
"SBML"
uuid
=
"e5567a89-2604-4b09-9718-f5f78e97c3bb"
authors
=
[
"Mirek Kratochvil <miroslav.kratochvil@uni.lu>"
,
"LCSB R3 team <lcsb-r3@uni.lu>"
]
version
=
"0.
1
.0"
version
=
"0.
2
.0"
[deps]
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]
...
...
docs/src/index.md
View file @
a085176e
...
...
@@ -31,6 +31,18 @@ julia> metabolites
⋮
julia
>
S
77
×77
SparseArrays
.
SparseMatrixCSC
{
Float64
,
Int64
}
with
308
stored
entries
:
[
60
,
1
]
=
-
1.0
[
68
,
1
]
=
1.0
[
1
,
2
]
=
1.0
[
6
,
2
]
=
-
1.0
⋮
[
23
,
76
]
=
1.0
[
56
,
76
]
=
-
1.0
[
30
,
77
]
=
-
1.0
[
48
,
77
]
=
1.0
julia
>
Matrix
(
S
)
77
×77
Array
{
Float64
,
2
}
:
0.0
1.0
0.0
0.0
0.0
0.0
0.0
…
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
...
...
src/SBML.jl
View file @
a085176e
module
SBML
using
SBML_jll
,
Libdl
,
Pkg
using
SparseArrays
include
(
"structs.jl"
)
include
(
"version.jl"
)
...
...
src/utils.jl
View file @
a085176e
"""
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
...
...
test/loadEColi.jl
View file @
a085176e
...
...
@@ -21,6 +21,10 @@ end
mets
,
rxns
,
S
=
getS
(
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
length
(
mets
)
==
77
@test
length
(
rxns
)
==
77
@test
size
(
S
)
==
(
length
(
mets
),
length
(
rxns
))
...
...
test/runtests.jl
View file @
a085176e
using
Test
,
SHA
using
Test
,
SHA
,
SparseArrays
using
SBML
import
Pkg
...
...
cylon-x
🤖
@cylon-x
mentioned in commit
eb44b837
·
Feb 26, 2021
mentioned in commit
eb44b837
mentioned in commit eb44b837720ab9ab0eba0b54bfe30d9f8cffc159
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