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

support BioNetGen function blocks and more inline function types

Open isaacsas opened this issue 5 years ago • 8 comments

Currently function blocks are not supported. This would be great to add but note, this requires allowing observables within the functions.

isaacsas avatar Feb 27 '19 00:02 isaacsas

Yes. functions and groups would be great!

pascalschulthess avatar Jun 22 '22 16:06 pascalschulthess

Do you have an example that doesn’t currently work?

isaacsas avatar Jun 22 '22 16:06 isaacsas

I'm currently looking into this: https://github.com/labsyspharm/marm1-supplement/blob/master/resources/MARM1.bngl which may be way to complex but it does have both types.

pascalschulthess avatar Jun 27 '22 16:06 pascalschulthess

Could you upload the .net file it generates? That's what we'd want to be able to load here.

isaacsas avatar Jun 27 '22 17:06 isaacsas

There you go... just remove the .txt suffix. Gerosa_BioNetGen_model.net.txt

pascalschulthess avatar Jun 27 '22 19:06 pascalschulthess

Thanks! This looks like we could probably support it in a fairly straightforward manner since the observables are never used in reactions or rate laws. The latter would be more complicated to support. The groups should already work (i.e. you should be able to index a solution object using the group names to get their values).

isaacsas avatar Jun 27 '22 19:06 isaacsas

Alright. I just discovered that if I do:

model_bngl = loadrxnetwork(BNGNetwork(), model_path)
rn = model_bngl.rn

I can access the observables if I do rn.observed which gives for instance tDUSP(t) ~ S24(t) + S296(t). I, however, don't know how I could get this as an output of solve.

pascalschulthess avatar Jun 28 '22 08:06 pascalschulthess

Here is an example on how to index by the name of a variable (which should work for observables too)

using Catalyst, OrdinaryDiffEq
rn = @reaction_network begin
    α, S + I --> 2I
    β, I --> R
end α β
p     = [:α => .1/1000, :β => .01]
tspan = (0.0,250.0)
u0    = [:S => 999.0, :I => 1.0, :R => 0.0]
op    = ODEProblem(rn, u0, tspan, p)
sol   = solve(op, Tsit5()) 
@unpack S = rn
sol[S]   # solution for the variable S
# or
t = [1.0, 1.5, 2.0]
@unpack I = rn
sol(t, idxs=[S,I])   # values of S and I at the times

isaacsas avatar Jun 29 '22 23:06 isaacsas