Catalyst.jl icon indicating copy to clipboard operation
Catalyst.jl copied to clipboard

writing ReactionSystem to file

Open anandijain opened this issue 3 years ago • 1 comments

ODESystems allow you to do

open("mwe.jl", "w") do io
       write(io, sys)
end

this fails on ReactionSystems with

ERROR: type Reaction has no field lhs
Stacktrace:
 [1] getproperty
   @ ./Base.jl:42 [inlined]
 [2] round_trip_eq(eq::Reaction{Any, Float64}, var2name::Dict{Any, Symbol})
   @ ModelingToolkit ~/.julia/packages/ModelingToolkit/r5ZaU/src/systems/abstractsystem.jl:565
 [3] push_eqs!(stmt::Vector{Any}, eqs::Vector{Any}, var2name::Dict{Any, Symbol})
   @ ModelingToolkit ~/.julia/packages/ModelingToolkit/r5ZaU/src/systems/abstractsystem.jl:572
 [4] toexpr(sys::ReactionSystem{ODESystem})
   @ ModelingToolkit ~/.julia/packages/ModelingToolkit/r5ZaU/src/systems/abstractsystem.jl:621
 [5] write(io::IOStream, sys::ReactionSystem{ODESystem})
   @ ModelingToolkit ~/.julia/packages/ModelingToolkit/r5ZaU/src/systems/abstractsystem.jl:636
 [6] (::var"#14#15")(io::IOStream)
   @ Main ./REPL[190]:2
 [7] open(::var"#14#15", ::String, ::Vararg{String}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Base ./io.jl:330
 [8] open(::Function, ::String, ::String)
   @ Base ./io.jl:328
 [9] top-level scope
   @ REPL[190]:1

I haven't looked into fixing this yet, just making a note. this isn't urgent, but would make debugging some things from sbml easier

anandijain avatar Dec 21 '21 21:12 anandijain

Probably needs a custom write for ReactionSystems, or something that is called by it.

isaacsas avatar Dec 21 '21 21:12 isaacsas