Skip to content

Commit

Permalink
New test suite is working and takes account of round-off problems.
Browse files Browse the repository at this point in the history
Closes #247
Closes #242
  • Loading branch information
pjotrp committed Aug 25, 2021
1 parent bda453a commit b0c7f0e
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,19 @@ fast-check: all unittests
rm -vf output/*
ruby -Eutf-8 -Itest ./test/dev_tests.rb | tee ./dev_test.log

# Note the following tests are not robust for different architectures
old-check: all unittests
rm -vf test/output/*
cd test && ./dev_test_suite.sh | tee ../test.log
grep -q 'success rate: 100%' test.log

# Note the following tests are not robust for different architectures
slow-check: all
rm -vf test/output/*
cd test && ./test_suite.sh | tee ../test.log
grep -q 'success rate: 100%' test.log

# Note the following tests are not robust for different architectures
lengthy-check: all
rm -vf test/output/*
cd test && ./lengthy_test_suite.sh | tee ../lengthy_test.log
Expand Down
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and
* Documented `-lmm 9` which adds additive effect to `-lmm 2`
* Fix of GSL ERROR: function value is not finite in brent.c at line 202 errno 9, see #210
* Added profiler support in Guix profile and make file. Profiling issue #243
* Added new test suite to replace shunit2 scripts - should make it more robust for different architectures, see github issues #242 and #247.

## ChangeLog v0.98.4 (2021/01/29)

Expand Down
2 changes: 2 additions & 0 deletions test/dev_test_suite.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

echo "WARNING: THIS TEST SUITE IS NO LONGER USED"

gemma=../bin/gemma
# gemmaopts="-debug -strict"
gemmaopts="-debug -check"
Expand Down
34 changes: 27 additions & 7 deletions test/dev_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def setup
end

def test_linear_model
assert gemma("-g ./example/mouse_hs1940.geno.txt.gz \
gemma("-g ./example/mouse_hs1940.geno.txt.gz \
-p ./example/mouse_hs1940.pheno.txt \
-n 1 \
-a ./example/mouse_hs1940.anno.txt \
Expand All @@ -23,14 +23,14 @@ def test_linear_model
end

def test_BXD
assert gemma("-g ./example/BXD_geno.txt.gz \
gemma("-g ./example/BXD_geno.txt.gz \
-p ./example/BXD_pheno.txt \
-c ./example/BXD_covariates2.txt \
-a ./example/BXD_snps.txt \
-gk \
-o BXD")

assert gemma("-g ./example/BXD_geno.txt.gz \
gemma("-g ./example/BXD_geno.txt.gz \
-p ./example/BXD_pheno.txt \
-c ./example/BXD_covariates2.txt \
-a ./example/BXD_snps.txt \
Expand All @@ -39,18 +39,18 @@ def test_BXD
-o BXDLMM")

expect("output/BXDLMM.assoc.txt",[[2,9,"1.234747e-01"],
[:max,9,"9.997119e-01"]])
[:max,"p_lrt","9.997119e-01"]])
end

def test_mouse_hs1940_loco
assert gemma("-g ./example/mouse_hs1940.geno.txt.gz \
gemma("-g ./example/mouse_hs1940.geno.txt.gz \
-p ./example/mouse_hs1940.pheno.txt \
-a ./example/mouse_hs1940.anno.txt \
-snps ./example/mouse_hs1940_snps.txt \
-nind 400 -loco 1 -gk \
-o mouse_hs1940_loco")

assert gemma("-g ./example/mouse_hs1940.geno.txt.gz \
gemma("-g ./example/mouse_hs1940.geno.txt.gz \
-p ./example/mouse_hs1940.pheno.txt \
-n 1 \
-loco 1 \
Expand All @@ -61,6 +61,26 @@ def test_mouse_hs1940_loco
-nind 400 -no-check \
-o mouse_hs1940_loco")
expect("output/mouse_hs1940_loco.assoc.txt",[[2,9,"-3.073643e+02"],
[:max,11,"9.716047e-01"]])
[:max,"p_wald","9.716047e-01"]])
end

# Test for https://github.com/genetics-statistics/GEMMA/issues/58
# fixed GSLv2 NaN's that appeared with covariates.
def test_plink_covariates_lmm
gemma("-bfile example/HLC -gk 2 -o testPlinkStandardRelatednessMatrixK")

gemma("-bfile example/HLC \
-k output/testPlinkStandardRelatednessMatrixK.sXX.txt \
-lmm 1 \
-maf 0.1 \
-c example/HLC_covariates.txt \
-no-check \
-o plink_lmm1_cov")
expect("output/plink_lmm1_cov.assoc.txt",[[100,"p_wald","5.189953e-01"],
[:max,"logl_H1","279.2689"],
[:max,"l_remle","1.686062"],
[:max,"p_wald","0.9999996"]])
end


end
2 changes: 2 additions & 0 deletions test/lengthy_test_suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#
# Long running tests go here

echo "WARNING: THIS TEST SUITE IS NO LONGER USED"

gemma=../bin/gemma
export GSL_RNG_SEED=100

Expand Down
14 changes: 9 additions & 5 deletions test/lib/test-helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module TestHelpers

# Runs gemma and returns true if successful
def gemma(opts)
system("./bin/gemma #{opts}")
assert system("./bin/gemma #{opts}")
end

def read(fn, line=0)
Expand All @@ -18,11 +18,15 @@ def expect(fn, list)
lines = lines.map { |l| l.split("\t") } # avoid this for large files
list.each do | l |
line,colnum,value = l
if line == :max
cols = lines.max_by {|a| a[colnum].to_f}
else
cols = lines[line]
if colnum.is_a? String
colnum = lines[0].index(colnum)
end
cols =
if line == :max
lines.max_by {|a| a[colnum].to_f}
else
lines[line]
end
# assert_equal value,cols[colnum]
assert_in_delta value.to_f,cols[colnum].to_f, 0.001
end
Expand Down
2 changes: 2 additions & 0 deletions test/test_suite.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

echo "WARNING: THIS TEST SUITE IS NO LONGER USED"

gemma=../bin/gemma
gemmaopts="-debug"
export GSL_RNG_SEED=10
Expand Down

0 comments on commit b0c7f0e

Please sign in to comment.