Commit 8e78100e authored by Miroslav Kratochvil's avatar Miroslav Kratochvil
Browse files

fix null kinetic law

parent a085176e
......@@ -33,12 +33,12 @@ end
function extractModel(mdl::VPtr)::Model
units = Dict{String,Vector{UnitPart}}()
for i = 0:ccall(sbml(:Model_getNumUnitDefinitions), Cuint, (VPtr,), mdl)-1
ud = ccall(sbml(:Model_getUnitDefinition), VPtr, (VPtr, Cuint), mdl, i)
for i = 1:ccall(sbml(:Model_getNumUnitDefinitions), Cuint, (VPtr,), mdl)
ud = ccall(sbml(:Model_getUnitDefinition), VPtr, (VPtr, Cuint), mdl, i - 1)
id = unsafe_string(ccall(sbml(:UnitDefinition_getId), Cstring, (VPtr,), ud))
units[id] = [
begin
u = ccall(sbml(:UnitDefinition_getUnit), VPtr, (VPtr, Cuint), ud, j)
u = ccall(sbml(:UnitDefinition_getUnit), VPtr, (VPtr, Cuint), ud, j - 1)
UnitPart(
unsafe_string(
ccall(
......@@ -52,7 +52,7 @@ function extractModel(mdl::VPtr)::Model
ccall(sbml(:Unit_getScale), Cint, (VPtr,), u),
ccall(sbml(:Unit_getMultiplier), Cdouble, (VPtr,), u),
)
end for j = 0:ccall(sbml(:UnitDefinition_getNumUnits), Cuint, (VPtr,), ud)-1
end for j = 1:ccall(sbml(:UnitDefinition_getNumUnits), Cuint, (VPtr,), ud)
]
end
......@@ -62,14 +62,14 @@ function extractModel(mdl::VPtr)::Model
sbml(:Compartment_getId),
Cstring,
(VPtr,),
ccall(sbml(:Model_getCompartment), VPtr, (VPtr, Cuint), mdl, i),
ccall(sbml(:Model_getCompartment), VPtr, (VPtr, Cuint), mdl, i - 1),
),
) for i = 0:ccall(sbml(:Model_getNumCompartments), Cuint, (VPtr,), mdl)-1
) for i = 1:ccall(sbml(:Model_getNumCompartments), Cuint, (VPtr,), mdl)
]
species = Dict{String,Species}()
for i = 0:ccall(sbml(:Model_getNumSpecies), Cuint, (VPtr,), mdl)-1
sp = ccall(sbml(:Model_getSpecies), VPtr, (VPtr, Cuint), mdl, i)
for i = 1:ccall(sbml(:Model_getNumSpecies), Cuint, (VPtr,), mdl)
sp = ccall(sbml(:Model_getSpecies), VPtr, (VPtr, Cuint), mdl, i - 1)
species[unsafe_string(ccall(sbml(:Species_getId), Cstring, (VPtr,), sp))] = Species(
unsafe_string(ccall(sbml(:Species_getName), Cstring, (VPtr,), sp)),
unsafe_string(ccall(sbml(:Species_getCompartment), Cstring, (VPtr,), sp)),
......@@ -77,24 +77,29 @@ function extractModel(mdl::VPtr)::Model
end
reactions = Dict{String,Reaction}()
for i = 0:ccall(sbml(:Model_getNumReactions), Cuint, (VPtr,), mdl)-1
re = ccall(sbml(:Model_getReaction), VPtr, (VPtr, Cuint), mdl, i)
kl = ccall(sbml(:Reaction_getKineticLaw), VPtr, (VPtr,), re)
for i = 1:ccall(sbml(:Model_getNumReactions), Cuint, (VPtr,), mdl)
re = ccall(sbml(:Model_getReaction), VPtr, (VPtr, Cuint), mdl, i - 1)
lb = (-Inf, "")
ub = (Inf, "")
oc = 0.0
for j = 0:ccall(sbml(:KineticLaw_getNumParameters), Cuint, (VPtr,), kl)-1
p = ccall(sbml(:KineticLaw_getParameter), VPtr, (VPtr, Cuint), kl, j)
id = unsafe_string(ccall(sbml(:Parameter_getId), Cstring, (VPtr,), p))
pval = () -> ccall(sbml(:Parameter_getValue), Cdouble, (VPtr,), p)
punit =
() -> unsafe_string(ccall(sbml(:Parameter_getUnits), Cstring, (VPtr,), p))
if id == "LOWER_BOUND"
lb = (pval(), punit())
elseif id == "UPPER_BOUND"
ub = (pval(), punit())
elseif id == "OBJECTIVE_COEFFICIENT"
oc = pval()
kl = ccall(sbml(:Reaction_getKineticLaw), VPtr, (VPtr,), re)
if kl != C_NULL
for j = 1:ccall(sbml(:KineticLaw_getNumParameters), Cuint, (VPtr,), kl)
p = ccall(sbml(:KineticLaw_getParameter), VPtr, (VPtr, Cuint), kl, j - 1)
id = unsafe_string(ccall(sbml(:Parameter_getId), Cstring, (VPtr,), p))
pval = () -> ccall(sbml(:Parameter_getValue), Cdouble, (VPtr,), p)
punit =
() ->
unsafe_string(ccall(sbml(:Parameter_getUnits), Cstring, (VPtr,), p))
if id == "LOWER_BOUND"
lb = (pval(), punit())
elseif id == "UPPER_BOUND"
ub = (pval(), punit())
elseif id == "OBJECTIVE_COEFFICIENT"
oc = pval()
end
end
end
......@@ -107,13 +112,13 @@ function extractModel(mdl::VPtr)::Model
ccall(sbml(:SpeciesReference_getStoichiometry), Cdouble, (VPtr,), sr) *
factor
for j = 0:ccall(sbml(:Reaction_getNumReactants), Cuint, (VPtr,), re)-1
sr = ccall(sbml(:Reaction_getReactant), VPtr, (VPtr, Cuint), re, j)
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)
end
for j = 0:ccall(sbml(:Reaction_getNumProducts), Cuint, (VPtr,), re)-1
sr = ccall(sbml(:Reaction_getProduct), VPtr, (VPtr, Cuint), re, j)
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)
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