This is a test version of Biostars. For the public version, visit https://www.biostars.org.
merging multiple pair end read files into one

Hi,

I do have two groups of fastq files, I need to merge R1 reads of one file whose has same name at the beginning with the other R1 files reads.

Like Soil-13 is similar in two RI reads files,

I do have multiple pair-end read files like this that I need to merge into one. similarly, I need to do for R2 reads.

at the end I want to I have two soil-13 fastq files, one for R1 reads and other for R2 read. Like this, I need to do with multiple files.

Soil-13_S4_L001_R1_001.fastq

Soil-13_S4_L001_R2_001.fastq

Soil-15_S5_L001_R1_001.fastq

Soil-15_S5_L001_R2_001.fastq



Soil-13_S62_L001_R1_001.fastq

Soil-13_S62_L001_R2_001.fastq

Soil-15_S72_L001_R1_001.fastq

Soil-15_S72_L001_R2_001.fastq

Kind Regards

linux command line

1 answer

You can just concatenate them with cat:

cat Soil-13*_R1_*.fastq > Soil-13_R1_001.fastq
cat Soil-13*_R2_*.fastq > Soil-13_R2_001.fastq

etc.

You can generate a for loop to run through all libraries (bash):

 for l in $(ls *_R1_*.fastq | cut -d "_" -f 1 |sort |uniq); do cat ${l}*_R1_*.fastq > ${l}_R1_001.fastq && cat ${l}*_R2_*.fastq; done

Note that the cut part of the command only works properly if none of your sample names has "_" in it.

Thanks, In all files, there is dash (-) . No underscore.

Log in to answer this question.