RuleWorld / bionetgen

Rule-based modeling framework
https://bionetgen.org/
MIT License
59 stars 25 forks source link

Time-dependent rate laws? #275

Open hodgensc opened 4 months ago

hodgensc commented 4 months ago

Hi everyone! Apologies if this isn't the right place to put this.

I'm interested in applying a time-dependent rate law for one of my reactions. Currently what I've found to work is a structure like this, where I create a pseudo-species that increases linearly with time as a reaction and then define my time-varying rate law using that.

begin seed species
  A 100
  B 100
  C 0
  T 0
end seed species
begin observables
  Molecules A A()
  Molecules B B()
  Molecules C C()
  Molecules T T()
end observables
begin functions
tfunc() = sin(T)+1
end functions
begin reaction rules
  A() + B() <-> C() tfunc(), 1
  0 -> T    1
end reaction rules
simulate({method=>"ode",t_end=>100,n_steps=>1000})

But, is there a better way to do this? Is it possible to just access the current time state from within the BioNetGen file without having to do this workaround? I noticed that there's a "time" constant reserved in the syntax file in the VSCode extension, and what I know of cvode I'd expect there should be a way to access time from inside the problem function that's passed to it.

wshlavacek commented 4 months ago

I do the same thing but this approach becomes problematic for a stochastic model, as the time counter does not change smoothly I recall trying to use the built-in time function a long time ago and I was dissatisfied with it for some reason that I now forget It would be nice to have a simple way to access the current time in function definitions, no matter which simulator is being used Sent from my iPhoneOn May 17, 2024, at 10:20 AM, hodgensc @.***> wrote: Hi everyone! Apologies if this isn't the right place to put this. I'm interested in applying a time-dependent rate law for one of my reactions. Currently what I've found to work is a structure like this, where I create a pseudo-species that increases linearly with time as a reaction and then define my time-varying rate law using that. begin seed species A 100 B 100 C 0 T 0 end seed species begin observables Molecules A A() Molecules B B() Molecules C C() Molecules T T() end observables begin functions tfunc() = sin(T)+1 end functions begin reaction rules A() + B() <-> C() tfunc(), 1 0 -> T 1 end reaction rules simulate({method=>"ode",t_end=>100,n_steps=>1000})

But, is there a better way to do this? Is it possible to just access the current time state from within the BioNetGen file without having to do this workaround? I noticed that there's a "time" constant reserved in the syntax file in the VSCode extension, and what I know of cvode I'd expect there should be a way to access time from inside the problem function that's passed to it.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>