762
762
default_reaction_metadata::Vector{Pair{Symbol, T}} = Vector{Pair{Symbol, Any}}()) where {T}
763
763
764
764
Takes a `ReactionSystem` and remakes it, returning a modified `ReactionSystem`. Modifications depend
765
- on which additional arguments are provided. The input `ReactionSystem` is not mutated.
765
+ on which additional arguments are provided. The input `ReactionSystem` is not mutated. Updating
766
+ default reaction metadata is currently the only supported feature.
766
767
767
768
Arguments:
768
769
- `rs::ReactionSystem`: The `ReactionSystem` which you wish to remake.
@@ -772,11 +773,26 @@ Arguments:
772
773
have their value updated).
773
774
"""
774
775
function remake_ReactionSystem_internal (rs:: ReactionSystem ; default_reaction_metadata = [])
775
- # Updates the metadata for all reactions (equation are ignored).
776
+ rs = set_default_metadata (rs; default_reaction_metadata)
777
+ return rs
778
+ end
779
+
780
+ # For a `ReactionSystem`, updates all `Reaction`'s default metadata.
781
+ function set_default_metadata (rs:: ReactionSystem ; default_reaction_metadata = [])
782
+ # Updates reaction metadata for for reactions in this specific system.
776
783
eqtransform (eq) = eq isa Reaction ? set_default_metadata (eq, default_reaction_metadata) : eq
777
784
updated_equations = map (eqtransform, get_eqs (rs))
778
785
@set! rs. eqs = updated_equations
779
786
@set! rs. rxs = Reaction[rx for rx in updated_equations if rx isa Reaction]
787
+
788
+ # Updates reaction metadata for all its subsystems.
789
+ new_sub_systems = similar (get_systems (rs))
790
+ for (i, sub_system) in enumerate (get_systems (rs))
791
+ new_sub_systems[i] = set_default_metadata (sub_system; default_reaction_metadata)
792
+ end
793
+ @set! rs. systems = new_sub_systems
794
+
795
+ # Returns the updated system.
780
796
return rs
781
797
end
782
798
@@ -790,17 +806,17 @@ end
790
806
set_default_metadata (eq:: Equation , default_metadata) = eq
791
807
792
808
"""
793
- remake_noise_scaling (rs::ReactionSystem, noise_scaling)
809
+ set_default_noise_scaling (rs::ReactionSystem, noise_scaling)
794
810
795
811
Creates an updated `ReactionSystem`. This is the old `ReactionSystem`, but each `Reaction` that does
796
- not have a `Noise_scaling ` metadata have its noise_scaling metadata updated. The input `ReactionSystem`
797
- is not mutated.
812
+ not have a `noise_scaling ` metadata have its noise_scaling metadata updated. The input `ReactionSystem`
813
+ is not mutated. Any subsystems of `rs` have their `noise_scaling` metadata updated as well.
798
814
799
815
Arguments:
800
816
- `rs::ReactionSystem`: The `ReactionSystem` which you wish to remake.
801
817
- `noise_scaling`: The updated noise scaling terms
802
818
"""
803
- function remake_noise_scaling (rs:: ReactionSystem , noise_scaling)
819
+ function set_default_noise_scaling (rs:: ReactionSystem , noise_scaling)
804
820
return remake_ReactionSystem_internal (rs, default_reaction_metadata = [:noise_scaling => noise_scaling])
805
821
end
806
822
0 commit comments