#!/bin/bash -ex

bamwithoutchrm=$1
genome=$2
readsize=$3
spot=$4
hotspot_dir=$5
output=$6
tmp=$7
Nread2=5000000
hotspot_spot=$8

if [ ! -s ${bamwithoutchrm}.${Nread2}.bam ]
then
    edwBamStats -sampleBamSize=${Nread2} -u4mSize=${Nread2} -sampleBam=${bamwithoutchrm}.${Nread2}.bam ${bamwithoutchrm} tmp.ra
fi

if [ ! -s ${hotspot_spot} ]
then
    export PATH=${toolsDir}/hotspot-distr/hotspot-deploy/bin/:$PATH
    hotspot.py -o ${hotspot_dir}/hotspot-distr/ ${bamwithoutchrm}.${Nread2}.bam $genome DNase-seq $readsize $tmp $output
fi

if [ ! -s ${spot} ]
then
    cp ${hotspot_spot} ${spot}
    rm -r $tmp
fi
