Unverified Commit 3500090e authored by Miroslav Kratochvil's avatar Miroslav Kratochvil Committed by GitHub
Browse files

Merge pull request #58 from LCSB-BioCore/mk-init-cs

add initial concentration, fix certainty of units
parents d8e40b32 42299f85
"""
convert_level_and_version(level, version)
set_level_and_version(level, version)
A converter to pass into [`readSBML`](@ref) that enforces certain SBML level
and version.
"""
convert_level_and_version(level, version) =
set_level_and_version(level, version) =
doc -> begin
ccall(
sbml(:SBMLDocument_setLevelAndVersion),
......@@ -45,6 +45,19 @@ libsbml_convert(conversion_options::Vector{Pair{String,Dict{String,String}}}) =
end
end
"""
libsbml_convert(converter::String; kwargs...)
Quickly construct a single run of a `libsbml` converter from keyword arguments.
# Example
```
readSBML("example.xml", libsbml_convert("stripPackage", package="layout"))
```
"""
libsbml_convert(converter::String; kwargs...) =
libsbml_convert([converter => Dict(string(k) => string(v) for (k, v) in kwargs)])
"""
convert_simplify_math
......@@ -52,6 +65,6 @@ Shortcut for [`libsbml_convert`](@ref) that expands functions, local
parameters, and initial assignments in the SBML document.
"""
convert_simplify_math = libsbml_convert(
["promoteLocalParameters", "expandFunctionDefinitions", "setLevelAndVersion"] .=>
["promoteLocalParameters", "expandFunctionDefinitions"] .=>
Ref(Dict{String,String}()),
)
......@@ -88,7 +88,7 @@ single parameter, which is the C pointer to the loaded SBML document (C type
# Example
```
m = readSBML("my_model.xml", doc -> begin
convert_level_and_version(3, 1)(doc)
set_level_and_version(3, 1)(doc)
convert_simplify_math(doc)
end)
```
......@@ -240,7 +240,15 @@ function extractModel(mdl::VPtr)::SBML.Model
if ccall(sbml(:Species_isSetInitialAmount), Cint, (VPtr,), sp) != 0
ia = (
ccall(sbml(:Species_getInitialAmount), Cdouble, (VPtr,), sp),
get_string(sp, :Species_getSubstanceUnits),
get_optional_string(sp, :Species_getSubstanceUnits),
)
end
ic = nothing
if ccall(sbml(:Species_isSetInitialConcentration), Cint, (VPtr,), sp) != 0
ic = (
ccall(sbml(:Species_getInitialAmount), Cdouble, (VPtr,), sp),
get_optional_string(sp, :Species_getSubstanceUnits),
)
end
......@@ -255,6 +263,7 @@ function extractModel(mdl::VPtr)::SBML.Model
formula,
charge,
ia,
ic,
get_optional_bool(
sp,
:Species_isSetHasOnlySubstanceUnits,
......
......@@ -142,12 +142,13 @@ struct Species
boundary_condition::Maybe{Bool}
formula::Maybe{String}
charge::Maybe{Int}
initial_amount::Maybe{Tuple{Float64,String}}
initial_amount::Maybe{Tuple{Float64,Maybe{String}}}
initial_concentration::Maybe{Tuple{Float64,Maybe{String}}}
only_substance_units::Maybe{Bool}
notes::Maybe{String}
annotation::Maybe{String}
Species(na, co, b, f, ch, ia, osu, no = nothing, a = nothing) =
new(na, co, b, f, ch, ia, osu, no, a)
Species(na, co, b, f, ch, ia, ic, osu, no = nothing, a = nothing) =
new(na, co, b, f, ch, ia, ic, osu, no, a)
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