about summary refs log tree commit diff
path: root/test/test-uvlmm-integration.scm
blob: 91eb14a7f36a731131860016e45c77d0c9a4b812 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
# -*- mode: scheme; -*-
exec guile --debug -s "$0" "$@"
!#

(define-module (test-runner)
  #:use-module (ice-9 match)
  #:use-module (srfi srfi-1)  ; for last
  #:use-module (srfi srfi-13)
  #:use-module (srfi srfi-64) ; for tests
  #:use-module (ice-9 rdelim)
  )

(define kinship-fn "./output/mouse_hs1940.cXX.txt")
(define gwa-fn "./output/mouse_hs1940.assoc.txt")

(test-begin "uvlmm-bimbam-kinship-run")

(when (file-exists? kinship-fn)
  (delete-file kinship-fn))
(let [(err (system "./build/bin/Debug/gemma -g ./example/mouse_hs1940.geno.txt.gz -gk -p ./example/mouse_hs1940.pheno.txt -o mouse_hs1940 -debug"))]
  (test-eqv 0 err))

(test-end "uvlmm-bimbam-kinship-run")


(test-begin "uvlmm-bimbam-gwa-run")

(when (file-exists? gwa-fn)
  (delete-file gwa-fn))
;; The following integration test runs gemma uvlmm and adds up the output column as a check.
;; It uses the kinship-run matrix from the earlier test
(let [(err (system (string-append "./build/bin/Debug/gemma -g ./example/mouse_hs1940.geno.txt.gz -p ./example/mouse_hs1940.pheno.txt -n 1 -a ./example/mouse_hs1940.anno.txt -k " kinship-fn " -o mouse_hs1940 -lmm 9 -debug")))]
  (test-eqv 0 err))
(call-with-input-file gwa-fn
  (lambda (port)
    (read-line port)  ; skip first line
    (let* ((fields (string-split (read-line port) #\tab))
           (last-field (last fields)))
      (test-eqv 208.0 (truncate (* 1000 (string->number last-field)))))
    (test-eqv 5720672.0
      (let loop ((line (read-line port))
                 (sum 208.0))
        (if (eof-object? line)
            sum
            (let* ((fields (string-split line #\tab))
                   (last-field (last fields))
                   (value (string->number last-field)))
              (loop (read-line port)
                    (+ sum (truncate (* 1000 value))))))))))

(test-end "uvlmm-bimbam-gwa-run")