Skip to content

Commit

Permalink
Merge pull request #67 from JuliaDiffEq/new_funcs
Browse files Browse the repository at this point in the history
- Add default functions for hill and mm repressors.
  • Loading branch information
ChrisRackauckas authored Nov 15, 2018
2 parents ed1a0fd + 8024b0c commit 716f922
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
11 changes: 11 additions & 0 deletions src/reaction_network.jl
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,9 @@ function recursive_clean!(expr::Any)
(expr.args[1] == :/) && (expr.args[3] == 1) && (return expr.args[2])
haskey(funcdict, expr.args[1]) && return funcdict[expr.args[1]](expr.args[2:end])
in(expr.args[1],hill_name) && return hill(expr)
in(expr.args[1],hillR_name) && return hillR(expr)
in(expr.args[1],mm_name) && return mm(expr)
in(expr.args[1],mmR_name) && return mmR(expr)
(expr.args[1] == :binomial) && (expr.args[3] == 1) && return expr.args[2]
#@isdefined($(expr.args[1])) || error("Function $(expr.args[1]) not defined.")
end
Expand Down Expand Up @@ -454,12 +456,21 @@ hill_name = Set{Symbol}([:hill, :Hill, :h, :H, :HILL])
function hill(expr::Expr)
return :($(expr.args[3])*($(expr.args[2])^$(expr.args[5]))/($(expr.args[4])^$(expr.args[5])+$(expr.args[2])^$(expr.args[5])))
end
hillR_name = Set{Symbol}([:hill_repressor, :hillr, :hillR, :HillR, :hR, :hR, :Hr, :HR, :HILLR])
function hillR(expr::Expr)
return :($(expr.args[3])*($(expr.args[4])^$(expr.args[5]))/($(expr.args[4])^$(expr.args[5])+$(expr.args[2])^$(expr.args[5])))
end

#Michaelis menten function made avaiable.
mm_name = Set{Symbol}([:MM, :mm, :Mm, :mM, :M, :m])
function mm(expr::Expr)
return :($(expr.args[3])*$(expr.args[2])/($(expr.args[4])+$(expr.args[2])))
end
#Michaelis menten function made avaiable.
mmR_name = Set{Symbol}([:mm_repressor, :MMR, :mmr, :mmR, :MmR, :mMr, :MR, :mr, :Mr, :mR])
function mmR(expr::Expr)
return :($(expr.args[3])*$(expr.args[4])/($(expr.args[4])+$(expr.args[2])))
end

#Allows the user to define new function and enable the @reaction_network macro to see them.
macro reaction_func(expr)
Expand Down
20 changes: 13 additions & 7 deletions test/func_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,25 @@ using DiffEqBiological, StochasticDiffEq, Statistics

network1 = @reaction_network rn begin
hill(X,4,3,2), X + Y --> Z1
3X^2+1, X + Y --> Z2
exp(Y), X + Y --> Z3
mm(X,4.0,3), X + Y --> Z2
3X^2+1, X + Y --> Z3
exp(Y), X + Y --> Z4
hillR(X,2.0,3.0,2), X + Y --> Z5
mmR(X,4.0,1), X + Y --> Z6
end
network2 = @reaction_network rn begin
new_hill(X,4,3,2), X + Y --> Z1
new_poly(X), X + Y --> Z2
new_exp(Y), X + Y --> Z3
4.0*X/(X+3), X + Y --> Z2
new_poly(X), X + Y --> Z3
new_exp(Y), X + Y --> Z4
2.0*(3.0^2)/(3.0^2+X^2), X + Y --> Z5
4.0*1/(X+1), X + Y --> Z6
end

for i = 1:100
u = 5*rand(5)
du1 = 3*rand(5); du2 = du1;
du1g = 2.5*rand(5,3); du2g = du1g;
u = 5*rand(length(network1.syms))
du1 = 3*rand(length(network1.syms)); du2 = du1;
du1g = 2.5*rand(length(network1.syms),length(network1.reactions)); du2g = du1g;
t = 9*rand()
p = []

Expand Down

0 comments on commit 716f922

Please sign in to comment.