Hi all,
I am trying to create a bash command to use a for loop to concatenate fastq files split by lanes after demultiplexing. For example, after demultiplexing, my non-concatenated fastq files are as such:
HC13_S13_L001_R1_001.fastq
HC13_S13_L001_R2_001.fastq
HC13_S13_L002_R1_001.fastq
HC13_S13_L002_R2_001.fastq
HC13_S13_L003_R1_001.fastq
HC13_S13_L003_R2_001.fastq
HC13_S13_L004_R1_001.fastq
HC13_S13_L004_R2_001.fastq
HC14_S14_L001_R1_001.fastq
HC14_S14_L001_R2_001.fastq
HC14_S14_L002_R1_001.fastq
HC14_S14_L002_R2_001.fastq
HC14_S14_L003_R1_001.fastq
HC14_S14_L003_R2_001.fastq
HC14_S14_L004_R1_001.fastq
HC14_S14_L004_R2_001.fastq
And I would like to take this and create four files of HC13_R1.fastq, HC13_R2.fastq, HC14_R1.fastq, and HC14_R2.fastq.
This would be very easy to do without a loop, however it is extremely time consuming if I am dealing with 25+ samples at a time.
cat HC13_S13_L00*_R1_001.fastq > HC13_R1.fq
The command I have tried to use to carry this out with a loop is below. It successfully merges the different lanes together, but does not create separate files for each sample, and I am not sure how to work that into my command.
for SUFFIX in R1_001.fastq R2_001.fastq; do cat *L001_$SUFFIX *L002_$SUFFIX *L003_$SUFFIX *L004_$SUFFIX > samplename_cat_$SUFFIX; done
Thanks!
I am trying to create a bash command to use a for loop to concatenate fastq files split by lanes after demultiplexing. For example, after demultiplexing, my non-concatenated fastq files are as such:
HC13_S13_L001_R1_001.fastq
HC13_S13_L001_R2_001.fastq
HC13_S13_L002_R1_001.fastq
HC13_S13_L002_R2_001.fastq
HC13_S13_L003_R1_001.fastq
HC13_S13_L003_R2_001.fastq
HC13_S13_L004_R1_001.fastq
HC13_S13_L004_R2_001.fastq
HC14_S14_L001_R1_001.fastq
HC14_S14_L001_R2_001.fastq
HC14_S14_L002_R1_001.fastq
HC14_S14_L002_R2_001.fastq
HC14_S14_L003_R1_001.fastq
HC14_S14_L003_R2_001.fastq
HC14_S14_L004_R1_001.fastq
HC14_S14_L004_R2_001.fastq
And I would like to take this and create four files of HC13_R1.fastq, HC13_R2.fastq, HC14_R1.fastq, and HC14_R2.fastq.
This would be very easy to do without a loop, however it is extremely time consuming if I am dealing with 25+ samples at a time.
cat HC13_S13_L00*_R1_001.fastq > HC13_R1.fq
The command I have tried to use to carry this out with a loop is below. It successfully merges the different lanes together, but does not create separate files for each sample, and I am not sure how to work that into my command.
for SUFFIX in R1_001.fastq R2_001.fastq; do cat *L001_$SUFFIX *L002_$SUFFIX *L003_$SUFFIX *L004_$SUFFIX > samplename_cat_$SUFFIX; done
Thanks!
Comment