aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPjotr Prins2021-08-24 12:45:38 +0200
committerPjotr Prins2021-08-24 12:45:38 +0200
commite18913d175cf1f21b1a8393e45c188342370b160 (patch)
treea815ed96a35f25f9fa5859bb98e0ac46f308f254 /test
parent71553f5e5626e1d791b5be24c84ea6b17ae81cc7 (diff)
downloadpangemma-e18913d175cf1f21b1a8393e45c188342370b160.tar.gz
Tests: started to replace the test system - moving from shell scripts to Ruby tests
Diffstat (limited to 'test')
-rw-r--r--test/dev_tests.rb25
-rw-r--r--test/lib/test-helpers.rb24
2 files changed, 49 insertions, 0 deletions
diff --git a/test/dev_tests.rb b/test/dev_tests.rb
new file mode 100644
index 0000000..8ce8dbc
--- /dev/null
+++ b/test/dev_tests.rb
@@ -0,0 +1,25 @@
+
+require 'minitest/autorun'
+require 'lib/test-helpers'
+
+class TestQuick < MiniTest::Test
+
+ include TestHelpers
+
+ def setup
+ end
+
+ def test_linear_model
+ assert gemma("-g ./example/mouse_hs1940.geno.txt.gz \
+ -p ./example/mouse_hs1940.pheno.txt \
+ -n 1 \
+ -a ./example/mouse_hs1940.anno.txt \
+ -lm \
+ -o mouse_hs1940_CD8_lm")
+
+ expect('output/mouse_hs1940_CD8_lm.assoc.txt',[[2,1,"rs3707673"],
+ [2,10,"5.252187e-05"],
+ [3,9,"3.909916e-02"]])
+ end
+
+end
diff --git a/test/lib/test-helpers.rb b/test/lib/test-helpers.rb
new file mode 100644
index 0000000..72b9cd9
--- /dev/null
+++ b/test/lib/test-helpers.rb
@@ -0,0 +1,24 @@
+module TestHelpers
+
+ # Runs gemma and returns true if successful
+ def gemma(opts)
+ system("./bin/gemma #{opts}")
+ end
+
+ def read(fn, line=0)
+ count = 0
+ File.open(fn, "r:utf-8").each_line { |ln|
+ return ln.chomp.split("\t") if count == line
+ count += 1
+ }
+ end
+
+ def expect(fn, list)
+ lines = File.read(fn).split("\n") # avoid this for large files
+ list.each do | l |
+ line,colnum,value = l
+ cols = lines[line].chomp.split("\t")
+ assert_equal value,cols[colnum]
+ end
+ end
+end