Skip to content

Commit

Permalink
MTK itnernal remake, causes problems though
Browse files Browse the repository at this point in the history
  • Loading branch information
TorkelE committed Nov 14, 2023
1 parent 5d45e68 commit 258c759
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ si_ode(rs; measured_quantities = [:X], known_p = [:p])
```
"""
function Catalyst.make_si_ode(rs::ReactionSystem; measured_quantities = [], known_p = [], ignore_no_measured_warn=false)
ignore_no_measured_warn || isempty(measured_quantities) && @warn "No measured quantity provided to the `measured_quantities` argument, any further identifiability analysis will likely fail. You can disable this warning by setting `ignore_no_measured_warn=true`."
known_quantities = make_measured_quantities(rs, measured_quantities, known_p)
known_quantities = make_measured_quantities(rs, measured_quantities, known_p; ignore_no_measured_warn)
return StructuralIdentifiability.preprocess_ode(convert(ODESystem, rs; expand_functions = true), known_quantities)[1]

Check warning on line 25 in ext/CatalystStructuralIdentifiabilityExtension/structural_identifiability_extension.jl

View check run for this annotation

Codecov / codecov/patch

ext/CatalystStructuralIdentifiabilityExtension/structural_identifiability_extension.jl#L23-L25

Added lines #L23 - L25 were not covered by tests
end

# For input measured quantities, if this is not a vector of equations, convert it to a proper form.
function make_measured_quantities(rs::ReactionSystem, measured_quantities::Vector{T}, known_p::Vector{S}) where {T,S}
function make_measured_quantities(rs::ReactionSystem, measured_quantities::Vector{T}, known_p::Vector{S}; ignore_no_measured_warn=false) where {T,S}
ignore_no_measured_warn || isempty(measured_quantities) && @warn "No measured quantity provided to the `measured_quantities` argument, any further identifiability analysis will likely fail. You can disable this warning by setting `ignore_no_measured_warn=true`."
all_quantities = [measured_quantities; known_p]
all_quantities = [(quant isa Symbol) ? Catalyst._symbol_to_var(rs, quant) : quant for quant in all_quantities]
@variables t (___internal_observables(t))[1:length(all_quantities)]
Expand All @@ -37,17 +37,23 @@ end
### Structural Identifiability Wrappers ###

# Local identifiability.
function StructuralIdentifiability.assess_local_identifiability(rs::ReactionSystem, args...; measured_quantities = Num[], known_p = Num[], kwargs...)
return StructuralIdentifiability.assess_local_identifiability(Catalyst.make_si_ode(rs; measured_quantities, known_p), args...; kwargs...)
function StructuralIdentifiability.assess_local_identifiability(rs::ReactionSystem, args...; measured_quantities = Num[], known_p = Num[], ignore_no_measured_warn=false, kwargs...)
known_quantities = make_measured_quantities(rs, measured_quantities, known_p; ignore_no_measured_warn)
osys = convert(ODESystem, rs; expand_functions = true)
return StructuralIdentifiability.assess_local_identifiability(osys, args...; measured_quantities=known_quantities, kwargs...)

Check warning on line 43 in ext/CatalystStructuralIdentifiabilityExtension/structural_identifiability_extension.jl

View check run for this annotation

Codecov / codecov/patch

ext/CatalystStructuralIdentifiabilityExtension/structural_identifiability_extension.jl#L40-L43

Added lines #L40 - L43 were not covered by tests
end

# Global identifiability.
function StructuralIdentifiability.assess_identifiability(rs::ReactionSystem, args...; measured_quantities = Num[], known_p = Num[], kwargs...)
return StructuralIdentifiability.assess_identifiability(Catalyst.make_si_ode(rs; measured_quantities, known_p), args...; kwargs...)
function StructuralIdentifiability.assess_identifiability(rs::ReactionSystem, args...; measured_quantities = Num[], known_p = Num[], ignore_no_measured_warn=false, kwargs...)
known_quantities = make_measured_quantities(rs, measured_quantities, known_p; ignore_no_measured_warn)
osys = convert(ODESystem, rs; expand_functions = true)
return StructuralIdentifiability.assess_identifiability(osys, args...; measured_quantities=known_quantities, kwargs...)

Check warning on line 50 in ext/CatalystStructuralIdentifiabilityExtension/structural_identifiability_extension.jl

View check run for this annotation

Codecov / codecov/patch

ext/CatalystStructuralIdentifiabilityExtension/structural_identifiability_extension.jl#L47-L50

Added lines #L47 - L50 were not covered by tests
end

# Identifiable functions.
function StructuralIdentifiability.find_identifiable_functions(rs::ReactionSystem, args...; measured_quantities = Num[], known_p = Num[], kwargs...)
return StructuralIdentifiability.find_identifiable_functions(Catalyst.make_si_ode(rs; measured_quantities, known_p), args...; kwargs...)
function StructuralIdentifiability.find_identifiable_functions(rs::ReactionSystem, args...; measured_quantities = Num[], known_p = Num[], ignore_no_measured_warn=false, kwargs...)
known_quantities = make_measured_quantities(rs, measured_quantities, known_p; ignore_no_measured_warn)
osys = convert(ODESystem, rs; expand_functions = true)
return StructuralIdentifiability.find_identifiable_functions(osys, args...; measured_quantities=known_quantities, kwargs...)

Check warning on line 57 in ext/CatalystStructuralIdentifiabilityExtension/structural_identifiability_extension.jl

View check run for this annotation

Codecov / codecov/patch

ext/CatalystStructuralIdentifiabilityExtension/structural_identifiability_extension.jl#L54-L57

Added lines #L54 - L57 were not covered by tests
end

0 comments on commit 258c759

Please sign in to comment.