Commit 42299f85 authored by Miroslav Kratochvil's avatar Miroslav Kratochvil
Browse files

clean up the converters to work nicely with ICs

parent adf92572
""" """
convert_level_and_version(level, version) set_level_and_version(level, version)
A converter to pass into [`readSBML`](@ref) that enforces certain SBML level A converter to pass into [`readSBML`](@ref) that enforces certain SBML level
and version. and version.
""" """
convert_level_and_version(level, version) = set_level_and_version(level, version) =
doc -> begin doc -> begin
ccall( ccall(
sbml(:SBMLDocument_setLevelAndVersion), sbml(:SBMLDocument_setLevelAndVersion),
...@@ -45,6 +45,19 @@ libsbml_convert(conversion_options::Vector{Pair{String,Dict{String,String}}}) = ...@@ -45,6 +45,19 @@ libsbml_convert(conversion_options::Vector{Pair{String,Dict{String,String}}}) =
end end
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 convert_simplify_math
...@@ -52,6 +65,6 @@ Shortcut for [`libsbml_convert`](@ref) that expands functions, local ...@@ -52,6 +65,6 @@ Shortcut for [`libsbml_convert`](@ref) that expands functions, local
parameters, and initial assignments in the SBML document. parameters, and initial assignments in the SBML document.
""" """
convert_simplify_math = libsbml_convert( convert_simplify_math = libsbml_convert(
["promoteLocalParameters", "expandFunctionDefinitions", "setLevelAndVersion"] .=> ["promoteLocalParameters", "expandFunctionDefinitions"] .=>
Ref(Dict{String,String}()), Ref(Dict{String,String}()),
) )
...@@ -88,7 +88,7 @@ single parameter, which is the C pointer to the loaded SBML document (C type ...@@ -88,7 +88,7 @@ single parameter, which is the C pointer to the loaded SBML document (C type
# Example # Example
``` ```
m = readSBML("my_model.xml", doc -> begin 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) convert_simplify_math(doc)
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