This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to split fastq file containing Forward and Reverse reads to two files Forward and Reverse

Hello everyone ,

I have fastq file containing both Forward and reverse reads an di want to split this file to two files Forward and Reverse

can you tell me please how to do that ?

Thank you very much

sequencing genome alignment assembly

Do you really mean forward and reverse, and not read 1 and read and read 2? read1 and read2 can likely be split by their names. forward and reverse can only be determined after alignment.

Thank you for your response

well , because i did alignement of my reads (two files R1 and R2 ) and i transfered the output of bowtie2 (sam file ) to bam file , and from bam file i extracted unmapped reads (bam format ) and i transfered this last one to fastq and now i want to split this file to forward and reverse to do assemblage next ( my goal is to do assembly of the unmapped reads )

Sorry for late reply

You can also use samtools fastq to convert your unmapped.bam file to fastq.

yees i ve got fastq file and i wat to split it to two files forward and reverse

You can't identify what direction the read goes from the fastq. However, the bam file will tell you forward or reverse.

If you mean forward (= R1 read) and reverse (=R2 read) then splitting the interleaved files is fine. Otherwise you can't find the information about which strand they come from since the reads are unmapped.

1 answer

If your reads are interleaved (1_R1,1_R2,2_R1,2_R2 etc) then you can use reformat.sh from BBMap suite.

reformat.sh in=original.fq out1=R1.fq out2=R2.fq

Thank you very much for your answer

What if reads are not interleaved? Like merged fastq file by "cat" R1 and R2? 1_R1, 2_R1, 3_R1...and then 1_R2, 2_R2, 3_R2...

R1: @A00821:139:HNTJGDSXX:1:1101:5159:1031 1:N:0:TGGTCATC+CCTAGTCA

R2: @A00920:68:HNV3TDSXX:3:2678:32832:37059 2:N:0:AAGGTTCG+CACGTCAT

You could simply split the file in two pieces. Assuming the read numbers in two files matched before they were cated.

Log in to answer this question.