Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support BioNetGen function blocks and more inline function types #4

Open
isaacsas opened this issue Feb 27, 2019 · 8 comments
Open

Comments

@isaacsas
Copy link
Member

isaacsas commented Feb 27, 2019

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

@pascalschulthess
Copy link

Yes. functions and groups would be great!

@isaacsas
Copy link
Member Author

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

@pascalschulthess
Copy link

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.

@isaacsas
Copy link
Member Author

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

@pascalschulthess
Copy link

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

@isaacsas
Copy link
Member Author

isaacsas commented Jun 27, 2022

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).

@pascalschulthess
Copy link

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.

@isaacsas
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants