Unverified Commit 71ddd791 authored by Laurent Heirendt's avatar Laurent Heirendt Committed by GitHub
Browse files

Merge pull request #3 from LCSB-BioCore/tests

tests
parents 613d70c7 591a1ece
name: CI
on:
push:
branches:
- master
- develop
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@latest
- run: |
git config --global user.name Tester
git config --global user.email te@st.er
- uses: julia-actions/julia-runtest@latest
continue-on-error: ${{ matrix.version == 'nightly' }}
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
name = "SBML" name = "SBML"
uuid = "e5567a89-2604-4b09-9718-f5f78e97c3bb" uuid = "e5567a89-2604-4b09-9718-f5f78e97c3bb"
authors = ["Mirek Kratochvil <miroslav.kratochvil@uni.lu>", authors = ["Mirek Kratochvil <miroslav.kratochvil@uni.lu>", "LCSB R3 team <lcsb-r3@uni.lu>"]
"LCSB R3 team <lcsb-r3@uni.lu>"]
version = "0.1.0" version = "0.1.0"
[deps] [deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
SBML_jll = "bb12108a-f4ef-5f88-8ef3-0b33ff7017f1" SBML_jll = "bb12108a-f4ef-5f88-8ef3-0b33ff7017f1"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
...@@ -11,13 +11,11 @@ function readSBML(fn::String)::Model ...@@ -11,13 +11,11 @@ function readSBML(fn::String)::Model
try try
n_errs = ccall(sbml(:SBMLDocument_getNumErrors), Cuint, (VPtr,), doc) n_errs = ccall(sbml(:SBMLDocument_getNumErrors), Cuint, (VPtr,), doc)
if n_errs > 0 if n_errs > 0
@error "SBML loading failed" throw(SystemError("Opening SBML document has failed"))
throw(:IOError)
end end
if 0 == ccall(sbml(:SBMLDocument_isSetModel), Cint, (VPtr,), doc) if 0 == ccall(sbml(:SBMLDocument_isSetModel), Cint, (VPtr,), doc)
@error "SBML document does not contain a model" throw(AssertionError("SBML document contains no model"))
throw(:ValueError)
end end
model = ccall(sbml(:SBMLDocument_getModel), VPtr, (VPtr,), doc) model = ccall(sbml(:SBMLDocument_getModel), VPtr, (VPtr,), doc)
......
sbmlfile = "EColi.xml"
if !isfile(sbmlfile)
download("https://systemsbiology.ucsd.edu/sites/systemsbiology.ucsd.edu/files/Attachments/Images/InSilicoOrganisms/Ecoli/Ecoli_SBML/Ec_core_flux1.xml", sbmlfile)
end
if bytes2hex(sha256(sbmlfile)) != "e3d18499660a0f7fc15a5a44f33f001c7881ac99a2e8a6a461edf1cf3d69a537"
@warn "The downloaded E Coli core flux model seems to be different from the expected one. Tests will likely fail."
end
@testset "SBML model loading" begin
mdl = readSBML(sbmlfile)
@test typeof(mdl) == Model
@test_throws SystemError readSBML(sbmlfile * ".does.not.really.exist")
@test length(mdl.compartments) == 2
mets, rxns, S = getS(mdl)
@test length(mets) == 77
@test length(rxns) == 77
@test size(S) == (length(mets),length(rxns))
# totally arbitrary value tests
@test isapprox(sum(S), 42.1479)
@test mets[10:12] == ["M_akg_e", "M_fum_c", "M_pyr_c"]
@test rxns[10:12] == ["R_H2Ot", "R_PGL", "R_EX_glc_e_"]
lbs = getLBs(mdl)
ubs = getUBs(mdl)
ocs = getOCs(mdl)
@test length(ocs) == length(mets)
@test ocs[40] == 1.0
deleteat!(ocs, 40)
@test all(ocs .== 0.0)
@test length(getLBs(mdl)) == length(rxns)
@test length(getUBs(mdl)) == length(rxns)
getunit = (val,unit)::Tuple -> unit
@test all([broadcast(getunit, lbs) broadcast(getunit, ubs)] .== "mmol_per_gDW_per_hr")
getval = (val,unit)::Tuple -> val
lvals = broadcast(getval, lbs)
uvals = broadcast(getval, ubs)
@test isapprox(lvals[27], uvals[27])
@test isapprox(lvals[27], 7.6)
@test isapprox(lvals[12], -10)
@test count(isapprox.(lvals, -999999)) == 40
@test count(isapprox.(lvals, 0)) == 35
@test count(isapprox.(uvals, 999999)) == 76
end
using Test, SHA
using SBML
import Pkg
@testset "SBML test suite" begin
include("version.jl")
include("loadEColi.jl")
end
@testset "CCall to SBML works and SBML returns a version" begin
@test typeof(SBMLVersion())==Pkg.VersionNumber
end
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