Browse files

Remove filler texts from blast-tab indexing and parsing

This patch removes some filler texts that affect string equality testing. These
texts do not affect the constructed SearchIO objects' values, only the string
lengths. To cope with this tweak, the parser is also adjusted.

Conflicts:

	Bio/SearchIO/BlastIO/blast_tab.py
  • Loading branch information...
1 parent 823d2ea commit 6525656f9e06eb52c7dde0583dc36e186d57afd6 @bow bow committed with peterjc Dec 5, 2012
Showing with 9 additions and 13 deletions.
  1. +9 −11 Bio/SearchIO/BlastIO/blast_tab.py
  2. +0 −2 Tests/test_SearchIO_index.py
View
20 Bio/SearchIO/BlastIO/blast_tab.py
@@ -269,7 +269,7 @@ def _parse_comments(self):
self.line = self.handle.readline()
if not self.line:
- return
+ return comments
else:
self.line = self.line.strip()
@@ -605,20 +605,18 @@ def _get_raw_qresult_commented(self, offset):
# query mark is the line marking a new query
# something like '# TBLASTN 2.2.25+'
query_mark = None
- while True:
- line = handle.readline()
+ line = handle.readline()
+ while line:
+ # since query_mark depends on the BLAST search, we need to obtain it
+ # first
if query_mark is None:
query_mark = line
- # if we've encountered another query mark, it's the start of
- # another query
- # if 'BLAST processed' is in line, it's one line before EOF
- elif line == query_mark:
+ # break when we've reached the next qresult or the search ends
+ elif line == query_mark or line.startswith(end_mark):
break
- # append to the raw string as long as qresult is the same
- qresult_raw += line
- if line.startswith(end_mark):
- break
+ qresult_raw += line
+ line = handle.readline()
return qresult_raw
View
2 Tests/test_SearchIO_index.py
@@ -856,7 +856,6 @@ def test_blasttab_2226_multiple_last_commented(self):
gi|11464971:4-101 gi|338714227|ref|XM_001492113.3| 97.96 98 2 0 1 98 173 466 2e-66 202
gi|11464971:4-101 gi|338714227|ref|XM_001492113.3| 31.00 100 63 2 3 96 899 1198 1e-09 46.6
gi|11464971:4-101 gi|365982352|ref|XM_003667962.1| 30.77 52 27 1 12 54 3181 3336 1.7 19.6
-# BLAST processed 3 queries
"""
self.check_raw(filename, "gi|11464971:4-101", raw, comments=True)
@@ -877,7 +876,6 @@ def test_blasttab_2226_single_commented(self):
gi|11464971:4-101 gi|338714227|ref|XM_001492113.3| 97.96 98 2 0 1 98 173 466 2e-66 202
gi|11464971:4-101 gi|338714227|ref|XM_001492113.3| 31.00 100 63 2 3 96 899 1198 1e-09 46.6
gi|11464971:4-101 gi|365982352|ref|XM_003667962.1| 30.77 52 27 1 12 54 3181 3336 1.7 19.6
-# BLAST processed 1 queries
"""
self.check_raw(filename, "gi|11464971:4-101", raw, comments=True)

0 comments on commit 6525656

Please sign in to comment.