Skip to content

Commit

Permalink
bug somewhere fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
stelmo committed Feb 1, 2024
1 parent 855601e commit 3d67280
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/builders/enzymes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ $(TYPEDSIGNATURES)
Returns a constraint tree with enzyme constrained added to it. Splits reactions into forward and backward
Function inputs:
Inputs:
- `gene_ids` is a list of gene product IDs.
- `isozyme_ids` takes a reaction ID and returns `nothing` if the reaction does
not have isozymes associated with it, or an iterable container of all the
isozyme ids.
Expand All @@ -136,6 +137,7 @@ Function inputs:
function enzyme_constraints(
constraints::C.ConstraintTree;
fluxes = constraints.fluxes,
gene_ids = String[],
isozyme_ids = _ -> nothing,
kcat_forward = (_, _) -> 0.0,
kcat_reverse = (_, _) -> 0.0,
Expand All @@ -155,12 +157,15 @@ function enzyme_constraints(
# allocate variables for everything (nb. += wouldn't associate right here)
constraints =
constraints +
:fluxes_forward^unsigned_positive_contribution_variables(constraints.fluxes) +
:fluxes_reverse^unsigned_negative_contribution_variables(constraints.fluxes) +
sign_split_variables(
constraints.fluxes;
positive = :fluxes_forward,
negative = :fluxes_reverse,
) +
:isozyme_forward_amounts^isozyme_amounts +
:isozyme_reverse_amounts^isozyme_amounts +
:gene_product_amounts^C.variables(
keys = Symbol.(A.genes(model)),
keys = Symbol.(gene_ids),
bounds = C.Between(0, Inf),
)

Expand Down Expand Up @@ -190,10 +195,11 @@ function enzyme_constraints(
Symbol(id) => C.Constraint(
value = sum(
constraints.gene_product_amounts[Symbol(gp)].value *
gene_product_molar_mass[gp] for gp in gps
gene_product_molar_mass(gp) for gp in gps
),
bound = C.Between(0, limit),
) for (id, gps, limit) in capacity_limits
)
constraints
end

export enzyme_constraints
3 changes: 2 additions & 1 deletion src/frontend/enzymes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ function enzyme_constrained_flux_balance_constraints(

capacity_limits = capacity isa Real ? [("TotalCapacity", A.genes(model), capacity)] : capacity

enzyme_constraints(
c = enzyme_constraints(
flux_balance_constraints(model);
gene_ids = A.genes(model),
isozyme_ids,
kcat_forward,
kcat_reverse,
Expand Down

0 comments on commit 3d67280

Please sign in to comment.