#! /bin/bash

input=$1
output=$2
wigmaker=$3

inputfile=`basename $input`
dir=`dirname $input`

cd $dir
rm $dir/wigs_for_*.wig.gz > /dev/null 2>&1
rm $dir/wigs_for_*.wig > /dev/null 2>&1

prefix=`echo $input | perl -ne '(\$prefix) = \$_ =~ /(dataset_[0-9]+)/; print \$prefix'`

java -Djava.io.tmpdir=/tmp -Xmx2G -jar $wigmaker $inputfile

cp $dir/wigs_for_$prefix.wig $output
rm $dir/wigs_for_$prefix.wig
rm $dir/wigs_for_$prefix.wig.gz

