Skip to content

Commit

Permalink
fixup, eradicate ATPM
Browse files Browse the repository at this point in the history
  • Loading branch information
exaexa committed Sep 24, 2024
1 parent 3ce6e34 commit 20505d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
18 changes: 14 additions & 4 deletions docs/src/examples/05g-gapfilling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,23 @@ end

flux_balance_analysis(infeasible_model, optimizer = HiGHS.Optimizer) |> println

# To avoid very subtle semantic issues, we are going to remove the ATP
# maintenance pseudoreaction from the universal model:
universal_model = convert(CM.Model, model)
delete!(universal_model.reactions, "ATPM")

# ## Making the model feasible with a minimal set of reactions

# Which of the reactions we have to fill back to get the model working again?
# First, let's run [`gap_filling_analysis`](@ref) to get a solution for a
# system that implements the reaction patching:

x = gap_filling_analysis(infeasible_model, model, 0.05, optimizer = HiGHS.Optimizer)
x = gap_filling_analysis(
infeasible_model,
universal_model,
0.05,
optimizer = HiGHS.Optimizer,
)

# The reactions that had to be re-added can be found from the `fill_flags`:

Expand All @@ -83,7 +93,7 @@ filled_reactions = [k for (k, v) in x.fill_flags if v != 0]

x2 = gap_filling_analysis(
infeasible_model,
model,
universal_model,
0.05,
max_cost = 2.0,
known_fills = [x.fill_flags],
Expand Down Expand Up @@ -122,7 +132,7 @@ blocking_metabolites = [k for (k, v) in xm.fill_flags if v != 0]

@test length(blocking_metabolites) == 1 #src

# We can also have a look at how much of the metabolite was used to make the
# model feasible again:
# We can also have a look at how much of a given metabolite was used to make
# the model feasible again:

xm.universal_fluxes[first(blocking_metabolites)]
4 changes: 2 additions & 2 deletions src/frontend/gapfill.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function gap_filling_constraints(
stoichiometry = s,
universal_fluxes = u.fluxes,
universal_stoichiometry = u.flux_stoichiometry,
flux_cost = i -> universal_reaction_cost(String(first(i))),
flux_cost = i -> universal_reaction_cost(String(i)),
max_cost,
known_fills,
)
Expand Down Expand Up @@ -91,7 +91,7 @@ function gap_filling_constraints(;
:fluxes => universal_fluxes,
:stoichiometry => universal_stoichiometry,
) +
:fill_flags^C.variables_ifor(universal_fluxes) do i, _
:fill_flags^C.variables_for(universal_fluxes) do _
Switch(0, 1)
end

Expand Down

0 comments on commit 20505d4

Please sign in to comment.