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

#$ -pe smp 20
#$ -cwd
#$ -V

#### Jobdescription at qstat
#$ -N TRIMMO

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

#### Resubmit
#$ -r y

#get files
folder_in=/data/projects/2018/IBD/ATAC_BCG/00_RAW/

ff=.fastq.gz

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

trimmomatic PE -threads 20 $files ${files%_R1_001.fastq.gz}_R2_001.fastq.gz $outfile ${outfile%_R1_001_trimmed.fastq.gz}_R1_001_trimmed_unpaired.fastq.gz ${outfile%_R1_001_trimmed.fastq.gz}_R2_001_trimmed.fastq.gz ${outfile%_R1_001_trimmed.fastq.gz}_R2_001_trimmed_unpaired.fastq.gz ILLUMINACLIP:NexteraPE-PE.fa:2:30:10 LEADING:3 TRAILING:3 SLIDINGWINDOW:4:15 MINLEN:40

done
