loadmodels.jl 2.34 KB
Newer Older
1
2
3

sbmlfiles = [
    # a test model from BIGG
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
4
    (
5
        joinpath(@__DIR__, "data", "e_coli_core.xml"),
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
6
7
8
9
10
        "http://bigg.ucsd.edu/static/models/e_coli_core.xml",
        "b4db506aeed0e434c1f5f1fdd35feda0dfe5d82badcfda0e9d1342335ab31116",
        72,
        95,
    ),
11
    # a relatively new non-curated model from biomodels
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
12
    (
13
        joinpath(@__DIR__, "data", "T1M1133.xml"),
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
14
15
16
17
18
        "https://www.ebi.ac.uk/biomodels/model/download/MODEL1909260004.4?filename=T1M1133.xml",
        "2b1e615558b6190c649d71052ac9e0dc1635e3ad281e541bc7d4fdf2892a5967",
        2517,
        3956,
    ),
19
    # a curated model from biomodels
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
20
    (
21
        joinpath(@__DIR__, "data", "Dasgupta2020.xml"),
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
22
23
24
25
26
        "https://www.ebi.ac.uk/biomodels/model/download/BIOMD0000000973.3?filename=Dasgupta2020.xml",
        "958b131d4df2f215dae68255433542f228601db0326d26a54efd08ddcf823489",
        2,
        6,
    ),
27
28
    # a cool model with `time` from SBML testsuite
    (
29
        joinpath(@__DIR__, "data", "sbml00852.xml"),
30
31
32
33
34
        "https://raw.githubusercontent.com/sbmlteam/sbml-test-suite/master/cases/semantic/00852/00852-sbml-l3v2.xml",
        "d013765aa358d265941420c2e3d81fcbc24b0aa4e9f39a8dc8852debd1addb60",
        4,
        3,
    ),
35
36
37
38
39
]

@testset "Loading of models from various sources" begin
    for (sbmlfile, url, hash, expected_mets, expected_rxns) in sbmlfiles
        if !isfile(sbmlfile)
40
            Downloads.download(url, sbmlfile)
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
        end

        cksum = bytes2hex(sha256(open(sbmlfile)))
        if cksum != hash
            @warn "The downloaded model `$sbmlfile' seems to be different from the expected one. Tests will likely fail." cksum
        end

        @testset "Loading of $sbmlfile" begin
            mdl = readSBML(sbmlfile)

            @test typeof(mdl) == Model

            mets, rxns, _ = getS(mdl)

            @test length(mets) == expected_mets
            @test length(rxns) == expected_rxns
        end
    end
end
60
61
62
63
64
65
66
67

@testset "Time variables in math" begin
    # this test is here mainly for keeping a magical constant that we need for
    # parsing time synced with libsbml source
    contains_time(x::SBML.MathTime) = true
    contains_time(x::SBML.MathApply) = any(contains_time.(x.args))
    contains_time(_) = false

68
    m = readSBML(joinpath(@__DIR__, "data", "sbml00852.xml"))
69
70
    @test all(contains_time.(r.kinetic_math for (_, r) in m.reactions))
end