How to split forward and reverse reads from one fastq file?
2
1
Entering edit mode
6.8 years ago
phongphak.06 ▴ 20

Hi, I have a metagenomic reads simulated by Grinder like this (example):

@1/1 reference=NZ_CP009501.1 position=complement(1484183..1484382) description="Methanosarcina thermophila TM-1, complete genome"
TAGTCAGTTCTGGCACGAATCCTGTCACACTCTACTTATTTTAAAATCCTTATTTATCACGATTTATATTTATAATTTATTATCAGTAAGATTATATTTATATACTTATGGTGTTGTATTATTCCCTGCATAAGTAATCCGATCCTATCAGTTTTCAGGCAGGACTTTGATATTTAGGGGGTCTAAAGTCCGAAAACCAG
+
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
@1/2 reference=NZ_CP009501.1 position=1484083..1484282 description="Methanosarcina thermophila TM-1, complete genome"
CTGTAGAAATACATTGAGAAATATCTTCTCTTATGTTTTCTTGCGTTTTTTATTTTCAGTAATCACTTACCTGAATGAGATACAACAATTCAATGATCATCTGGTTTTCGGACTTTAGACCCCCTAAATATCAAAGTCCTGCCTGAAAACTGATAGGATCGGATTACTTATGCAGGGAATAATACAACACCATAAGTATA
+
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

So I think /1 and /2 may represent forward and reverse reads

sequencing sequence next-gen • 4.0k views
ADD COMMENT
2
Entering edit mode
6.8 years ago
awk '{if(NR%8  >= 1 && NR%8 < 5) print}' file.fastq > file_R1.fastq
awk '{if(NR%8 == 0 || NR%8 >= 5) print}' file.fastq > file_R2.fastq
ADD COMMENT
0
Entering edit mode

Thank you! It's a nice idea, but it's not working correctly.

Anyway, I had tried this awk '{if(NR%8 < 4) print}' file.fastq > file_R1.fastq and it's worked, while I have no idea how to correct the another, since > 4 cannot extract the quality of reads (> 3 and > 5 are still not working)

ADD REPLY
0
Entering edit mode

Ah, I've updated my reply, I made an off-by-one error.

ADD REPLY
2
Entering edit mode
6.8 years ago

Alternatively, with BBMap:

reformat.sh in=file.fastq out=r#.fastq
ADD COMMENT

Login before adding your answer.

Traffic: 2227 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