#!/bin/bash
if [ ! -f beagle.24Aug19.3e8.jar ]; then
  echo
  echo "Downloading beagle.24Aug19.3e8.jar"
  wget http://faculty.washington.edu/browning/beagle/beagle.24Aug19.3e8.jar
fi

if [ ! -f bref3.24Aug19.3e8.jar ]; then
  echo
  echo "Downloading bref3.24Aug19.3e8.jar"
  wget http://faculty.washington.edu/browning/beagle/bref3.24Aug19.3e8.jar
fi

echo

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

echo
echo "*** Creating test files: ref.24Aug19.3e8.vcf.gz target.24Aug19.3e8.vcf.gz ***"
echo
zcat test.24Aug19.3e8.vcf.gz | cut -f1-190 | tr '/' '|' | gzip > ref.24Aug19.3e8.vcf.gz
zcat test.24Aug19.3e8.vcf.gz | cut -f1-9,191-200 | gzip > target.24Aug19.3e8.vcf.gz

echo
echo "*** Running test analysis with \"gt=\" argument ***"
echo
java -jar beagle.24Aug19.3e8.jar gt=test.24Aug19.3e8.vcf.gz out=out.gt

echo
echo "*** Running test analysis with \"ref=\" and \"gt=\" arguments ***"
echo
java -jar beagle.24Aug19.3e8.jar ref=ref.24Aug19.3e8.vcf.gz gt=target.24Aug19.3e8.vcf.gz out=out.ref

echo
echo "*** Making \"bref3\" file ***"
echo
java -jar bref3.24Aug19.3e8.jar ref.24Aug19.3e8.vcf.gz > ref.24Aug19.3e8.bref3

echo
echo "*** Running test analysis with \"bref3\" file ***"
echo
java -jar beagle.24Aug19.3e8.jar ref=ref.24Aug19.3e8.bref3 gt=target.24Aug19.3e8.vcf.gz out=out.bref3

