@@ -137,9 +137,10 @@ end kon kAon koff kAoff kAp kAdp
137
137
rsi = rates_sym_to_idx
138
138
rates = params[[rsi[:kon ], rsi[:kAon ], rsi[:koff ], rsi[:kAoff ], rsi[:kAp ], rsi[:kAdp ]]]
139
139
u0 = zeros (Int,9 )
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 ]
140
+ statesyms = ModelingToolkit. tosymbol .(ModelingToolkit. operation .(rs. states))
141
+ u0[ findfirst (isequal (:S1 ), statesyms)] = params[1 ]
142
+ u0[ findfirst (isequal (:S2 ), statesyms)] = params[2 ]
143
+ u0[ findfirst (isequal (:S3 ), statesyms)] = params[3 ]
143
144
tf = 100.
144
145
prob = DiscreteProblem (rs, u0, (0. , tf), rates)
145
146
"""
@@ -154,53 +155,49 @@ prob_jump_multistate = JumpProblemNetwork(rs, rates, tf, u0, prob,
154
155
155
156
# generate the network
156
157
N = 10 # number of genes
158
+ @parameters t
159
+ @variables G[1 : 2 N](t) M[1 : 2 N](t) P[1 : 2 N](t) G_ind[1 : 2 N](t)
160
+
157
161
function construct_genenetwork (N)
158
- genenetwork = make_empty_network ()
159
- @parameters t
162
+ genenetwork = make_empty_network ()
160
163
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 ))
164
+ addspecies! (genenetwork,G[2 * i- 1 ])
165
+ addspecies! (genenetwork,M[2 * i- i])
166
+ addspecies! (genenetwork,P[2 * i- i])
167
+ addreaction! (genenetwork, Reaction (10.0 , [G[2 * i- i]], [G[2 * i- i],M[2 * i- i]]))
168
+ addreaction! (genenetwork, Reaction (10.0 , [M[2 * i- i]], [M[2 * i- i],P[2 * i- i]]))
169
+ addreaction! (genenetwork, Reaction (1.0 , [M[2 * i- i]], nothing ))
170
+ addreaction! (genenetwork, Reaction (1.0 , [P[2 * i- i]], nothing ))
171
171
# genenetwork *= "\t 10.0, G$(2*i-1) --> G$(2*i-1) + M$(2*i-1)\n"
172
172
# genenetwork *= "\t 10.0, M$(2*i-1) --> M$(2*i-1) + P$(2*i-1)\n"
173
173
# genenetwork *= "\t 1.0, M$(2*i-1) --> 0\n"
174
174
# genenetwork *= "\t 1.0, P$(2*i-1) --> 0\n"
175
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 ))
176
+ addspecies! (genenetwork,G[2 * i])
177
+ addspecies! (genenetwork,M[2 * i])
178
+ addspecies! (genenetwork,P[2 * i])
179
+ addreaction! (genenetwork, Reaction (5.0 , [G[2 * i]], [G[2 * i],M[2 * i]]))
180
+ addreaction! (genenetwork, Reaction (5.0 , [M[2 * i]], [M[2 * i],P[2 * i]]))
181
+ addreaction! (genenetwork, Reaction (1.0 , [M[2 * i]], nothing ))
182
+ addreaction! (genenetwork, Reaction (1.0 , [P[2 * i]], nothing ))
186
183
# genenetwork *= "\t 5.0, G$(2*i) --> G$(2*i) + M$(2*i)\n"
187
184
# genenetwork *= "\t 5.0, M$(2*i) --> M$(2*i) + P$(2*i)\n"
188
185
# genenetwork *= "\t 1.0, M$(2*i) --> 0\n"
189
186
# genenetwork *= "\t 1.0, P$(2*i) --> 0\n"
190
187
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₂ᵢ]))
188
+ addspecies! (genenetwork, G_ind[2 * i])
189
+ addreaction! (genenetwork, Reaction (0.0001 , [G[2 * i],P[2 * i- i]], [G_ind[2 * i]]))
190
+ addreaction! (genenetwork, Reaction (100.0 , [G_ind[2 * i]], [G_ind[2 * i],M[2 * i]]))
195
191
# genenetwork *= "\t 0.0001, G$(2*i) + P$(2*i-1) --> G$(2*i)_ind \n"
196
192
# genenetwork *= "\t 100., G$(2*i)_ind --> G$(2*i)_ind + M$(2*i)\n"
197
193
end
198
194
genenetwork
199
195
end
200
196
rs = construct_genenetwork (N)
201
197
u0 = zeros (Int, length (rs. states))
198
+ statesyms = ModelingToolkit. tosymbol .(ModelingToolkit. operation .(rs. states))
202
199
for i = 1 : (2 * N)
203
- u0[findfirst (isequal (Variable ( Symbol ( " G $(i) " )) ),rs. states)] = 1
200
+ u0[findfirst (isequal (G[i] ),rs. states)] = 1
204
201
end
205
202
tf = 2000.0
206
203
prob = DiscreteProblem (rs, u0, (0.0 , tf))
@@ -238,16 +235,15 @@ prob_jump_dnadimer_repressor = JumpProblemNetwork(rn, rnpar, tf, u0, prob,
238
235
239
236
# diffusion model
240
237
function getDiffNetwork (N)
241
- diffnetwork = make_empty_network ()
238
+ diffnetwork = make_empty_network ()
242
239
@parameters t K
240
+ @variables X[1 : N](t)
243
241
for i = 1 : N
244
- addspecies! (diffnetwork, Variable ( " X " ,i)(t) )
242
+ addspecies! (diffnetwork, X[i] )
245
243
end
246
244
for i in 1 : (N- 1 )
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ᵢ]))
245
+ addreaction! (diffnetwork, Reaction (K, [X[i]], [X[i+ 1 ]]))
246
+ addreaction! (diffnetwork, Reaction (K, [X[i+ 1 ]], [X[i]]))
251
247
end
252
248
diffnetwork
253
249
end
0 commit comments