#!/bin/bash
if [ ! -f beagle.14Jun16.dd3.jar ]; then
  echo
  echo "Downloading beagle.14Jun16.dd3.jar"
  wget http://faculty.washington.edu/browning/beagle/beagle.14Jun16.dd3.jar
fi

if [ ! -f bref.14Jun16.dd3.jar ]; then
  echo
  echo "Downloading bref.14Jun16.dd3.jar"
  wget http://faculty.washington.edu/browning/beagle/bref.14Jun16.dd3.jar
fi

echo

if [ ! -f test.14Jun16.dd3.vcf.gz ]; then
    echo
    echo "*** Downloading some 1000 Genomes Project data to file: test.14Jun16.dd3.vcf.gz ***"
    wget http://faculty.washington.edu/browning/beagle/test.14Jun16.dd3.vcf.gz
fi

echo
echo "*** Creating test files: ref.14Jun16.dd3.vcf.gz target.14Jun16.dd3.vcf.gz ***"
echo
zcat test.14Jun16.dd3.vcf.gz | cut -f1-190 | tr '/' '|' | gzip > ref.14Jun16.dd3.vcf.gz
zcat test.14Jun16.dd3.vcf.gz | cut -f1-9,191-200 | gzip > target.14Jun16.dd3.vcf.gz


echo
echo "*** Running test analysis with \"gt=\" argument ***"
echo
java -jar beagle.14Jun16.dd3.jar gt=test.14Jun16.dd3.vcf.gz out=out.gt

echo
echo "*** Running test analysis with \"gl=\" argument ***"
echo
java -jar beagle.14Jun16.dd3.jar gl=test.14Jun16.dd3.vcf.gz out=out.gl

echo
echo "*** Running test analysis with \"ref=\" argument ***"
echo
java -jar beagle.14Jun16.dd3.jar ref=ref.14Jun16.dd3.vcf.gz gt=target.14Jun16.dd3.vcf.gz out=out.ref

echo
echo "*** Making \"bref\" file ***"
echo
java -jar bref.14Jun16.dd3.jar ref.14Jun16.dd3.vcf.gz

echo
echo "*** Running test analysis with \"bref=\" argument ***"
echo
java -jar beagle.14Jun16.dd3.jar ref=ref.14Jun16.dd3.bref gt=target.14Jun16.dd3.vcf.gz out=out.bref

