Skip to content

Commit

Permalink
automatic formatting
Browse files Browse the repository at this point in the history
triggered by @stelmo on PR #11
  • Loading branch information
stelmo committed Feb 2, 2024
1 parent bc8193a commit 2d20619
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
16 changes: 6 additions & 10 deletions src/builders/enzymes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ function enzyme_constraints(
gene_product_molar_mass = _ -> 0.0,
capacity_limits = [],
)
# TODO: would be nice if directionally constrained
# TODO: would be nice if directionally constrained

# might be nice to omit some conditionally (e.g. slash the direction if one
# kcat is nothing)
isozyme_amounts = isozyme_amount_variables(
[rid for rid in keys(fluxes) if !isnothing(isozyme_ids(rid))],
[rid for rid in keys(fluxes) if !isnothing(isozyme_ids(rid))],
rid -> isozyme_ids(rid),
)

Expand All @@ -162,13 +162,10 @@ function enzyme_constraints(
constraints.fluxes;
positive = :fluxes_forward,
negative = :fluxes_reverse,
) +
) +
:isozyme_forward_amounts^isozyme_amounts +
:isozyme_reverse_amounts^isozyme_amounts +
:gene_product_amounts^C.variables(
keys = gene_ids,
bounds = C.Between(0, Inf),
)
:gene_product_amounts^C.variables(keys = gene_ids, bounds = C.Between(0, Inf))

# connect all parts with constraints
constraints *
Expand All @@ -195,8 +192,7 @@ function enzyme_constraints(
:gene_product_capacity^C.ConstraintTree(
Symbol(id) => C.Constraint(
value = sum(
constraints.gene_product_amounts[gp].value *
gene_product_molar_mass(gp) for gp in gps
constraints.gene_product_amounts[gp].value * gene_product_molar_mass(gp) for gp in gps
),
bound = C.Between(0, limit),
) for (id, gps, limit) in capacity_limits
Expand Down
13 changes: 10 additions & 3 deletions src/frontend/enzymes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,20 @@ function enzyme_constrained_flux_balance_constraints(
)
# these functions should not fail gracefully to prevent user footguns
# they take strings and but cts use symbols internally, hence lots of conversions are required - kind of annoying
isozyme_ids(rid) = haskey(reaction_isozymes, String(rid)) ? Symbol.(keys(reaction_isozymes[String(rid)])) : nothing
isozyme_ids(rid) =
haskey(reaction_isozymes, String(rid)) ?
Symbol.(keys(reaction_isozymes[String(rid)])) : nothing
kcat_forward(rid, iso_id) = reaction_isozymes[String(rid)][String(iso_id)].kcat_forward
kcat_reverse(rid, iso_id) = reaction_isozymes[String(rid)][String(iso_id)].kcat_reverse
isozyme_subunit_stoichiometry(rid, iso_id) = Dict(Symbol(k) => v for (k, v) in reaction_isozymes[String(rid)][String(iso_id)].gene_product_stoichiometry)
isozyme_subunit_stoichiometry(rid, iso_id) = Dict(
Symbol(k) => v for (k, v) in
reaction_isozymes[String(rid)][String(iso_id)].gene_product_stoichiometry
)
gene_product_molar_mass(gid) = gene_product_molar_masses[String(gid)]

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

enzyme_constraints(
flux_balance_constraints(model);
Expand Down

0 comments on commit 2d20619

Please sign in to comment.