[BioPython] parsing Blast Output

Sameet Mehta sameet at nccs.res.in
Sat Aug 21 05:57:57 EDT 2004


Hi,
I have two earlier posts regarding this.  The problem is much peculiar than 
I thought earlier.  I did the following
>>> from Bio.Blast import NCBIStandalone
>>> infh = file(r'C:\Sameet\only2blast.txt', 'r')
>>> b_parser = NCBIStandalone.BlastParser()
>>> b_iterator = NCBIStandalone.Iterator(infh, b_parser)

then when i did this:
>>> x = b_iterator.next()
i got the following trace
Traceback (most recent call last):
  File "<pyshell#5>", line 1, in -toplevel-
    x = b_iterator.next()
  File "C:\Python23\lib\site-packages\Bio\Blast\NCBIStandalone.py", line 
1378, in next
    return self._parser.parse(File.StringHandle(data))
  File "C:\Python23\lib\site-packages\Bio\Blast\NCBIStandalone.py", line 
603, in parse
    self._scanner.feed(handle, self._consumer)
  File "C:\Python23\lib\site-packages\Bio\Blast\NCBIStandalone.py", line 93, 
in feed
    read_and_call_until(uhandle, consumer.noevent, contains='BLAST')
  File "C:\Python23\Lib\site-packages\Bio\ParserSupport.py", line 335, in 
read_and_call_until
    line = safe_readline(uhandle)
  File "C:\Python23\Lib\site-packages\Bio\ParserSupport.py", line 411, in 
safe_readline
    raise SyntaxError, "Unexpected end of stream."
SyntaxError: Unexpected end of stream.

However, when i did this (without starting from the beginging):
>>> while 1:
	rec = b_iterator.next()
	if rec is None:
		break
	for a in rec.alignments:
		for h in a.hsps:
			if h.expect == 0:
				print a.title
				print h.sbjct_start, (h.sbjct_start + len
(h.match))

I got the expected result.  So the first call to iterator.next() is giving 
error, however later it is working just fine.  There is no loss of data.  
After the second call all the 6 records were retrived and printed properly.

Can this is fixed, or is there a work around

regards
Sameet
--
National Centre for Cell Science, Pune



More information about the BioPython mailing list