Question: parsing a fastq file using biopython
gravatar for sumithrasank75
4.5 years ago by
United States
sumithrasank75140 wrote:

I am trying to store reads from a fastq file into a text file (tab delimited). I use the following code which just stores the read_id and sequence from the fastq file. What should I add to store the third and fourth rows of each entry? Thanks

def parsing_readid(input_file):

    f_read = open ('read1.txt','a')
    for record in SeqIO.parse(open(input_file,"rU"),"fastq"):
next-gen • 2.7k views
ADD COMMENTlink modified 4.5 years ago by iraun3.8k • written 4.5 years ago by sumithrasank75140
gravatar for iraun
4.5 years ago by
iraun3.8k wrote:

Usually I work with FastqGeneralIterator to parse fastq files but... Have you tried record.qual to print out the read quality?

For other hand, the third line in fq format usually is only a "+" or a "+" followed by the read_id, so, you can just print it like this:

f_read.write("@%s\t%s\t+\t%s\n" %,record.seq, record.qual))

Hope it helps.

ADD COMMENTlink written 4.5 years ago by iraun3.8k
Please log in to add an answer.


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