Skip to content

Commit fd4543d

Browse files
committed
partial progress
1 parent ecd6d76 commit fd4543d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/reactionsystem.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,11 @@ struct ReactionSystem{V <: NetworkProperties} <:
538538
checks && validate(rs)
539539
rs
540540
end
541+
542+
# Copies a reaction system, but with the option of having some fields replaced
543+
function ReactionSystem(rs::ReactionSystem; eqs = rs.eqs, rxs = rs.rxs, iv = rs.iv, sivs = rs.sivs, states = rs.states, species = rs.species, ps = rs.ps, var_to_name = rs.var_to_name, observed = rs.observed, name = rs.name, systems = rs.systems, defaults = rs.defaults, connection_type = rs.connection_type, networkproperties = rs.networkproperties, combinatoric_ratelaws = rs.combinatoric_ratelaws, continuous_events = rs.continuous_events, discrete_events = rs.discrete_events, complete = rs.complete)
544+
new{typeof(networkproperties)}(eqs, rxs, ModelingToolkit.unwrap(iv), ModelingToolkit.unwrap.(sivs), ModelingToolkit.unwrap.(states), ModelingToolkit.unwrap.(species), ModelingToolkit.unwrap.(ps), var_to_name, observed, name, systems, defaults, connection_type, networkproperties, combinatoric_ratelaws, continuous_events, discrete_events, complete)
545+
end
541546
end
542547

543548
function get_speciestype(iv, states, systems)

src/registered_functions.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ function Symbolics.derivative(::typeof(hillar), args::NTuple{5, Any}, ::Val{5})
109109
end
110110

111111
"""
112-
expand_registered_functions!(expr)
112+
expand_registered_functions(expr)
113113
114114
Takes an expression, and expands registered function expressions. E.g. `mm(X,v,K)` is replaced with v*X/(X+K). Currently supported functions: `mm`, `mmr`, `hill`, `hillr`, and `hill`.
115115
"""
116-
function expand_registered_functions!(expr)
116+
function expand_registered_functions(expr)
117117
istree(expr) || return expr
118118
args = arguments(expr)
119119
if operation(expr) == Catalyst.mm
@@ -131,4 +131,8 @@ function expand_registered_functions!(expr)
131131
args[i] = expand_registered_functions!(args[i])
132132
end
133133
return expr
134-
end
134+
end
135+
# If applied to a reaction, return a reaction with its rate modified.
136+
function expand_registered_functions(rx::Reaction)
137+
Reaction(expand_registered_functions(rx.rate), rx.substrates, rx.products, rx.substoich, rx.prodstoich, rx.netstoich, rx.only_use_rate)
138+
end

0 commit comments

Comments
 (0)