Skip to content

Commit be84648

Browse files
fix architecture-specific Ints
1 parent 0052d27 commit be84648

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/reaction_network.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ funcdict = Dict{Symbol, Function}() #Stores user def
7676
#Coordination function, actually does all the work of the macro.
7777
function coordinate(name, ex::Expr, p, scale_noise)
7878
reactions = get_reactions(ex) ::Vector{ReactionStruct}
79-
reactants = get_reactants(reactions) ::OrderedDict{Symbol,Int64}
80-
parameters = get_parameters(p) ::OrderedDict{Symbol,Int64}
79+
reactants = get_reactants(reactions) ::OrderedDict{Symbol,Int}
80+
parameters = get_parameters(p) ::OrderedDict{Symbol,Int}
8181

8282
syms = collect(keys(reactants))
8383
params = collect(keys(parameters))
@@ -143,7 +143,7 @@ end
143143
#Structure containing information about one reactant in one reaction.
144144
struct ReactantStruct
145145
reactant::Symbol
146-
stoichiometry::Int64
146+
stoichiometry::Int
147147
end
148148

149149
#Structure containing information about one Reaction. Contain all its substrates and products as well as its rate. Contains an specialized constructor.
@@ -193,7 +193,7 @@ function push_reactions(reactions::Vector{ReactionStruct}, sub_line::Any, prod_l
193193
end
194194

195195
#Recursive function that loops through the reactants in an reaction line and finds the reactants and their stochiometry. Recursion makes it able to handle e.g. 2(X+Y+3(Z+XY)) (probably one will not need it though).
196-
function add_reactants!(ex::Any, mult::Int64, reactants::Vector{ReactantStruct})
196+
function add_reactants!(ex::Any, mult::Int, reactants::Vector{ReactantStruct})
197197
if typeof(ex)!=Expr
198198
(ex == 0 || in(ex,empty_set)) && (return reactants)
199199
if in(ex, getfield.(reactants,:reactant))
@@ -216,8 +216,8 @@ end
216216

217217
#From the vector with all reactions, generates a dictionary with all reactants. Each reactant will point to a number so that X --> means X will be replaced with u[1] in the equations.
218218
function get_reactants(reactions::Vector{ReactionStruct})
219-
reactants = OrderedDict{Symbol,Int64}()
220-
r_count = 0 ::Int64
219+
reactants = OrderedDict{Symbol,Int}()
220+
r_count = 0 ::Int
221221
for reaction in reactions
222222
for sub in reaction.substrates
223223
(!haskey(reactants,sub.reactant)) && (reactants[sub.reactant] = r_count += 1)
@@ -231,16 +231,16 @@ end
231231

232232
#Generates a dictionary with all parameters.
233233
function get_parameters(p)
234-
parameters = OrderedDict{Symbol,Int64}()
235-
p_count = 0 ::Int64
234+
parameters = OrderedDict{Symbol,Int}()
235+
p_count = 0 ::Int
236236
for parameter in p
237237
(!haskey(parameters,parameter)) && (parameters[parameter] = p_count += 1)
238238
end
239239
return parameters
240240
end
241241

242242
#Produces an array of expressions. Each entry corresponds to a line in the function f, which constitutes the deterministic part of the system. The Expressions can be used for debugging, making LaTex code, or creating the real f function for simulating the network.
243-
function get_f(reactions::Vector{ReactionStruct}, reactants::OrderedDict{Symbol,Int64})
243+
function get_f(reactions::Vector{ReactionStruct}, reactants::OrderedDict{Symbol,Int})
244244
f = Vector{Expr}(length(reactants))
245245
for i = 1:length(f)
246246
f[i] = :(internal_var___du[$i] = $(Expr(:call, :+)))
@@ -254,7 +254,7 @@ function get_f(reactions::Vector{ReactionStruct}, reactants::OrderedDict{Symbol,
254254
end
255255

256256
#Produces an array of expressions. Each entry corresponds to a line in the function g, which constitutes the stochastic part of the system. Uses the Guillespie Approach for creating Langevin equations. The Expressions can be used for debugging, making LaTex code, or creating the real f function for simulating the network.
257-
function get_g(reactions::Vector{ReactionStruct}, reactants::OrderedDict{Symbol,Int64}, scale_noise::Symbol)
257+
function get_g(reactions::Vector{ReactionStruct}, reactants::OrderedDict{Symbol,Int}, scale_noise::Symbol)
258258
g = Vector{Expr}(length(reactions)*length(reactants))
259259
idx = 0
260260
for reactant in keys(reactants), i = 1:length(reactions)
@@ -276,7 +276,7 @@ function get_stoch_diff(reaction::ReactionStruct, reactant::Symbol)
276276
end
277277

278278
#Creates an expression which can be evaluated to an actual function. Input is an array of expression were each entry is a line in the function. Uses the array of expressions generated in either get_f or get_g.
279-
function make_func(func_expr::Vector{Expr},reactants::OrderedDict{Symbol,Int64},parameters::OrderedDict{Symbol,Int64})
279+
function make_func(func_expr::Vector{Expr},reactants::OrderedDict{Symbol,Int},parameters::OrderedDict{Symbol,Int})
280280
system = Expr(:block)
281281
for func_line in deepcopy(func_expr)
282282
push!(system.args, recursive_replace!(func_line, (reactants,:internal_var___u), (parameters, :internal_var___p)))
@@ -285,7 +285,7 @@ function make_func(func_expr::Vector{Expr},reactants::OrderedDict{Symbol,Int64},
285285
end
286286

287287
#Generates two tuples, each with N entries corresponding to the N reactions in the reaction network. The first tuple contains expressions corresponding to reaction rates, the second contains arrays of expressions corresponding to the affect functions. These expressions can be used for debugging, making LaTex code, or creating Cosnstant Rate Jumps for Guilespie simulations.
288-
function get_jump_expr(reactions::Vector{ReactionStruct}, reactants::OrderedDict{Symbol,Int64})
288+
function get_jump_expr(reactions::Vector{ReactionStruct}, reactants::OrderedDict{Symbol,Int})
289289
rates = Vector{Any}(length(reactions))
290290
affects = Vector{Vector{Expr}}(length(reactions))
291291
idx = 0
@@ -304,7 +304,7 @@ function get_jump_expr(reactions::Vector{ReactionStruct}, reactants::OrderedDict
304304
end
305305

306306
#From the tuples created in get_jump_expr, generates an expression which when evaluated will become a tuple of ConstantRateJumps to be used for Guillespie Simulations.
307-
function get_jumps(rates::Tuple, affects::Tuple,reactants::OrderedDict{Symbol,Int64},parameters::OrderedDict{Symbol,Int64})
307+
function get_jumps(rates::Tuple, affects::Tuple,reactants::OrderedDict{Symbol,Int},parameters::OrderedDict{Symbol,Int})
308308
jumps = Expr(:tuple)
309309
for i = 1:length(rates)
310310
push!(jumps.args,Expr(:call,:ConstantRateJump))
@@ -355,7 +355,7 @@ function recursive_clean!(expr::Any)
355355
end
356356

357357
#Recursively traverses an expression and replace instances of variables and parmaters with things that the DifferentialEquations packakes simulation algorithms can understand. E.g. X --> u[1], kB1 --> p[1] etc.
358-
function recursive_replace!(expr::Any, replace_requests::Tuple{OrderedDict{Symbol,Int64},Symbol}...)
358+
function recursive_replace!(expr::Any, replace_requests::Tuple{OrderedDict{Symbol,Int},Symbol}...)
359359
if typeof(expr) == Symbol
360360
for rr in replace_requests
361361
(haskey(rr[1],expr)) && (return :($(rr[2])[$(rr[1][expr])]))

0 commit comments

Comments
 (0)