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

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

#### Jobname
#$ -N REMM

#### Error Outputfile
#$ -e REMM.log
#$ -o REMM.err

#### Resubmit
#$ -r y


for files in /data/projects/2018/IBD/ATAC_BCG/03_BOWTIE/*_sorted.bam ;
do

samtools view -@ 24 -h $files | grep -v chrM | samtools sort -@ 24 -O bam -o ${files%_sorted.bam}_sorted_rmChrM.bam
done
