Unverified Commit ba9ee4b4 authored by St. Elmo's avatar St. Elmo
Browse files

slightly better fluxsummary

parent 9b11f0a3
Pipeline #43063 failed with stages
in 6 minutes and 58 seconds
"""
FluxVariabilitySummary
A struct used to store summary information about the
solution of a flux variability analysis result.
"""
struct FluxVariabilitySummary
biomass_fluxes :: Dict{String, Vector{Float64}}
import_fluxes :: Dict{String, Vector{Float64}}
export_fluxes :: Dict{String, Vector{Float64}}
unbounded_fluxes :: Dict{String, Vector{Float64}}
biomass_fluxes :: Dict{String, Vector{Union{Float64, Nothing}}}
exchange_fluxes :: Dict{String, Vector{Union{Float64, Nothing}}}
end
function flux_variability_summary(model::MetabolicModel,
flux_result::Tuple{Dict{String, Dict{String, Float64}}, Dict{String, Dict{String, Float64}}};
"""
flux_variability_summary(flux_result::Tuple{Dict{String, Dict{String, Float64}}, Dict{String, Dict{String, Float64}}};
exclude_exchanges = false,
exchange_prefixes = _constants.exchange_prefixes,
biomass_strings = _constants.biomass_strings,
exclude_biomass = false,
)
Return a
"""
function flux_variability_summary(flux_result::Tuple{Dict{String, Dict{String, Float64}}, Dict{String, Dict{String, Float64}}};
exclude_exchanges = false,
exchange_prefixes = _constants.exchange_prefixes,
biomass_strings = _constants.biomass_strings,
exclude_biomass = false,
small_flux_bound = 1.0/_constants.default_reaction_bound^2,
large_flux_bound = _constants.default_reaction_bound,
keep_unbounded = false,
)
rxn_ids = keys(flux_result[1])
ex_rxns = filter(x -> looks_like_exchange_reaction(x, exclude_biomass=exclude_biomass, biomass_strings=biomass_strings, exchange_prefixes=exchange_prefixes), rxn_ids)
bmasses = filter(x -> looks_like_biomass_reaction(x; exclude_exchanges=exclude_exchanges, exchange_prefixes=exchange_prefixes, biomass_strings=biomass_strings), rxn_ids)
res = Dict{String, Vector{Float64}}()
for rxn_id in rxn_ids
biomass_fluxes = Dict{String, Vector{Union{Float64, Nothing}}}()
for rxn_id in bmasses
lb = isnothing(flux_result[1][rxn_id]) ? nothing : flux_result[1][rxn_id][rxn_id]
ub = isnothing(flux_result[2][rxn_id]) ? nothing : flux_result[2][rxn_id][rxn_id]
res[rxn_id] = [lb, ub]
end
ex_rxn_fluxes = Dict{String, Vector{Union{Float64, Nothing}}}()
for rxn_id in ex_rxns
lb = isnothing(flux_result[1][rxn_id]) ? nothing : flux_result[1][rxn_id][rxn_id]
ub = isnothing(flux_result[2][rxn_id]) ? nothing : flux_result[2][rxn_id][rxn_id]
ex_rxn_fluxes[rxn_id] = [lb, ub]
end
return FluxVariabilitySummary(biomass_fluxes, ex_rxn_fluxes)
end
function Base.show(io::IO, ::MIME"text/plain", flux_res::FluxVariabilitySummary)
# for the repl
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment