Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
stelmo committed Nov 27, 2021
1 parent aaf25b0 commit 043f2aa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
24 changes: 17 additions & 7 deletions src/analysis/max_min_driving_force.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ function max_min_driving_force(
rid => value(opt_model[:dgrs][i]) for (i, rid) in enumerate(reactions(model))
),
concentrations = Dict(
mid => exp(value(opt_model[:logcs][i])) for (i, mid) in enumerate(metabolites(model))
mid => exp(value(opt_model[:logcs][i])) for
(i, mid) in enumerate(metabolites(model))
),
)
end
Expand Down Expand Up @@ -227,7 +228,7 @@ function max_min_driving_force_variability(
model::MetabolicModel,
reaction_standard_gibbs_free_energies::Dict{String,Float64},
optimizer;
workers =[myid()],
workers = [myid()],
relax_driving_force = 0.9,
flux_solution::Dict{String,Float64} = Dict{String,Float64}(),
proton_ids::Vector{String} = ["h_c", "h_e"],
Expand Down Expand Up @@ -261,12 +262,21 @@ function max_min_driving_force_variability(
small_flux_tol,
modifications,
ignore_reaction_ids,
)
)

mmdf = initsol.mmdf

dgr_variants = [[[_mmdf_add_df_bound(mmdf, relax_driving_force), _mmdf_dgr_objective(ridx, sense)],] for ridx in 1:n_reactions(model), sense in [MOI.MAX_SENSE, MOI.MIN_SENSE]]
concen_variants = [[[_mmdf_add_df_bound(mmdf, relax_driving_force), _mmdf_concen_objective(midx, sense)],] for midx in 1:n_metabolites(model), sense in [MOI.MAX_SENSE, MOI.MIN_SENSE]]
dgr_variants = [
[[_mmdf_add_df_bound(mmdf, relax_driving_force), _mmdf_dgr_objective(ridx, sense)]] for ridx = 1:n_reactions(model), sense in [MOI.MAX_SENSE, MOI.MIN_SENSE]
]
concen_variants = [
[
[
_mmdf_add_df_bound(mmdf, relax_driving_force),
_mmdf_concen_objective(midx, sense),
],
] for midx = 1:n_metabolites(model), sense in [MOI.MAX_SENSE, MOI.MIN_SENSE]
]

return screen(
model;
Expand All @@ -285,7 +295,7 @@ function max_min_driving_force_variability(
T,
R,
small_flux_tol,
modifications=[modifications; args],
modifications = [modifications; args],
ignore_reaction_ids,
),
workers,
Expand Down Expand Up @@ -316,7 +326,7 @@ Helper function to add a new constraint on the driving force.
function _mmdf_add_df_bound(dg_opt, gamma)
(model, opt_model) -> begin
if gamma == 1
fix(opt_model[:mmdf], dg_opt; force=true)
fix(opt_model[:mmdf], dg_opt; force = true)
else
@constraint(opt_model, gamma * dg_opt <= opt_model[:mmdf])
end
Expand Down
18 changes: 10 additions & 8 deletions test/analysis/max_min_driving_force.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,23 @@
flux_solution = flux_solution,
proton_ids = ["h_c", "h_e"],
water_ids = ["h2o_c", "h2o_e"],
concentration_ratios = Dict{Tuple{String, String}, Float64}(
concentration_ratios = Dict{Tuple{String,String},Float64}(
("atp_c", "adp_c") => 10.0,
("nadh_c", "nad_c") => 0.13,
("nadph_c", "nadp_c") => 1.3,
),
constant_concentrations = Dict{String, Float64}(
# "pi_c" => 10e-3
constant_concentrations = Dict{String,Float64}(
# "pi_c" => 10e-3
),
concentration_lb = 1e-6,
concentration_ub = 100e-3,
ignore_reaction_ids = [
"H2Ot",
],
modifications = [change_optimizer_attribute("IPM_IterationsLimit", 1000),]
ignore_reaction_ids = ["H2Ot"],
modifications = [change_optimizer_attribute("IPM_IterationsLimit", 1000)],
)
pyk_idx = first(indexin(["PYK"], reactions(model)))
@test isapprox(sols[pyk_idx].dg_reactions["PYK"], -1.5895040002691128; atol=TEST_TOLERANCE)
@test isapprox(
sols[pyk_idx].dg_reactions["PYK"],
-1.5895040002691128;
atol = TEST_TOLERANCE,
)
end

0 comments on commit 043f2aa

Please sign in to comment.