Skip to content
Snippets Groups Projects
Commit 0280d037 authored by Laurent Heirendt's avatar Laurent Heirendt :airplane: Committed by GitHub
Browse files

Merge pull request #48 from LCSB-BioCore/mk-clean-downloads

clean-up downloading of files for testing
parents b2953ef6 e87cfbbe
No related branches found
No related tags found
No related merge requests found
.DS_Store
test/data/*.xml
test/data/*.mat
test/data/*.json
# ignore VScode clutter
/.vscode
......
......@@ -43,9 +43,10 @@ end
@testset "Flux balance analysis with CobraModel" begin
model = read_model(
Downloads.download(
download_data_file(
"http://bigg.ucsd.edu/static/models/e_coli_core.json",
joinpath("data", "e_coli_core.json"),
"7bedec10576cfe935b19218dc881f3fb14f890a1871448fc19a9b4ee15b448d8",
),
)
@test length(model.reactions) == 95 # read in correctly
......
......@@ -62,9 +62,10 @@ end
@testset "Flux variability analysis with CobraModel" begin
model = read_model(
Downloads.download(
download_data_file(
"http://bigg.ucsd.edu/static/models/e_coli_core.json",
joinpath("data", "e_coli_core.json"),
"7bedec10576cfe935b19218dc881f3fb14f890a1871448fc19a9b4ee15b448d8",
),
)
@test length(model.reactions) == 95 # read in correctly
......
@testset "Parsimonious flux balance analysis with CobraModel" begin
model = read_model(
Downloads.download(
download_data_file(
"http://bigg.ucsd.edu/static/models/e_coli_core.json",
joinpath("data", "e_coli_core.json"),
"7bedec10576cfe935b19218dc881f3fb14f890a1871448fc19a9b4ee15b448d8",
),
)
@test length(model.reactions) == 95 # read in correctly
biomass = findfirst(model.reactions, "BIOMASS_Ecoli_core_w_GAM")
cons = Dict("EX_glc__D_e" => (-12.0, -12.0))
# pFBA
optimizer = OSQP.Optimizer
atts = Dict(
"eps_abs" => 5e-4,
"eps_rel" => 5e-4,
......@@ -20,7 +20,7 @@
)
solworks = pfba(
model,
optimizer;
OSQP.Optimizer;
objective_func = biomass,
solver_attributes = atts,
constraints = cons,
......@@ -34,5 +34,4 @@
@test !isempty(solworks)
@test isapprox(sol["PGM"], -14.737442319041387, atol = 1e-3)
end
@testset "IO" begin
# E. coli models - realistic size models
iJO1366_xml = Downloads.download(
iJO1366_xml = download_data_file(
"http://bigg.ucsd.edu/static/models/iJO1366.xml",
joinpath("data", "iJO1366.xml"),
"d6d9ec61ef6f155db5bb2f49549119dc13b96f6098b403ef82ea4240b27232eb",
)
sbmlmodel_ecoli = read_model(iJO1366_xml)
@test_broken length(sbmlmodel_ecoli.reactions) == 2583
iJO1366_mat = Downloads.download(
iJO1366_mat = download_data_file(
"http://bigg.ucsd.edu/static/models/iJO1366.mat",
joinpath("data", "iJO1366.mat"),
"b5cfe21b6369a00e45d600b783f89521f5cc953e25ee52c5f1d0a3f83743be30",
)
matlabmodel_ecoli = read_model(iJO1366_mat)
@test length(matlabmodel_ecoli.reactions) == 2583
iJO1366_json = Downloads.download(
iJO1366_json = download_data_file(
"http://bigg.ucsd.edu/static/models/iJO1366.json",
joinpath("data", "iJO1366.json"),
"9376a93f62ad430719f23e612154dd94c67e0d7c9545ed9d17a4d0c347672313",
)
jsonmodel_ecoli = read_model(iJO1366_json)
@test length(jsonmodel_ecoli.reactions) == 2583
......
sbmlfile = joinpath("data", "ecoli_core.xml")
if !isfile(sbmlfile)
Downloads.download(
"http://systemsbiology.ucsd.edu/sites/systemsbiology.ucsd.edu/files/Attachments/Images/downloads/Ecoli_core/ecoli_core_model.xml",
sbmlfile,
)
end
cksum = bytes2hex(sha256(open(sbmlfile)))
if cksum != "78692f8509fb36534f4f9b6ade23b23552044f3ecd8b48d84d484636922ae907"
@warn "The downloaded E Coli core model seems to be different from the expected one. Tests may fail." cksum
end
download_data_file(
"http://systemsbiology.ucsd.edu/sites/systemsbiology.ucsd.edu/files/Attachments/Images/downloads/Ecoli_core/ecoli_core_model.xml",
sbmlfile,
"78692f8509fb36534f4f9b6ade23b23552044f3ecd8b48d84d484636922ae907",
)
@testset "SBML import and conversion" begin
sbmlm = load_sbml_model(sbmlfile)
......
......@@ -14,7 +14,7 @@ using OSQP
using Statistics
using JSON
using Measurements
using Downloads # need this for download(...), depr warning
using Downloads
function run_test_file(path...)
fn = joinpath(path...)
......@@ -38,6 +38,7 @@ end
function download_data_file(url, path, hash)
if isfile(path)
check_data_file_hash(path, hash)
@info "using cached `$path'"
return path
end
......
@testset "Sampling Tests" begin
# these tests are not very good - sampling needs work
model = read_model(
Downloads.download(
download_data_file(
"http://bigg.ucsd.edu/static/models/e_coli_core.json",
joinpath("data", "e_coli_core.json"),
"7bedec10576cfe935b19218dc881f3fb14f890a1871448fc19a9b4ee15b448d8",
),
)
@test length(model.reactions) == 95 # read in correctly
optimizer = Tulip.Optimizer
biomass = findfirst(model.reactions, "BIOMASS_Ecoli_core_w_GAM")
cons = Dict("EX_glc__D_e" => (-12.0, -12.0))
atts = Dict("IPM_IterationsLimit" => 110)
sol = fba(model, optimizer; objective_func = biomass, constraints = cons)
cons["BIOMASS_Ecoli_core_w_GAM"] =
(sol["BIOMASS_Ecoli_core_w_GAM"] * 0.99, sol["BIOMASS_Ecoli_core_w_GAM"])
......@@ -27,6 +28,7 @@
solver_attributes = atts,
)
# TODO
# @test isapprox(mean(samples[64, :]), 8.9, atol = 0.5) # only tests if the sampler approximately converged
# samples = achr(
......@@ -38,5 +40,4 @@
# constraints = cons,
# )
# @test isapprox(mean(samples[64, :]), 8.9, atol = 0.5) # only tests if the sampler approximately converged
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment