[BioPython] Iterating over Blast file
Sameet Mehta
sameet at nccs.res.in
Thu Aug 19 07:44:14 EDT 2004
Hi all,
I have a blast output file. I want to iterate over the results, Now i am
doing the following
>>> from Bio.Blast import NCBIStandalone
>>> infile = open(r'C:\Sameet\only2blast.txt', 'r')
>>> parser = NCBIStandalone.BlastParser()
>>> iterator = NCBIStandalone.Iterator(infile, parser)
>>> while 1:
record = iterator.next()
if record is None:
break
for alignment in record.alignments:
for hsp in alignments.hsps:
if hsp.expect < 0.000000001:
print alignment.title, hsp.sbjct_start
The code taken as is from the tutorial
I am getting the following trace
Traceback (most recent call last):
File "<pyshell#12>", line 2, in -toplevel-
record = 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.
Now i have downloaded the latest version of the NCBIStandalone as advised by
Jeff. The module is working fine. I can get the individual blast results
one by one using the 'iterator.next()' command. But when i have a big file,
with 4 reports one after the other. I get this error. Now I see that there
is no problem with the NCBIStandalone, however, i dont know if i am diong
anything wrong. As far as the tutorial is concerned, i am following it to
the line.
regards
Sameet
--
National Centre for Cell Science, Pune
More information about the BioPython
mailing list