Commit cc059367 authored by Anand's avatar Anand Committed by Miroslav Kratochvil
Browse files

add substoich and prodstoich fields to Reaction

parent b498d676
......@@ -365,17 +365,35 @@ function extractModel(mdl::VPtr)::SBML.Model
get(stoi, s, 0) +
ccall(sbml(:SpeciesReference_getStoichiometry), Cdouble, (VPtr,), sr) *
factor
end
# extract stoichiometry
substoi = Dict{String,Float64}()
add_sstoi(sr, factor) = begin
s = get_string(sr, :SpeciesReference_getSpecies)
substoi[s] =
ccall(sbml(:SpeciesReference_getStoichiometry), Cdouble, (VPtr,), sr) *
factor
end
# extract stoichiometry
prodstoi = Dict{String,Float64}()
add_pstoi(sr, factor) = begin
s = get_string(sr, :SpeciesReference_getSpecies)
prodstoi[s] =
ccall(sbml(:SpeciesReference_getStoichiometry), Cdouble, (VPtr,), sr) *
factor
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_sstoi(sr, 1)
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_pstoi(sr, 1)
end
# gene product associations
......@@ -399,6 +417,8 @@ function extractModel(mdl::VPtr)::SBML.Model
reid = get_string(re, :Reaction_getId)
reactions[reid] = Reaction(
substoi,
prodstoi,
stoi,
lb,
ub,
......
......@@ -107,6 +107,8 @@ bounds (in tuples `lb` and `ub`, with unit names), and objective coefficient
$(TYPEDFIELDS)
"""
struct Reaction
substoich::Dict{String,Float64}
prodstoich::Dict{String,Float64}
stoichiometry::Dict{String,Float64}
lb::Tuple{Float64,String}
ub::Tuple{Float64,String}
......@@ -116,8 +118,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(ss, ps, s, l, u, o, as, km, r, n = nothing, an = nothing) =
new(ss, ps, s, l, u, o, as, km, r, n, an)
end
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment