#!/bin/sh
#$ -S /bin/sh

#$ -pe smp 24
#$ -cwd
#$ -V

#### Jobname
#$ -N MACS2

#### Error Outputfile
#$ -e MACS2.log
#$ -o MACS2.log

#### Resubmit
#$ -r y

#get files
folder_in=/data/projects/2018/IBD/ATAC_BCG/03_BOWTIE/
ff=_sorted_rmChrM_rmdupl_rmmulti_rmunpl_sorted.bam
outdir=/data/projects/2018/IBD/ATAC_BCG/04_MACS/
for files in /data/projects/2018/IBD/ATAC_BCG/03_BOWTIE/*_sorted_rmChrM_rmdupl_rmmulti_rmunpl_sorted.bam ;
do
strstart=${#folder_in}
strl=${#files}-${#ff}-$strstart
filename=${files:$strstart:$strl} 

macs2 callpeak -f BAMPE -g hs --keep-dup all --cutoff-analysis -n $filename  -t $files --outdir $outdir 2> macs2.log

done
