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

Merge pull request #98 from LCSB-BioCore/mk-aj-math

comprehensive math
parents bae9557e 52a28006
......@@ -11,22 +11,57 @@ unambiguously represented in Julia; it is supposed to be extended by the user
if more functions need to be supported.
"""
const default_symbolics_mapping = Dict{String,Any}(
"*" => :*,
"+" => :+,
"-" => :-,
"*" => :*,
"/" => :/,
"power" => :^,
"lt" => :<,
"leq" => :<=,
"geq" => :>=,
"gt" => :>,
"abs" => :abs,
"arccos" => :acos,
"arccosh" => :acosh,
"arccot" => :acot,
"arccoth" => :acoth,
"arccsc" => :acsc,
"arccsch" => :acsch,
"arcsec" => :asec,
"arcsech" => :asech,
"arcsin" => :asin,
"arcsinh" => :asinh,
"arctan" => :atan,
"arctanh" => :atanh,
"ceiling" => :ceil,
"cos" => :cos,
"cosh" => :cosh,
"cot" => :cot,
"coth" => :coth,
"csc" => :csc,
"csch" => :csch,
"eq" => :isequal,
"exp" => :exp,
"factorial" => :factorial,
"floor" => :floor,
"piecewise" => :(Core.ifelse),
"geq" => :>=,
"gt" => :>,
"leq" => :<=,
"ln" => :log,
"exp" => :exp,
"log" => :sbmlLog,
"lt" => :<,
"piecewise" => :(Core.ifelse),
"power" => :^,
"root" => :sbmlRoot,
"sech" => :sech,
"sec" => :sec,
"sinh" => :sinh,
"sin" => :sin,
"tanh" => :tanh,
"tan" => :tan,
)
sbmlLog(x) = log(x, 10)
sbmlLog(base, x) = log(base, x)
sbmlRoot(x) = sqrt(x)
sbmlRoot(power, x) = x^(1 / power)
allowed_sym(x, allowed_funs) =
haskey(allowed_funs, x) ? allowed_funs[x] :
throw(DomainError(x, "Unknown SBML function"))
......
......@@ -40,6 +40,14 @@ sbmlfiles = [
4,
2,
),
# this contains some special math
(
joinpath(@__DIR__, "data", "sbml01565.xml"),
"https://raw.githubusercontent.com/sbmlteam/sbml-test-suite/master/cases/semantic/01565/01565-sbml-l3v1.xml",
"14a80fbce316eea2adb566f67b4668ad151db8954e487309852ece7f730c8c99",
104,
52,
),
]
@testset "Loading of models from various sources" begin
......@@ -108,3 +116,12 @@ end
@test subterm.args[1] == SBML.MathIdent("S1")
@test isapprox(subterm.args[2].val, 1.0)
end
@testset "logBase and root math functions" begin
m = readSBML(joinpath(@__DIR__, "data", "sbml01565.xml"))
@test convert(Num, m.reactions["J23"].kinetic_math) == 0.0
@variables S29 S29b
@test isequal(convert(Num, m.reactions["J29"].kinetic_math), 2.0 * S29 * S29b)
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