#!/bin/bash

export myvar=`dpkg -l perl-tk  | grep perl-tk | cut -d " " -f 1`
if [ $myvar = "ii" ] ; then
	echo "Perl dependencies are OK"

else echo "No perl::TK found please install with command:
sudo apt-get install perl-tk"
exit
fi

mkdir -p ~/GAPSS_B
cd ~/GAPSS_B
wget http://grenada.lumc.nl/GAPSS/GAPSS_B.tar.gz
#wget http://ovh.dl.sourceforge.net/sourceforge/bowtie-bio/bowtie-0.9.9.3-bin-linux-x86_64.zip
wget http://ovh.dl.sourceforge.net/sourceforge/bowtie-bio/bowtie-0.10.0-bin-linux-x86_64.zip
tar xvfz GAPSS_B.tar.gz
unzip bowtie-0.10.0-bin-linux-x86_64.zip 
sed -i.orig "s/\/home\/...\/GAPSS_accessory_files\//\~\/GAPSS_B\/GAPSS_accessory_files\//g" GAPSS_B.pl
sed -i "s/\/usr\/local\/bin\/bowtie/~\/GAPSS_B\/bowtie-0.10.0\/bowtie/g" GAPSS_B.pl
cd ~/GAPSS_B/bowtie-0.10.0/indexes
tar xvfz ~/GAPSS_B/test_data/m_musculus_19_Y.tar.gz
mkdir -p ~/GAPSS_B/test_data_output
/usr/bin/perl ~/GAPSS_B/GAPSS_B.pl -c << INPUT
scarf
y
2
~/GAPSS_B/test_data/test_data1.scarf
~/GAPSS_B/test_data/test_data2.scarf
y
y
3
TCGTATGCCGTCTTCTGCTTG
1
~/GAPSS_B/bowtie-0.10.0/indexes/m_musculus_19_Y
2
y
y
y
100
$HOME/GAPSS_B/test_data_output
INPUT

cd ~/GAPSS_B/test_data_output

if [[
        -f "test_data1.scarf_F.wiggle" &&
        -f "test_data1.scarf_F.wiggle.compressed_region" &&
        -f "test_data1.scarf_R.wiggle" &&
        -f "test_data1.scarf_R.wiggle.compressed_region" &&
        -f "test_data1.scarf_SNPreport" &&
        -f "test_data2.scarf_F.wiggle" &&
        -f "test_data2.scarf_F.wiggle.compressed_region"
]];
then
        echo "GAPSS test run OK";
else echo "GAPSS test run failed";
fi





