#!/bin/sh -e
# http://dep.debian.net/deps/dep8/
# Autopkgtest: Test if QTLtools run analysis correctly
# Author: Dylan Aïssi <bob.dybian@gmail.com>
# Last-Update: 2016-11-16

pkg=qtltools
if [ "$AUTOPKGTEST_TMP" = "" ] ; then
  AUTOPKGTEST_TMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
fi
cd $AUTOPKGTEST_TMP
cp -a /usr/share/doc/${pkg}/examples/* $AUTOPKGTEST_TMP

tar Jxvf $AUTOPKGTEST_TMP/examples.tar.xz

# Mode PCA
QTLtools pca \
     --bed genes.50percent.chr22.bed.gz \
	 --scale \
	 --center \
	 --out genes.50percent.chr22

# Mode cis - nominal pass
QTLtools cis \
     --vcf genotypes.chr22.vcf.gz \
	 --bed genes.50percent.chr22.bed.gz \
	 --cov genes.covariates.pc50.txt.gz \
	 --nominal 0.01 \
	 --region chr22:17000000-18000000 \
	 --out nominals.txt

# Mode cis - permutations pass
QTLtools cis \
	 --vcf genotypes.chr22.vcf.gz \
	 --bed genes.50percent.chr22.bed.gz \
	 --cov genes.covariates.pc50.txt.gz \
	 --permute 1000 \
	 --region chr22:17000000-18000000 \
	 --out permutations.txt

# Mode trans - full pass
QTLtools trans \
	 --vcf genotypes.chr22.vcf.gz \
	 --bed genes.simulated.chr22.bed.gz \
	 --nominal \
	 --threshold 1e-5 \
	 --out trans.nominal

# Mode trans - approximate pass
QTLtools trans \
	 --vcf genotypes.chr22.vcf.gz \
	 --bed genes.simulated.chr22.bed.gz \
	 --sample 1000 \
	 --normal \
	 --out trans.sample

rm -f $AUTOPKGTEST_TMP/*
