1#!/usr/bin/env bash
2#
3# Long running tests go here
4
5gemma=../bin/gemma
6export GSL_RNG_SEED=100
7
8testPlinkStandardRelatednessMatrixK() {
9    testname=testPlinkStandardRelatednessMatrixK
10    datadir=../example
11    outfn=output/$testname.sXX.txt
12    rm -f $outfn
13    $gemma -bfile $datadir/HLC \
14           -gk 2 -o $testname \
15           -debug
16    assertEquals 0 $?
17    assertEquals "427" `wc -l < $outfn`
18    assertEquals "-358.07" `perl -nle 'foreach $x (split(/\s+/,$_)) { $sum += sprintf("%.2f",(substr($x,,0,6))) } END { printf "%.2f",$sum }' $outfn`
19}
20
21testPlinkMultivariateLinearMixedModelMultiplePhenotypes_Issue58() {
22    echo "Long running test!"
23    # This test passes, but takes over 30 minutes to run!
24    # n=2 is original pheno in fam file
25    # n=1 is causal1
26    # n=3..12 is causal2
27    # n=13..22 is causal3
28    # -n 1 2 3 15 is independent
29    testname=testPlinkMultivariateLinearMixedModelMultiplePhenotypes
30    datadir=../example
31    $gemma -bfile $datadir/HLC \
32           -p $datadir/HLC.simu.pheno.txt \
33           -k output/testPlinkStandardRelatednessMatrixK.sXX.txt \
34           -lmm 1 \
35           -maf 0.1 \
36           -n 1 2 3 15 \
37           -c $datadir/HLC_covariates.txt \
38           -debug \
39           -o $testname
40    assertEquals 0 $?
41    outfn=output/$testname.assoc.txt
42    assertEquals "223243" `wc -l < $outfn`
43    assertEquals "89754977983.69" `perl -nle 'foreach $x (split(/\s+/,$_)) { $sum += sprintf("%.2f",(substr($x,,0,6))) } END { printf "%.2f",$sum }' $outfn`
44}
45
46shunit2=`which shunit2`
47
48if [ -x "$shunit2" ]; then
49    echo run system shunit2
50    . $shunit2
51elif [ -e ../contrib/shunit2-2.0.3/src/shell/shunit2 ]; then
52    echo run shunit2 provided in gemma repo
53    . ../contrib/shunit2-2.0.3/src/shell/shunit2
54else
55    echo "Can not find shunit2 - see INSTALL.md"
56fi
57