@@ -864,29 +864,49 @@ end
864
864
# ####################### Other accessors ##############################
865
865
866
866
"""
867
- getnoisescaling (reaction::Reaction)
867
+ has_noise_scaling (reaction::Reaction)
868
868
869
- Returns the noise scaling associated with a specific reaction. If the `:noise_scaling` metadata has
870
- set, returns that. Else, returns `1.0`.
869
+ Checks whether a specific reaction has the metadata field `noise_scaing`. If so, returns `true`, else
870
+ returns `false`.
871
+
872
+ Arguments:
873
+ - `reaction`: The reaction for which we wish to check.
874
+
875
+ Example:
876
+ ```julia
877
+ reaction = @reaction k, 0 --> X, [noise_scaling=0.0]
878
+ has_noise_scaling(reaction)
879
+ """
880
+ function has_noise_scaling (reaction:: Reaction )
881
+ return hasmetadata (reaction, :noise_scaling )
882
+ end
883
+
884
+ """
885
+ get_noise_scaling(reaction::Reaction)
886
+
887
+ Returns the noise_scaling metadata from a specific reaction.
871
888
872
889
Arguments:
873
890
- `reaction`: The reaction for which we wish to retrive all metadata.
874
891
875
892
Example:
876
893
```julia
877
894
reaction = @reaction k, 0 --> X, [noise_scaling=0.0]
878
- getnoisescaling (reaction)
895
+ get_noise_scaling (reaction)
879
896
"""
880
- function getnoisescaling (reaction:: Reaction )
881
- has_metadata (reaction, :noise_scaling ) && (return get_metadata (reaction, :noise_scaling ))
882
- return 1.0
897
+ function get_noise_scaling (reaction:: Reaction )
898
+ if has_noise_scaling (reaction)
899
+ return getmetadata (reaction, :noise_scaling )
900
+ else
901
+ error (" Attempts to access noise_scaling metadata field for a reaction which does not have a value assigned for this metadata." )
902
+ end
883
903
end
884
904
885
905
886
- # These are currently considered internal, but can be used by public accessor functions like getnoisescaling .
906
+ # These are currently considered internal, but can be used by public accessor functions like get_noise_scaling .
887
907
888
908
"""
889
- get_metadata_dict (reaction::Reaction)
909
+ getmetadata_dict (reaction::Reaction)
890
910
891
911
Retrives the `ImmutableDict` containing all of the metadata associated with a specific reaction.
892
912
@@ -896,15 +916,15 @@ Arguments:
896
916
Example:
897
917
```julia
898
918
reaction = @reaction k, 0 --> X, [description="Production reaction"]
899
- get_metadata_dict (reaction)
919
+ getmetadata_dict (reaction)
900
920
```
901
921
"""
902
- function get_metadata_dict (reaction:: Reaction )
922
+ function getmetadata_dict (reaction:: Reaction )
903
923
return reaction. metadata
904
924
end
905
925
906
926
"""
907
- has_metadata (reaction::Reaction, md_key::Symbol)
927
+ hasmetadata (reaction::Reaction, md_key::Symbol)
908
928
909
929
Checks if a `Reaction` have a certain metadata field. If it does, returns `true` (else returns `false`).
910
930
@@ -915,15 +935,15 @@ Arguments:
915
935
Example:
916
936
```julia
917
937
reaction = @reaction k, 0 --> X, [description="Production reaction"]
918
- has_metadata (reaction, :description)
938
+ hasmetadata (reaction, :description)
919
939
```
920
940
"""
921
- function has_metadata (reaction:: Reaction , md_key:: Symbol )
922
- return any (isequal (md_key, entry[1 ]) for entry in get_metadata_dict (reaction))
941
+ function hasmetadata (reaction:: Reaction , md_key:: Symbol )
942
+ return any (isequal (md_key, entry[1 ]) for entry in getmetadata_dict (reaction))
923
943
end
924
944
925
945
"""
926
- get_metadata (reaction::Reaction, md_key::Symbol)
946
+ getmetadata (reaction::Reaction, md_key::Symbol)
927
947
928
948
Retrives a certain metadata value from a `Reaction`. If the metadata does not exists, throws an error.
929
949
@@ -934,15 +954,15 @@ Arguments:
934
954
Example:
935
955
```julia
936
956
reaction = @reaction k, 0 --> X, [description="Production reaction"]
937
- get_metadata (reaction, :description)
957
+ getmetadata (reaction, :description)
938
958
```
939
959
"""
940
- function get_metadata (reaction:: Reaction , md_key:: Symbol )
941
- if ! has_metadata (reaction, md_key)
942
- error (" The reaction does not have a metadata field $md_key . It does have the following metadata fields: $(keys (get_metadata_dict (reaction))) ." )
960
+ function getmetadata (reaction:: Reaction , md_key:: Symbol )
961
+ if ! hasmetadata (reaction, md_key)
962
+ error (" The reaction does not have a metadata field $md_key . It does have the following metadata fields: $(keys (getmetadata_dict (reaction))) ." )
943
963
end
944
- metadata = get_metadata_dict (reaction)
945
- return metadata[findfirst (isequal (md_key, entry[1 ]) for entry in get_metadata_dict (reaction))][2 ]
964
+ metadata = getmetadata_dict (reaction)
965
+ return metadata[findfirst (isequal (md_key, entry[1 ]) for entry in getmetadata_dict (reaction))][2 ]
946
966
end
947
967
948
968
@@ -1065,7 +1085,7 @@ function assemble_diffusion(rs, sts, ispcs; combinatoric_ratelaws = true,
1065
1085
1066
1086
for (j, rx) in enumerate (get_rxs (rs))
1067
1087
rlsqrt = sqrt (abs (oderatelaw (rx; combinatoric_ratelaw = combinatoric_ratelaws)))
1068
- rlsqrt *= getnoisescaling (rx)
1088
+ has_noise_scaling (rx) && ( rlsqrt *= get_noise_scaling (rx) )
1069
1089
remove_conserved && (rlsqrt = substitute (rlsqrt, depspec_submap))
1070
1090
1071
1091
for (spec, stoich) in rx. netstoich
@@ -1485,7 +1505,6 @@ function Base.convert(::Type{<:SDESystem}, rs::ReactionSystem;
1485
1505
name = nameof (rs), combinatoric_ratelaws = get_combinatoric_ratelaws (rs),
1486
1506
include_zero_odes = true , checks = false , remove_conserved = false ,
1487
1507
default_u0 = Dict (), default_p = Dict (), defaults = _merge (Dict (default_u0), Dict (default_p)),
1488
- noise_scaling = nothing , # To be removed (used for deprication message only).
1489
1508
kwargs... )
1490
1509
spatial_convert_err (rs:: ReactionSystem , SDESystem)
1491
1510
@@ -1535,7 +1554,6 @@ function Base.convert(::Type{<:JumpSystem}, rs::ReactionSystem; name = nameof(rs
1535
1554
combinatoric_ratelaws = get_combinatoric_ratelaws (rs),
1536
1555
remove_conserved = nothing , checks = false ,
1537
1556
default_u0 = Dict (), default_p = Dict (), defaults = _merge (Dict (default_u0), Dict (default_p)),
1538
- noise_scaling = nothing , # To be removed (used for deprication message only).
1539
1557
kwargs... )
1540
1558
spatial_convert_err (rs:: ReactionSystem , JumpSystem)
1541
1559
0 commit comments