@@ -34,7 +34,13 @@ Notes:
34
34
"""
35
35
function save_reactionsystem (filename:: String , rn:: ReactionSystem ;
36
36
annotate = true , safety_check = true )
37
+ # Error and warning checks.
37
38
reactionsystem_uptodate_check ()
39
+ if ! isempty (get_networkproperties (rn))
40
+ @warn " The serialised network has cached network properties (e.g. computed conservation laws). This will not be saved as part of the network, and must be recomputed when it is loaded."
41
+ end
42
+
43
+ # Write model to file and performs a safety check.
38
44
open (filename, " w" ) do file
39
45
write (file, get_full_system_string (rn, annotate, true ))
40
46
end
@@ -65,6 +71,7 @@ function get_full_system_string(rn::ReactionSystem, annotate::Bool, top_level::B
65
71
file_text, has_reactions = push_field (file_text, rn, annotate, top_level, REACTIONS_FS)
66
72
file_text, has_equations = push_field (file_text, rn, annotate, top_level, EQUATIONS_FS)
67
73
file_text, has_observed = push_field (file_text, rn, annotate, top_level, OBSERVED_FS)
74
+ file_text, has_defaults = push_field (file_text, rn, annotate, top_level, DEFAULTS_FS)
68
75
file_text, has_continuous_events = push_field (file_text, rn, annotate,
69
76
top_level, CONTINUOUS_EVENTS_FS)
70
77
file_text, has_discrete_events = push_field (file_text, rn, annotate,
@@ -78,7 +85,7 @@ function get_full_system_string(rn::ReactionSystem, annotate::Bool, top_level::B
78
85
rs_creation_code = make_reaction_system_call (
79
86
rn, annotate, top_level, has_sivs, has_species,
80
87
has_variables, has_parameters, has_reactions,
81
- has_equations, has_observed, has_continuous_events,
88
+ has_equations, has_observed, has_defaults, has_continuous_events,
82
89
has_discrete_events, has_systems, has_connection_type)
83
90
annotate || (@string_prepend! " \n " file_text)
84
91
@string_prepend! " let" file_text
89
96
90
97
# Creates a ReactionSystem call for creating the model. Adds all the correct inputs to it. The input
91
98
# `has_` `Bool`s described which inputs are used. If the model is `complete`, this is handled here.
92
- function make_reaction_system_call (
93
- rs:: ReactionSystem , annotate, top_level, has_sivs, has_species,
94
- has_variables, has_parameters, has_reactions, has_equations,
95
- has_observed, has_continuous_events, has_discrete_events,
96
- has_systems, has_connection_type)
99
+ function make_reaction_system_call (rs:: ReactionSystem , annotate, top_level, has_sivs,
100
+ has_species, has_variables, has_parameters, has_reactions, has_equations,
101
+ has_observed, has_defaults, has_continuous_events, has_discrete_events, has_systems,
102
+ has_connection_type)
97
103
98
104
# Gets the independent variable input.
99
105
iv = x_2_string (get_iv (rs))
@@ -141,6 +147,7 @@ function make_reaction_system_call(
141
147
# Goes through various fields that might exists, and if so, adds them to the string.
142
148
has_sivs && (@string_append! reaction_system_string " , spatial_ivs" )
143
149
has_observed && (@string_append! reaction_system_string " , observed" )
150
+ has_defaults && (@string_append! reaction_system_string " , defaults" )
144
151
has_continuous_events && (@string_append! reaction_system_string " , continuous_events" )
145
152
has_discrete_events && (@string_append! reaction_system_string " , discrete_events" )
146
153
has_systems && (@string_append! reaction_system_string " , systems" )
0 commit comments