Commit 0a296f34 authored by St. Elmo's avatar St. Elmo
Browse files

all tests pass

parent a76a8b07
......@@ -3,16 +3,6 @@
/vscode
*.code-workspace
# Ignore data files
*.brenda.txt
# Ignore working files
/notebooks_and_scripts/imgs
/notebooks_and_scripts/fluxes
/notebooks_and_scripts/.ipynb_checkpoints
/notebooks_and_scripts/ipynb_checkpoints
/notebooks_and_scripts/testpkg.jl
# Build artifacts for creating documentation generated by the Documenter package
docs/build/
docs/site/
......@@ -23,8 +13,5 @@ docs/site/
# environment.
Manifest.toml
# Ignore logo files
*pptx
# Ignore images
*.png
\ No newline at end of file
# Ignore temporary script for testing functions
temp.jl
\ No newline at end of file
......@@ -5,35 +5,34 @@ version = "0.1.0"
[deps]
Clp = "e2554f3b-3117-50c0-817c-e040a3ddf72d"
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
DistributedData = "f6a0035f-c5ac-4ad0-b410-ad102ced35df"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GLPK = "60bf3e95-4087-53dc-ae20-288a0d20c6a6"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
MAT = "23992714-dd62-5051-b70f-ba57cb901cac"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
OSQP = "ab2f91bb-94b4-55e3-9ba0-7f65df51de79"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
SBML = "e5567a89-2604-4b09-9718-f5f78e97c3bb"
SBML_jll = "bb12108a-f4ef-5f88-8ef3-0b33ff7017f1"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Tulip = "6dd1b50a-3aae-11e9-10b5-ef983d2400fa"
[compat]
julia = "1"
DistributedData = "0.1.3"
julia = "1"
......@@ -7,7 +7,6 @@ using LinearAlgebra
using JuMP
using MAT
using Distributed
using SBML
using DistributedData
using Requires
using JSON
......@@ -20,6 +19,7 @@ using OSQP # for QPs, but it kinda sucks
import Base: findfirst, getindex, show
import Pkg
import SBML # conflict with Reaction struct name
# import src files
include(joinpath("header", "header.jl"))
......@@ -46,8 +46,15 @@ banner = "
print(banner)
# order issue
include("base/gene.jl")
include("base/metabolite.jl")
include("base/reaction.jl")
include("base/model.jl")
include("base/solver.jl")
include("base/utilities.jl")
loadSource(["base", "io", "reconstruction", "analysis"], @__DIR__)
loadSource(["io", "reconstruction", "analysis", "sampling"], @__DIR__)
# export functions
= Metabolite("∅") # for exchange reactions
......
......@@ -37,11 +37,11 @@ function Base.show(io::IO, ::MIME"text/plain", m::CobraModel)
end
"""
Model()
CobraModel()
Empty model constructor.
"""
function Model()
function CobraModel()
CobraModel("blank", Array{Reaction,1}(), Array{Metabolite,1}(), Array{Gene,1}())
end
......
@testset "Basic analysis" begin
model = CobraTools.read_model(joinpath("data", "e_coli_core.json"))
model = read_model(download("http://bigg.ucsd.edu/static/models/e_coli_core.json", joinpath("data", "e_coli_core.json")))
@test length(model.reactions) == 95 # read in correctly
# FBA
......
......@@ -31,7 +31,7 @@
genes = [g1, g2, g3]
rxns = [r1, r2, r3, r4]
model = CobraTools.Model()
model = CobraModel()
model.id = "model"
model.reactions = rxns
model.metabolites = mets
......
......@@ -109,6 +109,4 @@
@test bal
@test isnothing(findfirst(rxns, "nope"))
end
@testset "IO" begin
# E. coli models - realistic size model
iJO1366_xml = joinpath("data", "iJO1366.xml")
sbmlmodel_ecoli = CobraTools.read_model(iJO1366_xml)
# E. coli models - realistic size models
iJO1366_xml = download("http://bigg.ucsd.edu/static/models/iJO1366.xml", joinpath("data", "iJO1366.xml"))
sbmlmodel_ecoli = read_model(iJO1366_xml)
@test_broken length(sbmlmodel_ecoli.reactions) == 2583
iJO1366_mat = joinpath("data", "iJO1366.mat")
matlabmodel_ecoli = CobraTools.read_model(iJO1366_mat)
iJO1366_mat = download("http://bigg.ucsd.edu/static/models/iJO1366.mat", joinpath("data", "iJO1366.mat"))
matlabmodel_ecoli = read_model(iJO1366_mat)
@test length(matlabmodel_ecoli.reactions) == 2583
iJO1366_json = joinpath("data", "iJO1366.json")
jsonmodel_ecoli = CobraTools.read_model(iJO1366_json)
iJO1366_json = download("http://bigg.ucsd.edu/static/models/iJO1366.json", joinpath("data", "iJO1366.json"))
jsonmodel_ecoli = read_model(iJO1366_json)
@test length(jsonmodel_ecoli.reactions) == 2583
@test model_comparison_test(jsonmodel_ecoli, matlabmodel_ecoli)
......
@testset "Construction overloading" begin
model = CobraTools.read_model(joinpath("data", "iJO1366.json"))
model = read_model(joinpath("data", "iJO1366.json"))
rxn_original = findfirst(model.reactions, "NADH16pp")
nadh = findfirst(model.metabolites, "nadh_c")
......
......@@ -26,7 +26,7 @@
rxns = [r1, r2]
model = CobraTools.Model()
model = CobraModel()
model.id = "model"
model.reactions = rxns
model.metabolites = mets
......
......@@ -9,7 +9,6 @@ using MAT
using SHA
using Distributed
using JuMP
using Tulip
using OSQP
using Statistics
......@@ -31,38 +30,15 @@ end
# load the test models
include(joinpath("data", "testModels.jl"))
# load some convenience functions for testing
include("testing_functions.jl")
# import base files
@testset "COBREXA test suite" begin
for testSet in ["base", "io", "reconstruction", "analysis"]
for testSet in ["base", "io", "reconstruction", "analysis", "sampling"]
@testset "$testSet" begin
runSuite(testSet)
end
end
end
const testdir = dirname(@__FILE__)
include("testing_functions.jl") # load some testing functions
tests = [
"base/gene_test.jl",
"base/metabolite_test.jl",
"base/model_test.jl",
"base/reaction_test.jl",
"io/io_tools_test.jl",
"construction/construction_overloading_test.jl",
"construction/model_manipulations_test.jl",
"optimization_analysis/basic_analysis_test.jl",
"sampling/sampling_tools_test.jl",
"external/brenda_tests.jl",
]
@testset "CobraTools" begin
for t in tests
tp = joinpath(testdir, t)
include(tp)
end
end
@testset "Sampling Tests" begin
model = CobraTools.read_model(joinpath("data", "e_coli_core.json"))
# these tests are not very good - sampling needs work
model = read_model(download("http://bigg.ucsd.edu/static/models/e_coli_core.json", joinpath("data", "e_coli_core.json")))
@test length(model.reactions) == 95 # read in correctly
......
......@@ -32,8 +32,8 @@ function model_comparison_test(model1, model2)
grrs_same = true
for rxn1 in model1.reactions
rxn2 = findfirst(model2.reactions, rxn1.id)
rxn1_grr_string = string(split(CobraTools.unparse_grr(rxn1.grr), "")) # use hash
rxn2_grr_string = string(split(CobraTools.unparse_grr(rxn2.grr), ""))
rxn1_grr_string = string(split(COBREXA.unparse_grr(rxn1.grr), ""))
rxn2_grr_string = string(split(COBREXA.unparse_grr(rxn2.grr), ""))
rxn1_ints = sum(Int.([x[1] for x in rxn1_grr_string]))
rxn2_ints = sum(Int.([x[1] for x in rxn2_grr_string]))
if rxn1_ints != rxn2_ints
......@@ -51,18 +51,9 @@ Test if model is the same after it was read in, saved, and then re-read.
function read_write_read_test(model, format)
tmpfile = joinpath("data", "temp." * format)
CobraTools.save_model(model, tmpfile)
tmpmodel = CobraTools.read_model(tmpfile)
save_model(model, tmpfile)
tmpmodel = read_model(tmpfile)
rm(tmpfile)
model_comparison_test(model, tmpmodel)
end
# function atom_test(model)
# biomass_rxn = findfirst(model.rxns, "BIOMASS_Ec_iJO1366_WT_53p95M")
# pfbasol = CobraTools.pfba(model, biomass_rxn)
# ad = CobraTools.atom_exchange(pfbasol)
# return ad["C"]/ad["H"] ≈ 0.6362486422376349
# end
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment