@@ -34,7 +34,13 @@ Notes:
3434"""
3535function save_reactionsystem (filename:: String , rn:: ReactionSystem ;
3636 annotate = true , safety_check = true )
37+ # Error and warning checks.
3738 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.
3844 open (filename, " w" ) do file
3945 write (file, get_full_system_string (rn, annotate, true ))
4046 end
@@ -65,6 +71,7 @@ function get_full_system_string(rn::ReactionSystem, annotate::Bool, top_level::B
6571 file_text, has_reactions = push_field (file_text, rn, annotate, top_level, REACTIONS_FS)
6672 file_text, has_equations = push_field (file_text, rn, annotate, top_level, EQUATIONS_FS)
6773 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)
6875 file_text, has_continuous_events = push_field (file_text, rn, annotate,
6976 top_level, CONTINUOUS_EVENTS_FS)
7077 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
7885 rs_creation_code = make_reaction_system_call (
7986 rn, annotate, top_level, has_sivs, has_species,
8087 has_variables, has_parameters, has_reactions,
81- has_equations, has_observed, has_continuous_events,
88+ has_equations, has_observed, has_defaults, has_continuous_events,
8289 has_discrete_events, has_systems, has_connection_type)
8390 annotate || (@string_prepend! " \n " file_text)
8491 @string_prepend! " let" file_text
8996
9097# Creates a ReactionSystem call for creating the model. Adds all the correct inputs to it. The input
9198# `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)
97103
98104 # Gets the independent variable input.
99105 iv = x_2_string (get_iv (rs))
@@ -141,6 +147,7 @@ function make_reaction_system_call(
141147 # Goes through various fields that might exists, and if so, adds them to the string.
142148 has_sivs && (@string_append! reaction_system_string " , spatial_ivs" )
143149 has_observed && (@string_append! reaction_system_string " , observed" )
150+ has_defaults && (@string_append! reaction_system_string " , defaults" )
144151 has_continuous_events && (@string_append! reaction_system_string " , continuous_events" )
145152 has_discrete_events && (@string_append! reaction_system_string " , discrete_events" )
146153 has_systems && (@string_append! reaction_system_string " , systems" )
0 commit comments