Skip to content

Commit 2222f90

Browse files
committed
Auto stash before merge of "structuralidentifiabilityextension" and "origin/structuralidentifiabilityextension"
1 parent e1a5811 commit 2222f90

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
## Catalyst 14.0
66
- Added CatalystStructuralIdentifiabilityExtension, which permits StructuralIdentifiability.jl function to be applied directly to Catalyst systems. E.g. use
77
```julia
8+
using Catalyst, StructuralIdentifiability
89
goodwind_oscillator = @reaction_network begin
910
(mmr(P,pₘ,1), dₘ), 0 <--> M
1011
(pₑ*M,dₑ), 0 <--> E

ext/CatalystStructuralIdentifiabilityExtension/structural_identifiability_extension.jl

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,33 @@
22

33
# For a reaction system, list of measured quantities and known parameters, generate a StructuralIdentifiability compatible ODE.
44
"""
5-
si_ode(rs::ReactionSystem; measured_quantities=observed(rs), known_p = Num[], ignore_no_measured_warn=false)
5+
make_si_ode(rs::ReactionSystem; measured_quantities=observed(rs), known_p = Num[], ignore_no_measured_warn=false)
66
77
Creates a ODE system of the form used within the StructuralIdentifiability.jl package. The output system is compatible with all StructuralIdentifiability functions.
88
99
Arguments:
1010
- `rs::ReactionSystem`; The reaction system we wish to convert to an ODE.
11-
- `measured_quantities=observed(rs)`: The quantities of the system we can measure. May either be equations (e.g. `x1 + x2`), or single species (e.g. the symbolic `x`, `rs.s`, or the symbol `:x`). Defaults to the system's observables.
11+
- `measured_quantities=[]`: The quantities of the system we can measure. May either be equations (e.g. `x1 + x2`), or single species (e.g. the symbolic `x`, `rs.s`, or the symbol `:x`). Defaults to the system's observables.
1212
- `known_p = Num[]`: List of parameters which values are known.
13-
- `ignore_no_measured_warn=false`: If set to `true`, no warning is provided when the `measured_quantities` vector is empty.
13+
- `ignore_no_measured_warn = false`: If set to `true`, no warning is provided when the `measured_quantities` vector is empty.
14+
- `remove_conserved = true`: Whether to eliminate conservation laws when computing the ode (this can reduce runtime of identifiability analysis significantly).
1415
1516
Example:
1617
```julia
18+
using Catalyst, StructuralIdentifiability
1719
rs = @reaction_network begin
1820
(p,d), 0 <--> X
1921
end
20-
si_ode(rs; measured_quantities = [:X], known_p = [:p])
22+
make_si_ode(rs; measured_quantities = [:X], known_p = [:p])
23+
```
2124
2225
Notes:
23-
This function is part of the StructuralIdentifiability.jl extension. StructuralIdentifiability.jl must be imported to access it.
26+
- This function is part of the StructuralIdentifiability.jl extension. StructuralIdentifiability.jl must be imported to access it.
27+
- `measured_quantities` and `known_p` input may also be symbolic (e.g. measured_quantities = [rs.X])
2428
```
2529
"""
2630
function Catalyst.make_si_ode(rs::ReactionSystem; measured_quantities = [], known_p = [],
27-
ignore_no_measured_warn=false, remove_conserved = true)
31+
ignore_no_measured_warn = false, remove_conserved = true)
2832
# Creates a MTK ODESystem, and a list of measured quantities (there are equations).
2933
# Gives these to SI to create an SI ode model of its preferred form.
3034
osys, conseqs, _ = make_osys(rs; remove_conserved)
@@ -111,12 +115,12 @@ function make_measured_quantities(rs::ReactionSystem, measured_quantities::Vecto
111115
# Appends the known parameters to the measured_quantities vector. Converts any Symbols to symbolics.
112116
mqiterator = Iterators.flatten((measured_quantities, known_p))
113117
mqs = [(q isa Symbol) ? Catalyst._symbol_to_var(rs, q) : q for q in mqiterator]
114-
mqs = vector_subs(measured_quantities, conseqs)
118+
mqs = vector_subs(mqs, conseqs)
115119

116120
# Creates one internal observation variable for each measured quantity (`___internal_observables`).
117121
# Creates a vector of equations, setting each measured quantity equal to one observation variable.
118-
@variables t (___internal_observables(t))[1:length(measured_quantities)]
119-
return Equation[(q isa Equation) ? q : (___internal_observables[i] ~ q) for (i,q) in enumerate(measured_quantities)]
122+
@variables t (___internal_observables(Catalyst.get_iv(rs)))[1:length(mqs)]
123+
return Equation[(q isa Equation) ? q : (___internal_observables[i] ~ q) for (i,q) in enumerate(mqs)]
120124
end
121125

122126
# Creates the functions that we wish to check for identifiability.
@@ -135,8 +139,8 @@ end
135139
function make_output(out, funcs_to_check, conseqs)
136140
funcs_to_check = vector_subs(funcs_to_check, conseqs)
137141
out = Dict(zip(vector_subs(keys(out), conseqs), values(out)))
138-
out = sort(out; by = x -> findfirst(isequal(x, ftc) for ftc in funcs_to_check))
139-
return out
142+
sortdict = Dict(ftc => i for (i,ftc) in enumerate(funcs_to_check))
143+
return sort(out; by = x -> sortdict[x])
140144
end
141145

142146
# For a vector of expressions and a conservation law, substitutes the law into every equation.

0 commit comments

Comments
 (0)