ruby
...ruby end
block. Probably the most useful possibility is to define elaborated functions directly from within QSoas
, or, preferable, from within a script; this is an alternative to defining a function in a completely separated Ruby-only file using ruby-run. For instance, you can define a function for plain Michaelis-Menten kinetics with a file containing:ruby def my_func(x, vm, km) return vm/(1 + km/x) end ruby end
This defines the function
my_func
with three parameters, , (vm
) and (km
), with the formula: You can then test that the function has been correctly defined running for instance:
QSoas> eval my_func(1.0,1.0,1.0) => 0.5 QSoas> eval my_func(1e4,1.0,1.0) => 0.999900009999
This yields the correct answer: the first command evaluates the function with
x = 1.0
, vm = 1.0
and km = 1.0
. For , the result is (here 0.5
). For , the result is almost . You can use the newly defined my_func
in any place you would use any ruby code, such as in the optional argument to generate-buffer, or for arbitrary fits:QSoas> generate-buffer 0 10 my_func(x,3.0,0.6) QSoas> fit-arb my_func(x,vm,km)
To redefine
my_func
, just run the ruby code again with a new definition, such as:ruby def my_func(x, vm, km) return vm/(1 + km/x**2) end ruby endThe previous version is just erased, and all new uses of
my_func
will refer to your new definition.See for yourself
The code for this example can be found there. Browse theqsoas-goodies
github repository for more goodies !
No comments:
Post a Comment