Thanks! Worked like a charm!
Hi,
I sequenced some gut-samples for microbial communities (16S, paired-end, Illumina MiSeq, fastq).
e.g. Sample1_read1.fq Sample1_read2.fq Sample2_read1.fq Sample2_read2.fq ...etc
I am following the Mothur SOP, however, due to the partially bad read quality, I incorporated a quality filtering step before aligning the reads. Therefore, I use a tool from the BBDuk package
bbduk.sh -Xmx1g in1=Sample1_read1.fq in2=Sample1_read2 out1=Sample1_clean_read1.fq out2=Sample1_clean_read2 qtrim=rl trimq=10
Everything works fine, but now I'd like to run everything in one batch. How can I create a loop so the bbduk.sh goes through all the files in my folder (and always takes read1 and read2 of the same sample)?
Thanks a lot for your help in advance! (And let me know if I missed some vital information)
1 answer
There can be many variations of this (and each one would get the job done).
for i in `ls -1 *_read1.fq | sed 's/_read1.fq//'`
do
bbduk.sh -Xmx1g in1=$i\_read1.fq in2=$i\_read2 out1=$i\_clean_read1.fq out2=$i\_clean_read2 qtrim=rl trimq=10
done
If you are using a job scheduler on a cluster wrap necessary bits around the bbduk command to submit individual jobs to scheduler.
my files are as such
SRR2753090_1.fastq SRR2753090_2.fastq
managed to do it..
just for my clarification this is what im using
for i in `ls -1 *_1.fastq | sed 's/_1.fastq//'`
do
bbduk.sh -Xmx1g in1=$i\_1.fastq in2=$i\_2.fastq out1=$i\_clean_1.fastq out2=$i\_clean_2.fastq ref=/src/bbmap/resources/adapters.fa
done
I hope the loop is correct ..
Log in to answer this question.
Use these for inspiration: A: bash loop for alignment RNA-seq data or A: shell script for bowtie/bwa alignment pair end reads
Post if you would like additional help.