#!/bin/bash

shopt -s extglob; 
#turns on extended globbing features ('!' can then be used to exclude file names)

#entering SCRATCHDIR used for computation on Metacentrum nodes
cd $SCRATCHDIR;

#copying input files
cp -r /storage/brno2/home/nicki/linkyx/* . 

#logfile
echo "Copying of the input data finished." `date` >/storage/brno2/home/nicki/linkyx/log;

#adding needed modules
module add trinity;
module add bwa-0.6.2;
module add bowtie-0.12.8;
module add ics.muni.cz jdk-1.6.0; #initialization of the specific JAVA version
module add samtools-0.1.18alt #samtools recompiled with -fPIC parameter
module add picard-1.80;
module add fastx-0.0.13;

#export of perl modules
export PERL5LIB=/storage/brno2/home/nicki/modules/File-Slurp-9999.19/lib:/storage/brno2/home/nicki/modules/Bio-SamTools-1.37/lib:/storage/brno2/home/nicki/modules/BioPerl-1.6.901:/storage/brno2/home/nicki/modules/Data-Dumper-2.139:/storage/brno2/home/nicki/modules/libwww-perl-6.04/lib:/storage/brno2/home/nicki/modules/URI-1.60:/storage/brno2/home/nicki/modules/UUID-Generator-PurePerl-0.04_02/lib:/storage/brno2/home/nicki/modules/UUID-Object-0.81:/storage/brno2/home/nicki/modules/UUID-Generator-PurePerl-0.04_02/lib/UUID/:Generator:/storage/brno2/home/nicki/modules/UUID-Object-0.81/lib:/home/nicki/lib:/storage/brno2/home/nicki/modules/bio_samtools_bin/local/lib/perl/5.10.0:/home/nicki/lib/x86_64-linux-gnu-thread-multi:/home/nicki/lib/man:/storage/brno2/home/nicki/modules/Data-GUID-0.046/lib:/home/nicki/perl/lib/perl5:/home/nicki/perl/lib/perl:/home/nicki/perl/share/perl:/home/nicki/perl/share/perl5:/home/nicki/lib/lib/perl5:/home/nicki/lib/lib/perl:/home/nicki/lib/share/perl:/home/nicki/lib/share/perl5:/home/nicki/lib/perl5/:/home/nicki/lib/perl5/site_perl:;

#execution of the linkYX pipeline
./runLinkYX.sh michalovova.monika@gmail.com misa

echo "Copying of the output data started." `date` >>/storage/brno2/home/nicki/linkyx/log;

#copying output files
cp -ar * /storage/brno2/home/nicki/linkyx_out;
#cleaning
rm -rf $SCRATCHDIR
trap "rm -rf $SCRATCHDIR" SIGTERM

