-1
#!/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?

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • How are we supposed to know what the errors are if we don't know what it's supposed to do? – Barmar Apr 15 '20 at 02:37
  • That doesn't look like Python, it looks like a shell script. – Barmar Apr 15 '20 at 02:37
  • This questions is waaay better suited to https://bioinformatics.stackexchange.com/ ; if you post on SO in future, please include a lot more information, as well as sample input/output and list the things you've tried to fix the problem. – jared_mamrot Apr 15 '20 at 02:45

1 Answers1

0

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.

jared_mamrot
  • 22,354
  • 4
  • 21
  • 46
  • Hey! So Yes you are right! I did fix these errors and it seems like it works.But now, I get the following error:./trimAll.sh: line 26: HEADCROP:0: command not found ./trimAll.sh: line 27: LEADING:20: command not found.What is this supposed to mean? – Mrinal Subash Apr 15 '20 at 04:13
  • Add a space and a backslash after "$unpairedOutPath$sampleName$rightSuffix" i.e. "$unpairedOutPath$sampleName$rightSuffix \" and add one after "ILLUMINACLIP:/usr/local/programs/Trimmomatic-0.36/adapters/TruSeq3-PE.fa:2:30:10" i.e. "ILLUMINACLIP:/usr/local/programs/Trimmomatic-0.36/adapters/TruSeq3-PE.fa:2:30:10 \" – jared_mamrot Apr 15 '20 at 04:57
  • You're welcome; please mark the question as 'answered' – jared_mamrot Apr 16 '20 at 05:31