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

if [ ! -f bref3.06Aug24.a91.jar ]; then
  echo
  echo "Downloading bref3.06Aug24.a91.jar"
  wget http://faculty.washington.edu/browning/beagle/bref3.06Aug24.a91.jar
fi

echo

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

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

echo
echo "*** Running test analysis with \"gt=\" argument ***"
echo
java -jar beagle.06Aug24.a91.jar gt=test.06Aug24.a91.vcf.gz out=out.gt

echo
echo "*** Running test analysis with \"ref=\" and \"gt=\" arguments ***"
echo
java -jar beagle.06Aug24.a91.jar ref=ref.06Aug24.a91.vcf.gz gt=target.06Aug24.a91.vcf.gz out=out.ref

echo
echo "*** Making \"bref3\" file ***"
echo
java -jar bref3.06Aug24.a91.jar ref.06Aug24.a91.vcf.gz > ref.06Aug24.a91.bref3

echo
echo "*** Running test analysis with \"bref3\" file ***"
echo
java -jar beagle.06Aug24.a91.jar ref=ref.06Aug24.a91.bref3 gt=target.06Aug24.a91.vcf.gz out=out.bref3

