Skip to content

Commit

Permalink
Merge pull request LCSB-BioCore#299 from LCSB-BioCore/mo-rm-verbose-u…
Browse files Browse the repository at this point in the history
…tilities

🪓 Remove `exchange_reactions`

Former-commit-id: 75cecb4
  • Loading branch information
stelmo committed Jun 6, 2021
2 parents a936edd + 5b09ec2 commit 344aa50
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 73 deletions.
69 changes: 0 additions & 69 deletions src/base/utils/StandardModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,75 +19,6 @@ function atom_exchange(flux_dict::Dict{String,Float64}, model::StandardModel)
return atom_flux
end

"""
get_exchanges(flux_dict::Dict{String, Float64}; top_n=Inf, ignorebound=_constants.default_reaction_bound, verbose=true)
Display the `top_n` producing and consuming exchange fluxes.
If `top_n` is not specified (by an integer), then all are displayed.
Ignores infinite (problem upper/lower bound) fluxes (set with ignorebound).
When `verbose` is false, the output is not printed out.
Return these reactions (id => ) in two dictionaries: `consuming`, `producing`
"""
function exchange_reactions(
flux_dict::Dict{String,Float64},
model::StandardModel;
top_n = Inf,
ignorebound = _constants.default_reaction_bound,
verbose = true,
)
consuming = Dict{String,Float64}()
producing = Dict{String,Float64}()

for (k, v) in flux_dict
if is_boundary(model.reactions[k])
if v < 0 # consuming
consuming[k] = v
elseif v > 0 # producing
producing[k] = v
else # no flux
continue
end
end
end

if verbose
# Do consuming
ks = collect(keys(consuming))
vs = [consuming[k] for k in ks]
inds = sortperm(vs)
n_max = length(ks)
println("Consuming fluxes: ")
ii = 0 # counter
for i in inds
if vs[i] > -ignorebound
println(ks[i], " = ", round(vs[i], digits = 6))
ii += 1
end
if ii > top_n
break
end
end
# Do producing
ks = collect(keys(producing))
vs = [producing[k] for k in ks]
inds = sortperm(vs, rev = true)
n_max = length(ks)
println("Producing fluxes: ")
ii = 0 # counter
for i in inds
if vs[i] < ignorebound
println(ks[i], " = ", round(vs[i], digits = 6))
ii += 1
end
if ii > top_n
break
end
end
end

return consuming, producing
end

"""
metabolite_fluxes(flux_dict::Dict{String, Float64}, model::StandardModel)
Expand Down
4 changes: 0 additions & 4 deletions test/base/utils/StandardModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
atom_fluxes = atom_exchange(sol, model)
@test isapprox(atom_fluxes["C"], -37.1902, atol = 1e-3)

# exchange trackers
consuming, producing = exchange_reactions(sol, model; verbose = false)
@test isapprox(consuming["EX_nh4_e"], -4.76532, atol = 1e-3)

# metabolite trackers
consuming, producing = metabolite_fluxes(sol, model)
@test isapprox(consuming["atp_c"]["PFK"], -7.47738, atol = 1e-3)
Expand Down

0 comments on commit 344aa50

Please sign in to comment.