How to convert a String to a Reaction/ReactionSystem type (Catalyst.jl)?

Hey you all, I wanna use Strings to add reactions to a @reaction_network in Catalyst.jl. For example:

julia> example = @reaction_network empty
julia> addreaction!(example, "k, A --> B")

or

julia> addreaction!(example, "A --> B")
1 Like

I have used parse and eval methods to wrap the string. That’s a temporary solution

function reaction_network(constants, schemes)
    reactions = String[]

    for (constant, scheme) in zip(constants, schemes)
        push!(reactions, constant*", "*scheme*" \n")
    end 

    network = "@reaction_network begin \n"

    for reaction in reactions
        network *= reaction
    end

    complete_network = network*"end "

    for constant in constants
        complete_network *= constant*" "
    end

    parsed_network = Meta.parse(complete_network)

    rn = eval(parsed_network)    

    return rn
end