Hi, I am having problem while running NCBIStandalone library of biopython. i want to retrieve sequence titles from output of blast but it gives error on iterator.
Following is the code to retrieve these sequence titles.
result_handle= open("foo.txt")
blast_parser = NCBIStandalone.BlastParser()
blast_iterator = NCBIStandalone.Iterator(result_handle, blast_parser)
print blast_iterator
for blast_record in blast_iterator:
print blast_record
E_VALUE_THRESH = 0.0
for alignment in blast_record.alignments:
for hsp in alignment.hsps:
if hsp.expect < E_VALUE_THRESH:
print 'sequence:', alignment.title
But it gives following errors. it makes iterator properly but does not loop it.
<Bio.Blast.NCBIStandalone.Iterator object at 0x1aa6450>
Traceback (most recent call last):
File "blast2.py", line 45, in <module>
for blast_record in blast_iterator:
File "/usr/lib/pymodules/python2.7/Bio/Blast/NCBIStandalone.py", line 1659, in next
return self._parser.parse(File.StringHandle(data))
File "/usr/lib/pymodules/python2.7/Bio/Blast/NCBIStandalone.py", line 818, in parse
self._scanner.feed(handle, self._consumer)
File "/usr/lib/pymodules/python2.7/Bio/Blast/NCBIStandalone.py", line 112, in feed
read_and_call_until(uhandle, consumer.noevent, contains='BLAST')
File "/usr/lib/pymodules/python2.7/Bio/ParserSupport.py", line 337, in read_and_call_until
line = safe_readline(uhandle)
File "/usr/lib/pymodules/python2.7/Bio/ParserSupport.py", line 413, in safe_readline
raise ValueError("Unexpected end of stream.")
ValueError: Unexpected end of stream.
Any help would be highly appreciated. Thanx Saima
The message "Unexpected end of stream." means the parser reached the end of the file before it expected it. Either your file is truncated, or the format has changed slightly (again). I hope you'd read the tutorial which warns that the plain text parser is fragile and this is (almost) to be expected if you try the latest BLAST release?