looks_like.jl 3.05 KB
Newer Older
St. Elmo's avatar
St. Elmo committed
1
@testset "Looks like in CoreModel, detailed test" begin
St. Elmo's avatar
St. Elmo committed
2
    cp = test_LP()
St. Elmo's avatar
St. Elmo committed
3
    @test isempty(filter(looks_like_exchange_reaction, reactions(cp)))
St. Elmo's avatar
St. Elmo committed
4
5

    cp = test_simpleLP()
St. Elmo's avatar
St. Elmo committed
6
    @test isempty(filter(looks_like_exchange_reaction, reactions(cp)))
St. Elmo's avatar
St. Elmo committed
7
8
9
10
11
12
13
14
15
16

    cp = CoreModel(
        [-1.0 -1 -2; 0 -1 0; 0 0 0],
        zeros(3),
        ones(3),
        ones(3),
        ones(3),
        ["EX_m1"; "r2"; "r3"],
        ["m1"; "m2"; "m3"],
    )
St. Elmo's avatar
St. Elmo committed
17
    @test filter(looks_like_exchange_reaction, reactions(cp)) == ["EX_m1"]
St. Elmo's avatar
St. Elmo committed
18
19
20
21
22
23
24
25

    cp = CoreModel(
        [-1.0 0 0; 0 0 -1; 0 -1 0],
        zeros(3),
        ones(3),
        ones(3),
        ones(3),
        ["EX_m1"; "Exch_m3"; "Ex_m2"],
St. Elmo's avatar
St. Elmo committed
26
        ["m1"; "m2"; "m3_e"],
St. Elmo's avatar
St. Elmo committed
27
    )
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
28
29
30
31
32
33
    @test filter(looks_like_exchange_reaction, reactions(cp)) ==
          ["EX_m1", "Exch_m3", "Ex_m2"]
    @test filter(
        x -> looks_like_exchange_reaction(x; exchange_prefixes = ["Exch_"]),
        reactions(cp),
    ) == ["Exch_m3"]
St. Elmo's avatar
St. Elmo committed
34
35
36
37

    # this is originally the "toyModel1.mat"
    cp = test_toyModel()

Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
38
39
40
41
42
43
    @test filter(looks_like_exchange_reaction, reactions(cp)) ==
          ["EX_m1(e)", "EX_m3(e)", "EX_biomass(e)"]
    @test filter(
        x -> looks_like_exchange_reaction(x; exclude_biomass = true),
        reactions(cp),
    ) == ["EX_m1(e)", "EX_m3(e)"]
St. Elmo's avatar
St. Elmo committed
44
    @test filter(looks_like_exchange_metabolite, metabolites(cp)) == ["m1[e]", "m3[e]"]
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
45
46
47
48
49
50
    @test filter(looks_like_biomass_reaction, reactions(cp)) ==
          ["EX_biomass(e)", "biomass1"]
    @test filter(
        x -> looks_like_biomass_reaction(x; exclude_exchanges = true),
        reactions(cp),
    ) == ["biomass1"]
St. Elmo's avatar
St. Elmo committed
51
52
end

St. Elmo's avatar
St. Elmo committed
53
@testset "Looks like functions, basic" begin
St. Elmo's avatar
St. Elmo committed
54
    model = load_model(model_paths["e_coli_core.json"])
St. Elmo's avatar
St. Elmo committed
55
56
57
    @test length(filter(looks_like_exchange_reaction, reactions(model))) == 20
    @test length(filter(looks_like_exchange_metabolite, metabolites(model))) == 20
    @test length(filter(looks_like_biomass_reaction, reactions(model))) == 1
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
58

59
    model = load_model(model_paths["e_coli_core.xml"])
St. Elmo's avatar
St. Elmo committed
60
61
62
    @test length(filter(looks_like_exchange_reaction, reactions(model))) == 20
    @test length(filter(looks_like_exchange_metabolite, metabolites(model))) == 20
    @test length(filter(looks_like_biomass_reaction, reactions(model))) == 1
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
63

St. Elmo's avatar
St. Elmo committed
64
    model = load_model(model_paths["e_coli_core.mat"])
St. Elmo's avatar
St. Elmo committed
65
66
67
    @test length(filter(looks_like_exchange_reaction, reactions(model))) == 20
    @test length(filter(looks_like_exchange_metabolite, metabolites(model))) == 20
    @test length(filter(looks_like_biomass_reaction, reactions(model))) == 1
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
68

St. Elmo's avatar
St. Elmo committed
69
    model = convert(StandardModel, model)
St. Elmo's avatar
St. Elmo committed
70
71
72
    @test length(filter(looks_like_exchange_reaction, reactions(model))) == 20
    @test length(filter(looks_like_exchange_metabolite, metabolites(model))) == 20
    @test length(filter(looks_like_biomass_reaction, reactions(model))) == 1
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
73

St. Elmo's avatar
St. Elmo committed
74
    model = convert(CoreModelCoupled, model)
St. Elmo's avatar
St. Elmo committed
75
76
77
    @test length(filter(looks_like_exchange_reaction, reactions(model))) == 20
    @test length(filter(looks_like_exchange_metabolite, metabolites(model))) == 20
    @test length(filter(looks_like_biomass_reaction, reactions(model))) == 1
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
78

St. Elmo's avatar
St. Elmo committed
79
end