gecko.jl 1.88 KB
Newer Older
St. Elmo's avatar
St. Elmo committed
1
@testset "GECKO" begin
St. Elmo's avatar
St. Elmo committed
2
    model = load_model(StandardModel, model_paths["e_coli_core.json"])
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

    get_reaction_isozymes =
        rid ->
            haskey(ecoli_core_reaction_kcats, rid) ?
            collect(
                Isozyme(
                    Dict(grr .=> ecoli_core_protein_stoichiometry[rid][i]),
                    ecoli_core_reaction_kcats[rid][i]...,
                ) for (i, grr) in enumerate(reaction_gene_association(model, rid))
            ) : Isozyme[]

    get_reaction_isozyme_masses =
        rid ->
            haskey(ecoli_core_protein_stoichiometry, rid) ?
            [
                sum(
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
19
20
21
                    counts .*
                    get.(Ref(ecoli_core_protein_masses), gids, 0.0),
                ) for (gids, counts) in zip(reaction_gene_association(model, rid), ecoli_core_protein_stoichiometry[rid])
22
23
24
25
26
27
28
            ] : []

    total_protein_mass = 100.0

    gm =
        model |>
        with_changed_bounds(
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
29
30
31
            ["EX_glc__D_e", "GLCpts"];
            lower = [-1000.0, -1.0],
            upper = [nothing, 12.0],
32
33
34
        ) |>
        with_gecko(
            reaction_isozymes = get_reaction_isozymes,
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
35
36
            reaction_isozyme_masses = get_reaction_isozyme_masses,
            gene_product_limit = g -> g == "b2779" ? (0.01, 0.06) : (0.0, 1.0),
37
38
            mass_fraction_limit = _ -> total_protein_mass,
        )
St. Elmo's avatar
St. Elmo committed
39
40

    opt_model = flux_balance_analysis(
St. Elmo's avatar
St. Elmo committed
41
        gm,
St. Elmo's avatar
St. Elmo committed
42
        Tulip.Optimizer;
St. Elmo's avatar
format    
St. Elmo committed
43
        modifications = [change_optimizer_attribute("IPM_IterationsLimit", 1000)],
St. Elmo's avatar
St. Elmo committed
44
45
    )

St. Elmo's avatar
St. Elmo committed
46
47
    rxn_fluxes = flux_dict(gm, opt_model)
    prot_concens = protein_dict(gm, opt_model)
St. Elmo's avatar
St. Elmo committed
48

St. Elmo's avatar
format    
St. Elmo committed
49
50
51
52
53
    @test isapprox(
        rxn_fluxes["BIOMASS_Ecoli_core_w_GAM"],
        0.812827846796761,
        atol = TEST_TOLERANCE,
    )
St. Elmo's avatar
St. Elmo committed
54

St. Elmo's avatar
St. Elmo committed
55
    prot_mass = sum(ecoli_core_protein_masses[gid] * c for (gid, c) in prot_concens)
St. Elmo's avatar
format    
St. Elmo committed
56

St. Elmo's avatar
St. Elmo committed
57
    @test isapprox(prot_mass, total_protein_mass, atol = TEST_TOLERANCE)
St. Elmo's avatar
format    
St. Elmo committed
58
end