Question: Biopython: Fastqgeneraliterator Throwing Valueerror
gravatar for nupurgupta0806
6.9 years ago by
nupurgupta080630 wrote:

Hello, I am reading and writing some fastq files, and am getting an unexpected error. The steps my code takes are

1.Read 3 FASTQ files, end trim for quality, and write to another 3 FASTQ files. Uses FastqGeneralIterator 2. Read from result 3 FASTQ files, throw some way based on some condition, and write to another file. Uses FastqGeneralIterator . The corresponding code is -

for title,rseq,quals in FastqGeneralIterator(read_handle) 

At step 2 I get an error

Traceback (most recent call last):
  File ".../", line 120, in do_filtering
    for title,rseq,quals in FastqGeneralIterator(read_handle) :
  File "/usr/lib/python2.7/site-packages/Bio/SeqIO/", line 891, in FastqGeneralIterator
    raise ValueError("End of file without quality information.")
ValueError: End of file without quality information.

This error is thrown after the whole file is parsed, at the step of the last record. That area of the FASTQ file looks like (The formatting is not coming out proper below..but I have checked it, and it definitely is alright.


I have checked these records. The sequence string and quality string are of the same length. Also, I am explicitly printing a "\n" at the end of the file when the original file was created. Further, there were 3 files. The code may fail at a different file each time. But it definitely does fail.

Any idea what could be the matter? Thanks very much.

biopython • 2.2k views
ADD COMMENTlink written 6.9 years ago by nupurgupta080630

Since the formatting of the example is messed up, how about posting the FASTQ snippet using gist or something?

Also check the exact contents with hexdump, e.g. at the command line you could try:

tail -n 10 example.fastq | hexdump -C

and copy paste that output. That may show up issues with different new lines (Unix vs Windows).

ADD REPLYlink modified 6.9 years ago • written 6.9 years ago by Peter5.8k
gravatar for nupurgupta0806
6.9 years ago by
nupurgupta080630 wrote:

Oh, I have figured it out. I had a bunch of file handles open, and I think that somehow messed up printing to the files. I am so sorry!

@Peter, thanks for the hexdump tip. Never used it before.

ADD COMMENTlink written 6.9 years ago by nupurgupta080630

Oh good - glad you've solved it :)

ADD REPLYlink written 6.9 years ago by Peter5.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: 1063 users visited in the last hour