@@ -136,9 +136,9 @@ end kon kAon koff kAoff kAp kAdp
136136rsi = rates_sym_to_idx
137137rates = params[[rsi[:kon ], rsi[:kAon ], rsi[:koff ], rsi[:kAoff ], rsi[:kAp ], rsi[:kAdp ]]]
138138u0 = zeros (Int,9 )
139- u0[ findfirst (rs. syms, :S1 ) ] = params[1 ]
140- u0[ findfirst (rs. syms, :S2 ) ] = params[2 ]
141- u0[ findfirst (rs. syms, :S3 ) ] = params[3 ]
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 ]
142142tf = 100.
143143prob = DiscreteProblem (u0, (0. , tf), rates)
144144"""
@@ -153,23 +153,26 @@ prob_jump_multistate = JumpProblemNetwork(rs, rates, tf, u0, prob,
153153
154154# generate the network
155155N = 10 # number of genes
156- genenetwork = " @reaction_network twentgtype begin\n "
157- for i in 1 : N
158- genenetwork *= " \t 10.0, G$(2 * i- 1 ) --> G$(2 * i- 1 ) + M$(2 * i- 1 ) \n "
159- genenetwork *= " \t 10.0, M$(2 * i- 1 ) --> M$(2 * i- 1 ) + P$(2 * i- 1 ) \n "
160- genenetwork *= " \t 1.0, M$(2 * i- 1 ) --> 0\n "
161- genenetwork *= " \t 1.0, P$(2 * i- 1 ) --> 0\n "
162-
163- genenetwork *= " \t 5.0, G$(2 * i) --> G$(2 * i) + M$(2 * i) \n "
164- genenetwork *= " \t 5.0, M$(2 * i) --> M$(2 * i) + P$(2 * i) \n "
165- genenetwork *= " \t 1.0, M$(2 * i) --> 0\n "
166- genenetwork *= " \t 1.0, P$(2 * i) --> 0\n "
167-
168- genenetwork *= " \t 0.0001, G$(2 * i) + P$(2 * i- 1 ) --> G$(2 * i) _ind \n "
169- genenetwork *= " \t 100., G$(2 * i) _ind --> G$(2 * i) _ind + M$(2 * i) \n "
156+ function construct_genenetwork (N)
157+ genenetwork = " @reaction_network twentgtype 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"
170173end
171- genenetwork *= " end "
172- rs = eval ( parse (genenetwork) )
174+ genenetwork = construct_genenetwork (N)
175+ rs = eval ( Meta . parse (genenetwork) )
173176u0 = zeros (Int, length (rs. syms))
174177for i = 1 : (2 * N)
175178 u0[findfirst (rs. syms, Symbol (" G$(i) " ))] = 1
@@ -217,7 +220,7 @@ function getDiffNetwork(N)
217220 diffnetwork *= " \t K, X$(i+ 1 ) --> X$(i) \n "
218221 end
219222 diffnetwork *= " end K"
220- rs = eval ( parse (diffnetwork) )
223+ rs = eval ( Meta . parse (diffnetwork) )
221224 rs
222225end
223226params = (1. ,)
0 commit comments