screening.jl 1.63 KB
Newer Older
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
1
2

@testset "Screening functions" begin
3
    m = test_toyModel()
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
4
5
6
7

    # nothing to analyze
    @test_throws DomainError screen(m; analysis = identity)

8
9
    # array dimensionalities must match
    @test_throws DomainError screen(
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
        m;
        analysis = identity,
        variants = [[], []],
        args = [() ()],
    )

    # sizes must match
    @test_throws DomainError screen(
        m;
        analysis = identity,
        variants = [[], []],
        args = [()],
    )

    # argument handling
    @test screen(m, analysis = identity, variants = [[]]) == [m]
    @test screen(m, analysis = identity, args = [()]) == [m]
    @test screen(m, analysis = (a, b) -> b, args = [(1,), (2,)]) == [1, 2]

    # test modifying some reactions
    quad_rxn(i) = (m::CoreModel) -> begin
        mm = copy(m)
        mm.S = copy(m.S)
        mm.S[:, i] .^= 2
        return mm
    end

    @test screen_variants(
        m,
        [[quad_rxn(i)] for i = 1:3],
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
40
        m -> flux_balance_analysis_vec(m, Tulip.Optimizer);
41
        workers = W,
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
    ) == [
        [250.0, -250.0, -1000.0, 250.0, 1000.0, 250.0, 250.0],
        [500.0, 500.0, 1000.0, 500.0, -1000.0, 500.0, 500.0],
        [500.0, 500.0, 1000.0, -500.0, 1000.0, 500.0, 500.0],
    ]

    # test solver modifications
    @test screen(
        m;
        analysis = (m, sense) -> flux_balance_analysis_vec(
            m,
            Tulip.Optimizer;
            modifications = [change_sense(sense)],
        ),
        args = [(MIN_SENSE,), (MAX_SENSE,)],
    ) == [
        [-500.0, -500.0, -1000.0, 500.0, 1000.0, -500.0, -500.0],
        [500.0, 500.0, 1000.0, -500.0, -1000.0, 500.0, 500.0],
    ]
end