Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
stelmo committed Jan 29, 2024
1 parent c268cb9 commit 0302381
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
11 changes: 11 additions & 0 deletions docs/src/examples/05-enzyme-constrained-models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,14 @@ ec_solution = enzyme_constrained_flux_balance_analysis(
0.011875920383431717, #src
atol = TEST_TOLERANCE, #src
) #src

### Running a simplified enzyme constrained model

ec_solution2 = simplified_enzyme_constrained_flux_balance_analysis(
model;
reaction_isozymes,
gene_product_molar_masses,
capacity = total_enzyme_capacity,
optimizer = Tulip.Optimizer,
settings = [set_optimizer_attribute("IPM_IterationsLimit", 10_000)],
)
4 changes: 2 additions & 2 deletions src/builders/enzymes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ function add_simplified_enzyme_constraints(
sum(
stoich * gene_product_molar_masses[gid] for
(gid, stoich) in iso.gene_product_stoichiometry
) * iso.kcat_forward for iso in isos
) / iso.kcat_forward for iso in values(isos)
),
reverse = minimum(
sum(
stoich * gene_product_molar_masses[gid] for
(gid, stoich) in iso.gene_product_stoichiometry
) * iso.kcat_reverse for iso in isos
) / iso.kcat_reverse for iso in values(isos)
),
) for (rid, isos) in reaction_isozymes
)
Expand Down
49 changes: 49 additions & 0 deletions src/frontend/enzymes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ the mass of enzymes in the whole model.
enzymes". Alternatively, `capacity` may be a vector of identifier-genes-limit
triples that make a constraint (identified by the given identifier) that limits
the listed genes to the given limit.
Uses [`add_enzyme_constraints`](@ref) internally.
"""
function enzyme_constrained_flux_balance_analysis(
model::A.AbstractFBCModel;
Expand Down Expand Up @@ -56,3 +58,50 @@ function enzyme_constrained_flux_balance_analysis(
end

export enzyme_constrained_flux_balance_analysis



"""
$(TYPEDSIGNATURES)
Run a basic simplified enzyme-constrained flux balance analysis on `model`.
Requires `reaction_isozymes`, which is a mapping of reaction identifiers to
[`Isozyme`](@ref) descriptions, and `gene_product_molar_masses` which is a
mapping of gene products to their molar masses. Internally, the cheapest and
fastest isozyme (minimum of MW/kcat for each isozyme) is used in the capacity
bound.
`capacity` may be a single number, which sets the limit of protein required for
all the fluxes in `reaction_isozymes`. Alternatively, `capacity` may be a vector
of identifier-fluxes-limit triples that make a constraint (identified by the
given identifier) that limits the enzyme requirements of the listed fluxes to
the given limit.
Uses [`add_simplified_enzyme_constraints`](@ref) internally.
"""
function simplified_enzyme_constrained_flux_balance_analysis(
model::A.AbstractFBCModel;
reaction_isozymes::Dict{String,Dict{String,Isozyme}},
gene_product_molar_masses::Dict{String,Float64},
capacity::Union{Vector{Tuple{String,Vector{String},Float64}},Float64},
optimizer,
settings = [],
)
constraints = flux_balance_constraints(model)

constraints = add_simplified_enzyme_constraints(
constraints;
reaction_isozymes,
gene_product_molar_masses,
capacity,
)

optimized_constraints(
constraints;
objective = constraints.objective.value,
optimizer,
settings,
)
end

export simplified_enzyme_constrained_flux_balance_analysis

0 comments on commit 0302381

Please sign in to comment.