#!/usr/bin/env python3
# trimAll.py
#Initialize variable to contain the directory of un-trimmed fastq files
fastqPath="/scratch/AiptasiaMiSeq/fastq/"
#Initialize variable to contain the suffix for the left reads
leftSuffix=".R1.fastq"
rightSuffix=".R2.fastq"
pairedOutPath="Paired/"
unpairedOutPath="Unpaired/"
#Loop through all the left-read fastq files in $fastqPath
for leftInFile in $fastqPath*$leftSuffix
do
#Remove the path from the filename and assign to pathRemoved
pathRemoved="${leftInFile/$fastqPath/}"
#Remove the left-read suffix from $pathRemoved and assign to suffixRemoved
sampleName="${pathRemoved/$leftSuffix/}"
nice -n19 java -jar /usr/local/programs/Trimmomatic-0.36/trimmomatic-0.36.jar PE \
-threads 1 -phred33 \
$fastqPath$sampleName$leftSuffix \
$fastqPath$sampleName$rightSuffix \
$pairedOutPath$sampleName$leftSuffix \
$unpairedOutPath$sampleName$leftsuffix \
$pairedOutPath$sampleName$rightSuffix \
$unpairedOutPath$sampleName$rightSuffix
HEADCROP:0 \
ILLUMINACLIP:/usr/local/programs/Trimmomatic-0.36/adapters/TruSeq3-PE.fa:2:30:10
LEADING:20 TRAILING:20 SLIDINGWINDOW:4:30 MINLEN:36
done
Basically, the code is a Python Script and I am trying to find an error.What is the error in this piece of code?
Trimmomatic in 'PE' mode expects forward ("left") and reverse ("right") reads; this for loop is only looking at left reads ('$fastqPath*$leftSuffix') so it will fail. If you replace for leftInFile in $fastqPath*$leftSuffix
with for leftInFile in $fastqPath*.fastq
it should work as expected. Also, this looks to be a shell script, not a python script, so change your shebang to #!/bin/bash
. Also, your trimming parameters are fairly strict (e.g. see https://www.frontiersin.org/articles/10.3389/fgene.2014.00013/full) - you may want to consider easing them off a bit, depending on your application.