Question: merging multiple pair end read files into one
0
gravatar for Bioinfonext
20 months ago by
Bioinfonext300
Korea
Bioinfonext300 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 • 615 views
ADD COMMENTlink modified 20 months ago by Asaf8.5k • written 20 months ago by Bioinfonext300
2
gravatar for Asaf
20 months ago by
Asaf8.5k
Israel
Asaf8.5k 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 20 months ago by Asaf8.5k
1

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

ADD REPLYlink written 20 months ago by swbarnes29.2k

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

ADD REPLYlink modified 20 months ago • written 20 months ago by Bioinfonext300
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: 1058 users visited in the last hour