@@ -87,7 +87,7 @@ function handle_us_n_ps(file_text::String, rn::ReactionSystem, annotate::Bool, t
87
87
p_deps && (@string_append! us_n_ps_string " parameters, " )
88
88
sp_deps && (@string_append! us_n_ps_string " species, " )
89
89
var_deps && (@string_append! us_n_ps_string " variables, " )
90
- us_n_ps_string = us_n_ps_string[ 1 : end - 2 ]
90
+ us_n_ps_string = get_substring_end ( us_n_ps_string, 1 , - 2 )
91
91
@string_append! us_n_ps_string " depends on the declaration of other parameters, species, and/or variables.\n # These are specially handled here.\n "
92
92
end
93
93
@@ -117,7 +117,7 @@ function handle_us_n_ps(file_text::String, rn::ReactionSystem, annotate::Bool, t
117
117
p_deps && (@string_append! us_n_ps_string " ps = " syms_2_strings (ps_all) " \n " )
118
118
sp_deps && (@string_append! us_n_ps_string " sps = " syms_2_strings (sps_all) " \n " )
119
119
var_deps && (@string_append! us_n_ps_string " vars = " syms_2_strings (vars_all) " \n " )
120
- us_n_ps_string = us_n_ps_string[ 1 : end - 1 ]
120
+ us_n_ps_string = get_substring_end ( us_n_ps_string, 1 , - 1 )
121
121
end
122
122
123
123
# If this is not a top-level system, `local ` must be added to all declarations.
@@ -217,7 +217,9 @@ function get_reactions_string(rn::ReactionSystem)
217
217
strip_call_dict = make_strip_call_dict (rn)
218
218
219
219
# Handles the case with one reaction separately. Only effect is nicer formatting.
220
- (length (get_rxs (rn)) == 1 ) && (return " rxs = [$(reaction_string (rx, strip_call_dict)) ]" )
220
+ if length (get_rxs (rn)) == 1
221
+ return " rxs = [$(reaction_string (get_rxs (rn)[1 ], strip_call_dict)) ]"
222
+ end
221
223
222
224
# Creates the string corresponding to the code which generates the system's reactions.
223
225
rxs_string = " rxs = ["
@@ -226,7 +228,7 @@ function get_reactions_string(rn::ReactionSystem)
226
228
end
227
229
228
230
# Updates the string (including removing the last `,`) and returns it.
229
- return rxs_string[ 1 : end - 1 ] * " \n ]"
231
+ return get_substring_end ( rxs_string, 1 , - 1 ) * " \n ]"
230
232
end
231
233
232
234
# Creates a string that corresponds to the declaration of a single `Reaction`.
@@ -251,7 +253,7 @@ function reaction_string(rx::Reaction, strip_call_dict)
251
253
metadata_entry = " $(x_2_string (entry)) , "
252
254
@string_append! rx_string metadata_entry
253
255
end
254
- rx_string = rx_string[ 1 : end - 2 ] * " ]"
256
+ rx_string = get_substring_end ( rx_string, 1 , - 2 ) * " ]"
255
257
end
256
258
257
259
# Returns the Reaction string.
@@ -291,7 +293,7 @@ function get_equations_string(rn::ReactionSystem)
291
293
end
292
294
293
295
# Updates the string (including removing the last `,`) and returns it.
294
- return eqs_string[ 1 : end - 1 ] * " \n ]"
296
+ return get_substring_end ( eqs_string, 1 , - 1 ) * " \n ]"
295
297
end
296
298
297
299
# Creates an annotation for the system's equations.
@@ -378,7 +380,7 @@ function get_continuous_events_string(rn::ReactionSystem)
378
380
end
379
381
380
382
# Updates the string (including removing the last `,`) and returns it.
381
- return continuous_events_string[ 1 : end - 1 ] * " \n ]"
383
+ return get_substring_end ( continuous_events_string, 1 , - 1 ) * " \n ]"
382
384
end
383
385
384
386
# Creates a string that corresponds to the declaration of a single continuous event.
@@ -388,7 +390,7 @@ function continuous_event_string(continuous_event, strip_call_dict)
388
390
for eq in continuous_event. eqs
389
391
@string_append! eqs_string expression_2_string (eq; strip_call_dict) " , "
390
392
end
391
- eqs_string = eqs_string[ 1 : end - 2 ] * " ]"
393
+ eqs_string = get_substring_end ( eqs_string, 1 , - 2 ) * " ]"
392
394
393
395
# Creates the string corresponding to the affects.
394
396
# Continuous events' `affect` field should probably be called `affects`. Likely the `s` was
@@ -397,7 +399,7 @@ function continuous_event_string(continuous_event, strip_call_dict)
397
399
for affect in continuous_event. affect
398
400
@string_append! affects_string expression_2_string (affect; strip_call_dict) " , "
399
401
end
400
- affects_string = affects_string[ 1 : end - 2 ] * " ]"
402
+ affects_string = get_substring_end ( affects_string, 1 , - 2 ) * " ]"
401
403
402
404
return eqs_string * " => " * affects_string
403
405
end
@@ -435,7 +437,7 @@ function get_discrete_events_string(rn::ReactionSystem)
435
437
end
436
438
437
439
# Updates the string (including removing the last `,`) and returns it.
438
- return discrete_events_string[ 1 : end - 1 ] * " \n ]"
440
+ return get_substring_end ( discrete_events_string, 1 , - 1 ) * " \n ]"
439
441
end
440
442
441
443
# Creates a string that corresponds to the declaration of a single discrete event.
@@ -453,7 +455,7 @@ function discrete_event_string(discrete_event, strip_call_dict)
453
455
for affect in discrete_event. affects
454
456
@string_append! affects_string expression_2_string (affect; strip_call_dict) " , "
455
457
end
456
- affects_string = affects_string[ 1 : end - 2 ] * " ]"
458
+ affects_string = get_substring_end ( affects_string, 1 , - 2 ) * " ]"
457
459
458
460
return condition_string * " => " * affects_string
459
461
end
@@ -504,7 +506,7 @@ function get_systems_string(rn::ReactionSystem, annotate::Bool)
504
506
# Manipulates the subsystem declaration to make it nicer.
505
507
subsystem_string = get_full_system_string (system, annotate, false )
506
508
subsystem_string = replace (subsystem_string, " \n " => " \n\t " )
507
- subsystem_string = " let\n " * subsystem_string[ 7 : end - 6 ] * " end"
509
+ subsystem_string = " let\n " * get_substring_end ( subsystem_string, 7 , - 6 ) * " end"
508
510
@string_append! systems_string " \n systems[$idx ] = " subsystem_string
509
511
end
510
512
0 commit comments