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

padding done for normal analysis

parent 877c88ed
Pipeline #43053 passed with stages
in 8 minutes and 29 seconds
......@@ -4,10 +4,10 @@ struct FluxSummary
A struct used to store information.
"""
struct FluxSummary
biomass_fluxes :: Dict{String, Float64}
import_fluxes :: Dict{String, Float64}
export_fluxes :: Dict{String, Float64}
unbounded_fluxes :: Dict{String, Float64}
biomass_fluxes :: OrderedDict{String, Float64}
import_fluxes :: OrderedDict{String, Float64}
export_fluxes :: OrderedDict{String, Float64}
unbounded_fluxes :: OrderedDict{String, Float64}
end
"""
......@@ -64,15 +64,15 @@ function flux_summary(model::MetabolicModel, flux_result::Dict{String, Float64};
if keep_unbounded
return FluxSummary(Dict(k => v for (k, v) in zip(bmasses, bmass_fluxes)),
Dict(k => v for (k, v) in zip(ex_rxns[import_fluxes], ex_fluxes[import_fluxes])),
Dict(k => v for (k, v) in zip(ex_rxns[export_fluxes], ex_fluxes[export_fluxes])),
Dict(k => v for (k, v) in zip([ex_rxns[lower_unbounded]; ex_rxns[upper_unbounded]], [ex_fluxes[lower_unbounded]; ex_fluxes[upper_unbounded]])),
OrderedDict(k => v for (k, v) in zip(ex_rxns[import_fluxes], ex_fluxes[import_fluxes])),
OrderedDict(k => v for (k, v) in zip(ex_rxns[export_fluxes], ex_fluxes[export_fluxes])),
OrderedDict(k => v for (k, v) in zip([ex_rxns[lower_unbounded]; ex_rxns[upper_unbounded]], [ex_fluxes[lower_unbounded]; ex_fluxes[upper_unbounded]])),
)
else
return FluxSummary(Dict(k => v for (k, v) in zip(bmasses, bmass_fluxes)),
Dict(k => v for (k, v) in zip(ex_rxns[import_fluxes], ex_fluxes[import_fluxes])),
Dict(k => v for (k, v) in zip(ex_rxns[export_fluxes], ex_fluxes[export_fluxes])),
Dict{String, Float64}(),
return FluxSummary(OrderedDict(k => v for (k, v) in zip(bmasses, bmass_fluxes)),
OrderedDict(k => v for (k, v) in zip(ex_rxns[import_fluxes], ex_fluxes[import_fluxes])),
OrderedDict(k => v for (k, v) in zip(ex_rxns[export_fluxes], ex_fluxes[export_fluxes])),
OrderedDict{String, Float64}(),
)
end
end
function Base.show(io::IO, ::MIME"text/plain", flux_res::FluxSummary)
c = Base.text_colors # of course I added colors :)
# println(c[:bold]*c[:light_black], "Biomass:", c[:normal]) # display all the biomass fluxes
# for (k, v) in zip(bmasses, bmass_fluxes)
# println("\t", c[:light_magenta], k, ": ", c[:normal], round(v, digits=round_digits), c[:normal])
# end
function _pad_spaces(str, maxlen)
join(repeat([" "], inner=maxlen - length(str) + 1))
end
# println(c[:bold]*c[:light_black],"Import:", c[:normal])
# for (k, v) in zip(ex_rxns[import_fluxes], ex_fluxes[import_fluxes])
# println("\t", c[:light_magenta], k, ": ", c[:normal], round(v, digits=round_digits))
# end
function Base.show(io::IO, ::MIME"text/plain", flux_res::FluxSummary)
longest_biomass_len = maximum([length(k) for k in keys(flux_res.biomass_fluxes)])
println(io, "Biomass:")
for (k, v) in flux_res.biomass_fluxes
println(io, " ", k, ":", _pad_spaces(k, longest_biomass_len), round(v, digits=4))
end
# println(c[:bold]*c[:light_black],"Export:", c[:normal])
# for (k, v) in zip(ex_rxns[export_fluxes], ex_fluxes[export_fluxes])
# println("\t", c[:light_magenta], k, ": ", c[:normal], round(v, digits=round_digits))
# end
longest_import_len = maximum([length(k) for k in keys(flux_res.import_fluxes)])
println(io, "Import:")
for (k, v) in flux_res.import_fluxes
println(io, " ", k, ":", _pad_spaces(k, longest_import_len), round(v, digits=4))
end
# println(c[:bold]*c[:light_black],"Unbounded:", c[:normal])
# for (k, v) in zip([ex_rxns[lower_unbounded]; ex_rxns[upper_unbounded]], [ex_fluxes[lower_unbounded]; ex_fluxes[upper_unbounded]])
# println("\t", c[:light_magenta], k, ": ", c[:normal], round(v, digits=round_digits))
# end
longest_export_len = maximum([length(k) for k in keys(flux_res.import_fluxes)])
println(io, "Export:")
for (k, v) in flux_res.export_fluxes
println(io, " ", k, ":", _pad_spaces(k, longest_export_len), round(v, digits=4))
end
if !isempty(flux_res.unbounded_fluxes)
longest_unbounded_len = maximum([length(k) for k in keys(flux_res.unbounded_fluxes)])
println(io, "Unbounded:")
for (k, v) in flux_res.unbounded_fluxes
println(io, " ", k, ":", _pad_spaces(k, longest_unbounded_len), round(v, digits=4))
end
end
return nothing
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