Commit 2da1a154 authored by Miroslav Kratochvil's avatar Miroslav Kratochvil
Browse files

extract freetext annotations

parent 04d041b9
...@@ -31,8 +31,8 @@ function readSBML(fn::String)::Model ...@@ -31,8 +31,8 @@ function readSBML(fn::String)::Model
end end
end end
function getNotes(x::VPtr)::Maybe{String} function getOptionalString(x::VPtr, fn_sym)::Maybe{String}
str = ccall(sbml(:SBase_getNotesString), Cstring, (VPtr,), x) str = ccall(sbml(fn_sym), Cstring, (VPtr,), x)
if str != C_NULL if str != C_NULL
return unsafe_string(str) return unsafe_string(str)
else else
...@@ -40,6 +40,9 @@ function getNotes(x::VPtr)::Maybe{String} ...@@ -40,6 +40,9 @@ function getNotes(x::VPtr)::Maybe{String}
end end
end end
getNotes(x::VPtr)::Maybe{String} = getOptionalString(x, :SBase_getNotesString)
getAnnotation(x::VPtr)::Maybe{String} = getOptionalString(x, :SBase_getAnnotationString)
function extractModel(mdl::VPtr)::Model function extractModel(mdl::VPtr)::Model
mdl_fbc = ccall(sbml(:SBase_getPlugin), VPtr, (VPtr, Cstring), mdl, "fbc") mdl_fbc = ccall(sbml(:SBase_getPlugin), VPtr, (VPtr, Cstring), mdl, "fbc")
...@@ -114,6 +117,7 @@ function extractModel(mdl::VPtr)::Model ...@@ -114,6 +117,7 @@ function extractModel(mdl::VPtr)::Model
formula, formula,
charge, charge,
getNotes(sp), getNotes(sp),
getAnnotation(sp),
) )
end end
...@@ -209,8 +213,17 @@ function extractModel(mdl::VPtr)::Model ...@@ -209,8 +213,17 @@ function extractModel(mdl::VPtr)::Model
ub, ub,
haskey(objectives_fbc, reid) ? objectives_fbc[reid] : oc, haskey(objectives_fbc, reid) ? objectives_fbc[reid] : oc,
getNotes(re), getNotes(re),
getAnnotation(re),
) )
end end
return Model(parameters, units, compartments, species, reactions, getNotes(mdl)) return Model(
parameters,
units,
compartments,
species,
reactions,
getNotes(mdl),
getAnnotation(mdl),
)
end end
...@@ -40,7 +40,8 @@ struct Reaction ...@@ -40,7 +40,8 @@ struct Reaction
ub::Tuple{Float64,String} ub::Tuple{Float64,String}
oc::Float64 oc::Float64
notes::Maybe{String} notes::Maybe{String}
Reaction(s, l, u, o, n) = new(s, l, u, o, n) annotation::Maybe{String}
Reaction(s, l, u, o, n = nothing, a = nothing) = new(s, l, u, o, n, a)
end end
""" """
...@@ -53,7 +54,8 @@ struct Species ...@@ -53,7 +54,8 @@ struct Species
formula::String formula::String
charge::Maybe{Int} charge::Maybe{Int}
notes::Maybe{String} notes::Maybe{String}
Species(na, co, f, ch, no) = new(na, co, f, ch, no) annotation::Maybe{String}
Species(na, co, f, ch, no = nothing, a = nothing) = new(na, co, f, ch, no, a)
end end
""" """
...@@ -68,5 +70,6 @@ struct Model ...@@ -68,5 +70,6 @@ struct Model
species::Dict{String,Species} species::Dict{String,Species}
reactions::Dict{String,Reaction} reactions::Dict{String,Reaction}
notes::Maybe{String} notes::Maybe{String}
Model(p, u, c, s, r, n) = new(p, u, c, s, r, n) annotation::Maybe{String}
Model(p, u, c, s, r, n = nothing, a = nothing) = new(p, u, c, s, r, n, a)
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