Skip to content

Commit

Permalink
Pl fix case00696 (#24)
Browse files Browse the repository at this point in the history
* throw error if bidirectional_math is only a single symbol

* bump patch version

* add test case for getunidirectionalcomponents called with single Symbol

* throw error on fbc models
  • Loading branch information
paulflang authored Aug 1, 2021
1 parent 5005264 commit b494243
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SBMLToolkit"
uuid = "86080e66-c8ac-44c2-a1a0-9adaadfe4a4e"
authors = ["paulflang", "anandijain"]
version = "0.1.4"
version = "0.1.5"

[deps]
Catalyst = "479239e8-5488-4da2-87a7-35f2df7eef83"
Expand Down
3 changes: 2 additions & 1 deletion src/reactionsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function checksupport(filename::String)
for item in not_implemented
occursin(item, sbml) && throw(ErrorException("SBML models with $item are not yet implemented."))
end
occursin("<sbml xmlns:fbc=", sbml) && throw(ErrorException("This model was designed for constrained-based optimisation. Please use COBREXA.jl instead of SBMLToolkit."))
end

""" Convert intensive to extensive mathematical expression """
Expand Down Expand Up @@ -167,7 +168,7 @@ function getunidirectionalcomponents(bidirectional_math)
err = "Cannot separate bidirectional kineticLaw `$bidirectional_math` to forward and reverse part. Please make reaction irreversible or rearrange kineticLaw to the form `term1 - term2`."
bidirectional_math = Symbolics.tosymbol(bidirectional_math)
bidirectional_math = simplify(bidirectional_math; expand=true)
if (bidirectional_math isa Real) || (SymbolicUtils.operation(bidirectional_math) != +)
if (bidirectional_math isa Union{Real, Symbol}) || (SymbolicUtils.operation(bidirectional_math) != +)
throw(ErrorException(err))
end
terms = SymbolicUtils.arguments(bidirectional_math)
Expand Down
1 change: 1 addition & 0 deletions test/reactionsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ km = SBML.MathIdent("s1s2")
sm1 = convert(Num, km)
sm2 = sm - sm1
@test_throws ErrorException SBMLToolkit.getunidirectionalcomponents(sm2)
@test_throws ErrorException SBMLToolkit.getunidirectionalcomponents(:k1)

# Test get_paramap
trueparamap = [k1 => 1., c1 => 2.]
Expand Down

0 comments on commit b494243

Please sign in to comment.