1
- using DiffEqBase, DiffEqBiological
1
+ using DiffEqBase, Catalyst
2
2
# Jump Example Problems
3
3
export prob_jump_dnarepressor, prob_jump_constproduct, prob_jump_nonlinrxs,
4
4
# examples mixing mass action and constant rate jumps
@@ -13,8 +13,9 @@ export prob_jump_dnarepressor, prob_jump_constproduct, prob_jump_nonlinrxs,
13
13
the JumpProblem constructor requires the algorithm, so we
14
14
don't create the JumpProblem here.
15
15
"""
16
+
16
17
struct JumpProblemNetwork
17
- network # DiffEqBiological network
18
+ network # Catalyst network
18
19
rates # vector of rate constants or nothing
19
20
tstop # time to end simulation
20
21
u0 # initial values
@@ -33,7 +34,7 @@ end k1 k2 k3 k4 k5 k6
33
34
rates = [.5 , (20 * log (2. )/ 120. ), (log (2. )/ 120. ), (log (2. )/ 600. ), .025 , 1. ]
34
35
tf = 1000.0
35
36
u0 = [1 ,0 ,0 ,0 ]
36
- prob = DiscreteProblem (u0, (0.0 , tf), rates)
37
+ prob = DiscreteProblem (dna_rs, u0, (0.0 , tf), rates)
37
38
Nsims = 8000
38
39
expected_avg = 5.926553750000000e+02
39
40
prob_data = Dict (" num_sims_for_mean" => Nsims, " expected_mean" => expected_avg)
@@ -49,7 +50,7 @@ end k1 k2
49
50
rates = [1000. , 10. ]
50
51
tf = 1.0
51
52
u0 = [0 ]
52
- prob = DiscreteProblem (u0, (0. , tf), rates)
53
+ prob = DiscreteProblem (bd_rs, u0, (0. , tf), rates)
53
54
Nsims = 16000
54
55
expected_avg = t -> rates[1 ] / rates[2 ] .* ( 1. - exp .(- rates[2 ] * t))
55
56
prob_data = Dict (" num_sims_for_mean" => Nsims, " expected_mean_at_t" => expected_avg)
@@ -68,7 +69,7 @@ end k1 k2 k3 k4 k5
68
69
rates = [1. , 2. , .5 , .75 , .25 ]
69
70
tf = .01
70
71
u0 = [200 , 100 , 150 ]
71
- prob = DiscreteProblem (u0, (0. , tf), rates)
72
+ prob = DiscreteProblem (nonlin_rs, u0, (0. , tf), rates)
72
73
Nsims = 32000
73
74
expected_avg = 84.876015624999994
74
75
prob_data = Dict (" num_sims_for_mean" => Nsims, " expected_mean" => expected_avg)
@@ -92,7 +93,7 @@ oscil_rs = @reaction_network begin
92
93
end
93
94
u0 = [200. ,60. ,120. ,100. ,50. ,50. ,50. ] # Hill equations force use of floats!
94
95
tf = 4000.
95
- prob = DiscreteProblem (u0, (0. ,tf))
96
+ prob = DiscreteProblem (oscil_rs, u0, (0. ,tf))
96
97
"""
97
98
Oscillatory system, uses a mixture of jump types.
98
99
"""
@@ -136,11 +137,11 @@ end kon kAon koff kAoff kAp kAdp
136
137
rsi = rates_sym_to_idx
137
138
rates = params[[rsi[:kon ], rsi[:kAon ], rsi[:koff ], rsi[:kAoff ], rsi[:kAp ], rsi[:kAdp ]]]
138
139
u0 = zeros (Int,9 )
139
- u0[ something ( findfirst (isequal (:S1 ), rs. syms), 0 )] = params[1 ]
140
- u0[ something ( findfirst (isequal (:S2 ), rs. syms), 0 )] = params[2 ]
141
- u0[ something ( findfirst (isequal (:S3 ), rs. syms), 0 )] = params[3 ]
140
+ u0[ findfirst (isequal (Variable ( :S1 )) , rs. states )] = params[1 ]
141
+ u0[ findfirst (isequal (Variable ( :S2 )) , rs. states )] = params[2 ]
142
+ u0[ findfirst (isequal (Variable ( :S3 )) , rs. states )] = params[3 ]
142
143
tf = 100.
143
- prob = DiscreteProblem (u0, (0. , tf), rates)
144
+ prob = DiscreteProblem (rs, u0, (0. , tf), rates)
144
145
"""
145
146
Multistate model from Gupta and Mendes,
146
147
"An Overview of Network-Based and -Free Approaches for Stochastic Simulation of Biochemical Systems",
@@ -154,39 +155,62 @@ prob_jump_multistate = JumpProblemNetwork(rs, rates, tf, u0, prob,
154
155
# generate the network
155
156
N = 10 # number of genes
156
157
function construct_genenetwork (N)
157
- genenetwork = " @reaction_network begin\n "
158
- for i in 1 : N
159
- genenetwork *= " \t 10.0, G$(2 * i- 1 ) --> G$(2 * i- 1 ) + M$(2 * i- 1 ) \n "
160
- genenetwork *= " \t 10.0, M$(2 * i- 1 ) --> M$(2 * i- 1 ) + P$(2 * i- 1 ) \n "
161
- genenetwork *= " \t 1.0, M$(2 * i- 1 ) --> 0\n "
162
- genenetwork *= " \t 1.0, P$(2 * i- 1 ) --> 0\n "
163
-
164
- genenetwork *= " \t 5.0, G$(2 * i) --> G$(2 * i) + M$(2 * i) \n "
165
- genenetwork *= " \t 5.0, M$(2 * i) --> M$(2 * i) + P$(2 * i) \n "
166
- genenetwork *= " \t 1.0, M$(2 * i) --> 0\n "
167
- genenetwork *= " \t 1.0, P$(2 * i) --> 0\n "
168
-
169
- genenetwork *= " \t 0.0001, G$(2 * i) + P$(2 * i- 1 ) --> G$(2 * i) _ind \n "
170
- genenetwork *= " \t 100., G$(2 * i) _ind --> G$(2 * i) _ind + M$(2 * i) \n "
171
- end
172
- genenetwork *= " end"
158
+ genenetwork = make_empty_network ()
159
+ @parameters t
160
+ for i in 1 : N
161
+ G₂ᵢ₋₁ = Variable (Symbol (" G" ,2 * i- 1 ))(t)
162
+ M₂ᵢ₋₁ = Variable (Symbol (" M" ,2 * i- 1 ))(t)
163
+ P₂ᵢ₋₁ = Variable (Symbol (" P" ,2 * i- 1 ))(t)
164
+ addspecies! (genenetwork,G₂ᵢ₋₁)
165
+ addspecies! (genenetwork,M₂ᵢ₋₁)
166
+ addspecies! (genenetwork,P₂ᵢ₋₁)
167
+ addreaction! (genenetwork, Reaction (10.0 , [G₂ᵢ₋₁], [G₂ᵢ₋₁,M₂ᵢ₋₁]))
168
+ addreaction! (genenetwork, Reaction (10.0 , [M₂ᵢ₋₁], [M₂ᵢ₋₁,P₂ᵢ₋₁]))
169
+ addreaction! (genenetwork, Reaction (1.0 , [M₂ᵢ₋₁], nothing ))
170
+ addreaction! (genenetwork, Reaction (1.0 , [P₂ᵢ₋₁], nothing ))
171
+ # genenetwork *= "\t 10.0, G$(2*i-1) --> G$(2*i-1) + M$(2*i-1)\n"
172
+ # genenetwork *= "\t 10.0, M$(2*i-1) --> M$(2*i-1) + P$(2*i-1)\n"
173
+ # genenetwork *= "\t 1.0, M$(2*i-1) --> 0\n"
174
+ # genenetwork *= "\t 1.0, P$(2*i-1) --> 0\n"
175
+
176
+ G₂ᵢ = Variable (Symbol (" G" ,2 * i))(t)
177
+ M₂ᵢ = Variable (Symbol (" M" ,2 * i))(t)
178
+ P₂ᵢ = Variable (Symbol (" P" ,2 * i))(t)
179
+ addspecies! (genenetwork,G₂ᵢ)
180
+ addspecies! (genenetwork,M₂ᵢ)
181
+ addspecies! (genenetwork,P₂ᵢ)
182
+ addreaction! (genenetwork, Reaction (5.0 , [G₂ᵢ], [G₂ᵢ,M₂ᵢ]))
183
+ addreaction! (genenetwork, Reaction (5.0 , [M₂ᵢ], [M₂ᵢ,P₂ᵢ]))
184
+ addreaction! (genenetwork, Reaction (1.0 , [M₂ᵢ], nothing ))
185
+ addreaction! (genenetwork, Reaction (1.0 , [P₂ᵢ], nothing ))
186
+ # genenetwork *= "\t 5.0, G$(2*i) --> G$(2*i) + M$(2*i)\n"
187
+ # genenetwork *= "\t 5.0, M$(2*i) --> M$(2*i) + P$(2*i)\n"
188
+ # genenetwork *= "\t 1.0, M$(2*i) --> 0\n"
189
+ # genenetwork *= "\t 1.0, P$(2*i) --> 0\n"
190
+
191
+ G₂ᵢ_ind = Variable (Symbol (" G" ,2 * i," _ind" ))(t)
192
+ addspecies! (genenetwork, G₂ᵢ_ind)
193
+ addreaction! (genenetwork, Reaction (0.0001 , [G₂ᵢ,P₂ᵢ₋₁], [G₂ᵢ_ind]))
194
+ addreaction! (genenetwork, Reaction (100.0 , [G₂ᵢ_ind], [G₂ᵢ_ind,M₂ᵢ]))
195
+ # genenetwork *= "\t 0.0001, G$(2*i) + P$(2*i-1) --> G$(2*i)_ind \n"
196
+ # genenetwork *= "\t 100., G$(2*i)_ind --> G$(2*i)_ind + M$(2*i)\n"
197
+ end
198
+ genenetwork
173
199
end
174
- genenetwork = construct_genenetwork (N)
175
- rs = eval ( Meta. parse (genenetwork) )
176
- u0 = zeros (Int, length (rs. syms))
200
+ rs = construct_genenetwork (N)
201
+ u0 = zeros (Int, length (rs. states))
177
202
for i = 1 : (2 * N)
178
- u0[something ( findfirst (isequal (Symbol (" G$(i) " )),rs. syms), 0 )] = 1
203
+ u0[findfirst (isequal (Variable ( Symbol (" G$(i) " ))) ,rs. states )] = 1
179
204
end
180
205
tf = 2000.0
181
- prob = DiscreteProblem (u0, (0.0 , tf))
206
+ prob = DiscreteProblem (rs, u0, (0.0 , tf))
182
207
"""
183
208
Twenty-gene model from McCollum et al,
184
209
"The sorting direct method for stochastic simulation of biochemical systems with varying reaction execution behavior"
185
210
Comp. Bio. and Chem., 30, pg. 39-49 (2006).
186
211
"""
187
212
prob_jump_twentygenes = JumpProblemNetwork (rs, nothing , tf, u0, prob, nothing )
188
213
189
-
190
214
rn = @reaction_network begin
191
215
c1, G --> G + M
192
216
c2, M --> M + P
@@ -201,7 +225,7 @@ rnpar = [.09, .05, .001, .0009, .00001, .0005, .005, .9]
201
225
varlabels = [" G" , " M" , " P" , " P2" ," P2G" ]
202
226
u0 = [1000 , 0 , 0 , 0 ,0 ]
203
227
tf = 4000.
204
- prob = DiscreteProblem (u0, (0.0 , tf), rnpar)
228
+ prob = DiscreteProblem (rn, u0, (0.0 , tf), rnpar)
205
229
"""
206
230
Negative feedback autoregulatory gene expression model. Dimer is the repressor.
207
231
Taken from Marchetti, Priami and Thanh,
@@ -214,14 +238,18 @@ prob_jump_dnadimer_repressor = JumpProblemNetwork(rn, rnpar, tf, u0, prob,
214
238
215
239
# diffusion model
216
240
function getDiffNetwork (N)
217
- diffnetwork = " @reaction_network begin\n "
241
+ diffnetwork = make_empty_network ()
242
+ @parameters t K
243
+ for i = 1 : N
244
+ addspecies! (diffnetwork, Variable (" X" ,i)(t))
245
+ end
218
246
for i in 1 : (N- 1 )
219
- diffnetwork *= " \t K, X$(i) --> X$(i+ 1 ) \n "
220
- diffnetwork *= " \t K, X$(i+ 1 ) --> X$(i) \n "
247
+ Xᵢ = Variable (" X" ,i)(t)
248
+ Xᵢ₊₁ = Variable (" X" ,i+ 1 )(t)
249
+ addreaction! (diffnetwork, Reaction (K, [Xᵢ], [Xᵢ₊₁]))
250
+ addreaction! (diffnetwork, Reaction (K, [Xᵢ₊₁], [Xᵢ]))
221
251
end
222
- diffnetwork *= " end K"
223
- rs = eval ( Meta. parse (diffnetwork) )
224
- rs
252
+ diffnetwork
225
253
end
226
254
params = (1. ,)
227
255
function getDiffu0 (N)
0 commit comments