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
b52d201b
Unverified
Commit
b52d201b
authored
Aug 03, 2021
by
Miroslav Kratochvil
🚴
Committed by
GitHub
Aug 03, 2021
Browse files
Merge pull request #142 from anandijain/aj/substoich_prodstoich
separate reactants and product stoichiometries
parents
dac269e5
9761031e
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/readsbml.jl
View file @
b52d201b
...
...
@@ -358,24 +358,23 @@ function extractModel(mdl::VPtr)::SBML.Model
end
# extract stoichiometry
stoi = Dict{String,Float64}()
add_stoi(sr, factor) = begin
reactants = Dict{String,Float64}()
products = Dict{String,Float64}()
add_stoi(sr, coll) = begin
s = get_string(sr, :SpeciesReference_getSpecies)
stoi[s] =
get(stoi, s, 0) +
ccall(sbml(:SpeciesReference_getStoichiometry), Cdouble, (VPtr,), sr) *
factor
coll[s] =
ccall(sbml(:SpeciesReference_getStoichiometry), Cdouble, (VPtr,), sr)
end
# reactants and products
for j = 1:ccall(sbml(:Reaction_getNumReactants), Cuint, (VPtr,), re)
sr = ccall(sbml(:Reaction_getReactant), VPtr, (VPtr, Cuint), re, j - 1)
add_stoi(sr,
-1
)
add_stoi(sr,
reactants
)
end
for j = 1:ccall(sbml(:Reaction_getNumProducts), Cuint, (VPtr,), re)
sr = ccall(sbml(:Reaction_getProduct), VPtr, (VPtr, Cuint), re, j - 1)
add_stoi(sr,
1
)
add_stoi(sr,
products
)
end
# gene product associations
...
...
@@ -399,7 +398,8 @@ function extractModel(mdl::VPtr)::SBML.Model
reid = get_string(re, :Reaction_getId)
reactions[reid] = Reaction(
stoi,
reactants,
products,
lb,
ub,
haskey(objectives_fbc, reid) ? objectives_fbc[reid] : oc,
...
...
src/structs.jl
View file @
b52d201b
...
...
@@ -99,15 +99,16 @@ end
$(TYPEDEF)
Reaction with stoichiometry that assigns reactants and products their relative
consumption/production rates
(accessible in field `stoichiometry`), lower/upper
bounds (in tuples `lb` and `ub`, with
unit names), and objective coefficient
(`oc`). Also may contains `notes` and
`annotation`.
consumption/production rates
, lower/upper bounds (in tuples `lb` and `ub`, with
unit names), and objective coefficient
(`oc`). Also may contains `notes` and
`annotation`.
# Fields
$(TYPEDFIELDS)
"""
struct
Reaction
stoichiometry
::
Dict
{
String
,
Float64
}
reactants
::
Dict
{
String
,
Float64
}
products
::
Dict
{
String
,
Float64
}
lb
::
Tuple
{
Float64
,
String
}
ub
::
Tuple
{
Float64
,
String
}
oc
::
Float64
...
...
@@ -116,8 +117,8 @@ struct Reaction
reversible
::
Bool
notes
::
Maybe
{
String
}
annotation
::
Maybe
{
String
}
Reaction
(
s
,
l
,
u
,
o
,
as
,
km
,
r
,
n
=
nothing
,
an
=
nothing
)
=
new
(
s
,
l
,
u
,
o
,
as
,
km
,
r
,
n
,
an
)
Reaction
(
rs
,
p
s
,
l
,
u
,
o
,
as
,
km
,
r
,
n
=
nothing
,
an
=
nothing
)
=
new
(
rs
,
p
s
,
l
,
u
,
o
,
as
,
km
,
r
,
n
,
an
)
end
"""
...
...
src/utils.jl
View file @
b52d201b
...
...
@@ -18,8 +18,10 @@ function stoichiometry_matrix(
rowsd
=
Dict
(
k
=>
i
for
(
i
,
k
)
in
enumerate
(
rows
))
S
=
zeros
(
Float64
,
length
(
rows
),
length
(
cols
))
for
col
=
1
:
length
(
cols
)
stoi
=
m
.
reactions
[
cols
[
col
]]
.
stoichiometry
S
[
getindex
.
(
Ref
(
rowsd
),
keys
(
stoi
)),
col
]
.=
values
(
stoi
)
s
=
m
.
reactions
[
cols
[
col
]]
.
reactants
S
[
getindex
.
(
Ref
(
rowsd
),
keys
(
s
)),
col
]
.-=
values
(
s
)
s
=
m
.
reactions
[
cols
[
col
]]
.
products
S
[
getindex
.
(
Ref
(
rowsd
),
keys
(
s
)),
col
]
.+=
values
(
s
)
end
return
rows
,
cols
,
S
end
...
...
cylon-x
🤖
@cylon-x
mentioned in commit
b08b9b08
·
Aug 03, 2021
mentioned in commit
b08b9b08
mentioned in commit b08b9b08b77b32919fd7ca223cd6245fe4b71290
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