Skip to content
This repository has been archived by the owner on Aug 12, 2023. It is now read-only.

Commit

Permalink
More tests and some flexibility with testing floats
Browse files Browse the repository at this point in the history
  • Loading branch information
pjotrp committed Aug 26, 2021
1 parent 2a71650 commit b6bbf33
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
25 changes: 24 additions & 1 deletion test/dev_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@ def test_BXD
-lmm 2 -no-check -maf 0.1 \
-o BXDLMM")

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

def test_mouse_hs1940_loco
assert 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 \
-p ./example/mouse_hs1940.pheno.txt \
-n 1 \
-loco 1 \
-a ./example/mouse_hs1940.anno.txt \
-k ./output/mouse_hs1940_loco.cXX.txt \
-snps ./example/mouse_hs1940_snps.txt \
-lmm \
-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"]])
end
end
12 changes: 9 additions & 3 deletions test/lib/test-helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ def read(fn, line=0)
end

def expect(fn, list)
lines = File.read(fn).split("\n") # avoid this for large files
lines = File.read(fn).split("\n")
lines = lines.map { |l| l.split("\t") } # avoid this for large files
list.each do | l |
line,colnum,value = l
cols = lines[line].chomp.split("\t")
assert_equal value,cols[colnum]
if line == :max
cols = lines.max_by {|a| a[colnum].to_f}
else
cols = lines[line]
end
# assert_equal value,cols[colnum]
assert_in_delta value.to_f,cols[colnum].to_f, 0.001
end
end
end

0 comments on commit b6bbf33

Please sign in to comment.