From 681af4b62c32333382dc6783637b2a9ed4bc99e9 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Thu, 19 Sep 2024 13:56:32 +0200 Subject: [PATCH 1/4] document ecFVA --- .../examples/05b-enzyme-constrained-models.jl | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/docs/src/examples/05b-enzyme-constrained-models.jl b/docs/src/examples/05b-enzyme-constrained-models.jl index ddb51d5c..317cc4ec 100644 --- a/docs/src/examples/05b-enzyme-constrained-models.jl +++ b/docs/src/examples/05b-enzyme-constrained-models.jl @@ -400,3 +400,71 @@ simplified_ec_solution.gene_product_amounts simplified_ec_solution.objective, #src atol = TEST_TOLERANCE, #src ) #src + +# ## Extracting variability +# +# Enzyme-constrained variability analysis can be executed on a model by +# combining [`enzyme_constrained_flux_balance_constraints`](@ref) with +# [`constraints_variability`](@ref) (or other analysis functions): + +ec_system = enzyme_constrained_flux_balance_constraints( + model; + reaction_isozymes, + gene_product_molar_masses = ecoli_core_gene_product_masses, + capacity = total_enzyme_capacity, +) + +# Here, we do the FVA "manually", first solving the system: + +ec_optimum = optimized_values( + ec_system, + output = ec_system.objective, + objective = ec_system.objective.value, + optimizer = HiGHS.Optimizer, +) + +# ...then creating a system constrained to near-optimal growth: +import ConstraintTrees as C +ec_system *= + :optimum_bound^C.Constraint( + ec_system.objective.value, + C.Between(0.99 * ec_optimum, Inf), + ) + +# ...and finally, finding the extremes of the near-optimal part of the feasible +# space: + +ec_variabilities = + constraints_variability(ec_system, ec_system, optimizer = HiGHS.Optimizer) + +# By default, the result computes variabilities of all possible values in the +# model. (I.e., it also computes variabilities for the variable combinations +# that are present in the tree!) As usual, the results can be observed in the +# original constraint tree structure, giving us the variabilities for reaction +# fluxes: + +ec_variabilities.fluxes + +# ...as well as for gene product requirements: + +ec_variabilities.gene_product_amounts + +# ...and for the individual directional isozymes: + +ec_variabilities.isozymes_forward_amounts.PGM + +# If we do not need to compute all these values, it is often more efficient to +# only ask for the part of the output that is required: + +ec_gp_amount_variabilities = constraints_variability( + ec_system, + ec_system.gene_product_amounts, + optimizer = HiGHS.Optimizer, +) + +@test isapprox(ec_gp_amount_variabilities.b0008[1], 0, atol = TEST_TOLERANCE) #src +@test isapprox( #src + ec_gp_amount_variabilities.b0008[2], #src + 0.020956009969910837, #src + atol = TEST_TOLERANCE, #src +) #src From 5b8bcff7ff30a7bfa3582d5bb4514c5cf45dd512 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Thu, 19 Sep 2024 13:59:20 +0200 Subject: [PATCH 2/4] clean up --- docs/src/examples/05b-enzyme-constrained-models.jl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/src/examples/05b-enzyme-constrained-models.jl b/docs/src/examples/05b-enzyme-constrained-models.jl index 317cc4ec..5c2909e7 100644 --- a/docs/src/examples/05b-enzyme-constrained-models.jl +++ b/docs/src/examples/05b-enzyme-constrained-models.jl @@ -401,11 +401,12 @@ simplified_ec_solution.gene_product_amounts atol = TEST_TOLERANCE, #src ) #src -# ## Extracting variability +# ## Variability analysis with enzyme constraints # # Enzyme-constrained variability analysis can be executed on a model by -# combining [`enzyme_constrained_flux_balance_constraints`](@ref) with -# [`constraints_variability`](@ref) (or other analysis functions): +# combining [`enzyme_constrained_flux_balance_constraints`](@ref) (or +# [`simplified_enzyme_constrained_flux_balance_constraints`](@ref)) with +# [`constraints_variability`](@ref) (or any other analysis function): ec_system = enzyme_constrained_flux_balance_constraints( model; @@ -414,7 +415,7 @@ ec_system = enzyme_constrained_flux_balance_constraints( capacity = total_enzyme_capacity, ) -# Here, we do the FVA "manually", first solving the system: +# Here, we can do the FVA "manually", first solving the system: ec_optimum = optimized_values( ec_system, From 4bccebf5856790377ff9d973e594ce9630421348 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Thu, 19 Sep 2024 14:05:52 +0200 Subject: [PATCH 3/4] fix typo --- docs/src/examples/05b-enzyme-constrained-models.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/examples/05b-enzyme-constrained-models.jl b/docs/src/examples/05b-enzyme-constrained-models.jl index 5c2909e7..c6ae20ae 100644 --- a/docs/src/examples/05b-enzyme-constrained-models.jl +++ b/docs/src/examples/05b-enzyme-constrained-models.jl @@ -452,7 +452,7 @@ ec_variabilities.gene_product_amounts # ...and for the individual directional isozymes: -ec_variabilities.isozymes_forward_amounts.PGM +ec_variabilities.isozyme_forward_amounts.PGM # If we do not need to compute all these values, it is often more efficient to # only ask for the part of the output that is required: From 580617796f2ce4d309b846f3ae865c62829092ff Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Thu, 19 Sep 2024 14:09:03 +0200 Subject: [PATCH 4/4] simplify --- docs/src/examples/05b-enzyme-constrained-models.jl | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/src/examples/05b-enzyme-constrained-models.jl b/docs/src/examples/05b-enzyme-constrained-models.jl index c6ae20ae..54baacef 100644 --- a/docs/src/examples/05b-enzyme-constrained-models.jl +++ b/docs/src/examples/05b-enzyme-constrained-models.jl @@ -426,11 +426,8 @@ ec_optimum = optimized_values( # ...then creating a system constrained to near-optimal growth: import ConstraintTrees as C -ec_system *= - :optimum_bound^C.Constraint( - ec_system.objective.value, - C.Between(0.99 * ec_optimum, Inf), - ) + +ec_system.objective.bound = C.Between(0.99 * ec_optimum, Inf) # ...and finally, finding the extremes of the near-optimal part of the feasible # space: