I have files with names like:
0195_R1.fastq
0195_R2.fastq
0196_R1.fastq
0196_R2.fastq
0197_R1.fastq
0197_R2.fastq
and so on.
I need to run a software for each pair of files (the R1 and R2 are correspondent to each other) like:
bowtie2 -x index_files -1 0195_R1.fastq -2 0195_R2.fastq -S 0195_output.sam
With multiple pairs I'd have to run multiple times. So I tried to do a bash script using a for loop but I've had no success. Also, I don't know how to rename the output sequentially.
I've tried the following:
for R1 in $FQDIR/*_R1.fastq; do
for R2 in $FQDIR/*_R2.fastq; do
bowtie2 -x index_files -1 $R1 -2 $R2 -S $N_output.sam
done
done
What should I do?
for R1 in $FQDIR/*_R1.fastq; do for R2 in $FQDIR/*_R2.fastq; dothis will dofor each R1 and for each R2, so every combination. Do it simpler - just iterate overR1files, so the first loop, then extract the<this part>_R1.fastqof the filename withbasenameandcut. Then when you have "this part" then it's easy. Note that$N_outputwould be intepreted as the variableN_outputyou probably want${N}_output.for i in {195..197}; { bowtie2 -x index_files -1 0195_R1.fastq -2 *${i}_R2.fastq -S *${i}_output.sam; }