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

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

#### Jobname
#$ -N BOWT2

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

#### Resubmit
#$ -r y

#get files
folder_in=/data/projects/2018/IBD/ATAC_BCG/02_TRIM/
ff=_R1_001_trimmed.fastq.gz

for files in /data/projects/2018/IBD/ATAC_BCG/02_TRIM/*_R1_001_trimmed.fastq.gz ;
do
strstart=${#folder_in}
strl=${#files}-${#ff}-$strstart
filename=${files:$strstart:$strl} 
outfile=/data/projects/2018/IBD/ATAC_BCG/03_BOWTIE/
outfile+=$filename

bowtie2 -p 24 --no-discordant --no-unal --no-mixed -X 2000--very-sensitive -x /data/genomes/hg38/index/bowtie2/ucsc/hg38  -1 $files  -2 ${files%_R1_001_trimmed.fastq.gz}_R2_001_trimmed.fastq.gz  | samtools view -@ 24 -Sb -o ${outfile%_R1_001_trimmed.fastq.gz}.bam
done
