Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return enzyme concentrations in useful units #757

Merged
merged 4 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/types/wrappers/EnzymeConstrainedModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,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 @@ -188,16 +188,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