Question: merging multiple pair end read files into one
0
gravatar for Bioinfonext
6 months ago by
Bioinfonext160
Korea
Bioinfonext160 wrote:

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 • 267 views
ADD COMMENTlink modified 6 months ago by Asaf6.2k • written 6 months ago by Bioinfonext160
2
gravatar for Asaf
6 months ago by
Asaf6.2k
Israel
Asaf6.2k wrote:

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 COMMENTlink written 6 months ago by Asaf6.2k
1

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

ADD REPLYlink written 6 months ago by swbarnes26.5k

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

ADD REPLYlink modified 6 months ago • written 6 months ago by Bioinfonext160
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1506 users visited in the last hour