diff --git a/src/builders/enzymes.jl b/src/builders/enzymes.jl index d5a24373..db334509 100644 --- a/src/builders/enzymes.jl +++ b/src/builders/enzymes.jl @@ -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. @@ -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, @@ -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), ) @@ -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 diff --git a/src/frontend/enzymes.jl b/src/frontend/enzymes.jl index 3c4f1c5d..18ea86b5 100644 --- a/src/frontend/enzymes.jl +++ b/src/frontend/enzymes.jl @@ -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,