merging multiple pair end read files into one
1
0
Entering edit mode
2.6 years ago
Bioinfonext ▴ 370

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.1k views
ADD COMMENT
2
Entering edit mode
2.6 years ago
Asaf 8.6k

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
ADD COMMENT
1
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 2295 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6