Skip to content

Commit

Permalink
Merge pull request #757 from LCSB-BioCore/mo-sensible-enzyme-map
Browse files Browse the repository at this point in the history
Return enzyme concentrations in useful units
  • Loading branch information
stelmo committed Feb 17, 2023
2 parents c5ac155 + f515349 commit 979d57c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/types/wrappers/EnzymeConstrainedModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ end
$(TYPEDSIGNATURES)
Get the mapping of the reaction rates in [`EnzymeConstrainedModel`](@ref) to
the original fluxes in the wrapped model
the original fluxes in the wrapped model.
"""
Accessors.reaction_variables(model::EnzymeConstrainedModel) =
Accessors.Internal.make_mapping_dict(
Expand All @@ -158,16 +158,16 @@ Accessors.reaction_variables(model::EnzymeConstrainedModel) =
"""
$(TYPEDSIGNATURES)
Get a mapping of enzyme variables to variables -- for enzyme constrained models,
this is just a direct mapping.
Get a mapping of enzyme concentration (on a mass basis, i.e. mass enzyme/mass
cell) variables to inner variables.
"""
Accessors.enzyme_variables(model::EnzymeConstrainedModel) =
Dict(gid => Dict(gid => 1.0) for gid in genes(model)) # this is enough for all the semantics to work
Dict(gid => Dict(gid => gene_product_molar_mass(model, gid)) for gid in genes(model)) # this is enough for all the semantics to work

"""
$(TYPEDSIGNATURES)
Get a mapping of enzyme groups to variables.
Get a mapping of enzyme groups to variables. See [`enzyme_variables`](@ref).
"""
function Accessors.enzyme_group_variables(model::EnzymeConstrainedModel)
enz_ids = genes(model)
Expand Down
15 changes: 11 additions & 4 deletions test/reconstruction/enzyme_constrained.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,18 @@
atol = TEST_TOLERANCE,
)

prot_mass = sum(ecoli_core_gene_product_masses[gid] * c for (gid, c) in prot_concens)
mass_groups = values_dict(:enzyme_group, gm, opt_model)

@test isapprox(prot_mass, total_gene_product_mass, atol = TEST_TOLERANCE)
@test isapprox(prot_mass, mass_groups["uncategorized"], atol = TEST_TOLERANCE)
@test isapprox(
sum(values(prot_concens)),
total_gene_product_mass,
atol = TEST_TOLERANCE,
)
@test isapprox(
sum(values(prot_concens)),
mass_groups["uncategorized"],
atol = TEST_TOLERANCE,
)

# test enzyme objective
growth_lb = rxn_fluxes["BIOMASS_Ecoli_core_w_GAM"] * 0.9
Expand Down Expand Up @@ -147,7 +154,7 @@ end
mass_groups = values_dict(:enzyme_group, gm, opt_model)

@test isapprox(rxn_fluxes["r6"], 1.1688888886502442, atol = TEST_TOLERANCE)
@test isapprox(gene_products["g4"], 0.02666666666304931, atol = TEST_TOLERANCE)
@test isapprox(gene_products["g4"], 0.02666666666304931 * 4.0, atol = TEST_TOLERANCE)
@test isapprox(mass_groups["uncategorized"], 0.5, atol = TEST_TOLERANCE)
@test isapprox(mass_groups["bound2"], 0.04, atol = TEST_TOLERANCE)
@test length(genes(gm)) == 4
Expand Down

0 comments on commit 979d57c

Please sign in to comment.