Question: parsing a fastq file using biopython
0
gravatar for sumithrasank75
3.5 years ago by
United States
sumithrasank75130 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"):
            f_read.write("%s\t%s\n" %record.id,record.seq))
next-gen • 2.1k views
ADD COMMENTlink modified 3.5 years ago by iraun3.6k • written 3.5 years ago by sumithrasank75130
0
gravatar for iraun
3.5 years ago by
iraun3.6k
Norway
iraun3.6k 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.id,record.seq, record.qual))

Hope it helps.

ADD COMMENTlink written 3.5 years ago by iraun3.6k
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: 1442 users visited in the last hour