Commit c7339ee0 authored by Miroslav Kratochvil's avatar Miroslav Kratochvil
Browse files

bump SBML compat to 0.7.x

Also closes #427
parent 60a1abab
Pipeline #45229 passed with stages
in 28 minutes and 19 seconds
...@@ -30,7 +30,7 @@ MAT = "0.10" ...@@ -30,7 +30,7 @@ MAT = "0.10"
MacroTools = "0.5.6" MacroTools = "0.5.6"
OSQP = "0.6" OSQP = "0.6"
OrderedCollections = "1.4" OrderedCollections = "1.4"
SBML = "0.6" SBML = "0.7"
Tulip = "0.7" Tulip = "0.7"
julia = "1" julia = "1"
......
...@@ -140,8 +140,16 @@ const _sbml_export_notes = _sbml_export_annotation ...@@ -140,8 +140,16 @@ const _sbml_export_notes = _sbml_export_annotation
Return the stoichiometry of reaction with ID `rid`. Return the stoichiometry of reaction with ID `rid`.
""" """
reaction_stoichiometry(m::SBMLModel, rid::String)::Dict{String,Float64} = function reaction_stoichiometry(m::SBMLModel, rid::String)::Dict{String,Float64}
m.sbml.reactions[rid].stoichiometry s = Dict{String,Float64}()
for (mid, x) in m.sbml.reactions[rid].reactants
s[mid] = get(s, mid, 0.0) - x
end
for (mid, x) in m.sbml.reactions[rid].products
s[mid] = get(s, mid, 0.0) + x
end
return s
end
""" """
Base.convert(::Type{SBMLModel}, mm::MetabolicModel) Base.convert(::Type{SBMLModel}, mm::MetabolicModel)
...@@ -186,10 +194,14 @@ function Base.convert(::Type{SBMLModel}, mm::MetabolicModel) ...@@ -186,10 +194,14 @@ function Base.convert(::Type{SBMLModel}, mm::MetabolicModel)
), ),
Dict( Dict(
rid => SBML.Reaction( rid => SBML.Reaction(
Dict([ Dict(
mets[i] => -stoi[i, ri] for
i in SparseArrays.nonzeroinds(stoi[:, ri]) if stoi[i, ri] <= 0
),
Dict(
mets[i] => stoi[i, ri] for mets[i] => stoi[i, ri] for
i in SparseArrays.nonzeroinds(stoi[:, ri]) i in SparseArrays.nonzeroinds(stoi[:, ri]) if stoi[i, ri] > 0
],), ),
(lbs[ri], ""), (lbs[ri], ""),
(ubs[ri], ""), (ubs[ri], ""),
ocs[ri], ocs[ri],
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
@test Set(reactions(sbmlm)) == Set(reactions(sm)) @test Set(reactions(sbmlm)) == Set(reactions(sm))
@test Set(metabolites(sbmlm)) == Set(metabolites(sbmlm2)) @test Set(metabolites(sbmlm)) == Set(metabolites(sbmlm2))
@test all([ @test all([
sbmlm.sbml.reactions[i].stoichiometry == sbmlm2.sbml.reactions[i].stoichiometry for sbmlm.sbml.reactions[i].reactants == sbmlm2.sbml.reactions[i].reactants &&
sbmlm.sbml.reactions[i].products == sbmlm2.sbml.reactions[i].products for
i in reactions(sbmlm2) i in reactions(sbmlm2)
]) ])
end 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