Permalink
Browse files

Rename blast-tab arg 'has_comments' to 'comments'

  • Loading branch information...
bow committed Aug 7, 2012
1 parent a4e3d53 commit 6d3d8a9a6ee32a9036bf0e75719aaadcf980703e
@@ -110,9 +110,9 @@ class BlastTabIterator(object):
"""Main parser for the BLAST tabular format."""
def __init__(self, handle, has_comments=False, fields=_DEFAULT_FIELDS):
def __init__(self, handle, comments=False, fields=_DEFAULT_FIELDS):
self.handle = handle
self.has_comments = has_comments
self.has_comments = comments
self.fields = self._prep_fields(fields)
self.line = self.handle.readline().strip()
@@ -417,10 +417,9 @@ class BlastTabIndexer(SearchIndexer):
_parser = BlastTabIterator
def __init__(self, filename, has_comments=False, fields=_DEFAULT_FIELDS):
SearchIndexer.__init__(self, filename, has_comments=has_comments, \
fields=fields)
self._has_comments = has_comments
def __init__(self, filename, comments=False, fields=_DEFAULT_FIELDS):
SearchIndexer.__init__(self, filename, comments=comments, fields=fields)
self._has_comments = comments
self._handle.seek(0)
# if the file doesn't have comments,
@@ -539,9 +538,9 @@ class BlastTabWriter(object):
"""Writer for blast-tab output format."""
def __init__(self, handle, has_comments=False, fields=_DEFAULT_FIELDS):
def __init__(self, handle, comments=False, fields=_DEFAULT_FIELDS):
self.handle = handle
self.has_comments = has_comments
self.has_comments = comments
self.fields = fields
def write_file(self, qresults):
@@ -240,7 +240,7 @@ def test_tab_2226_tblastn_005(self):
"Test parsing TBLASTN 2.2.26+ tabular output with comments (tab_2226_tblastn_005)"
xml_file = get_file('tab_2226_tblastn_005.txt')
qresults = parse(xml_file, FMT, has_comments=True)
qresults = parse(xml_file, FMT, comments=True)
counter = 0
# test first qresult
@@ -352,7 +352,7 @@ def test_tab_2226_tblastn_006(self):
"Test parsing TBLASTN 2.2.26+ tabular output with comments (tab_2226_tblastn_006)"
xml_file = get_file('tab_2226_tblastn_006.txt')
qresults = parse(xml_file, FMT, has_comments=True)
qresults = parse(xml_file, FMT, comments=True)
counter = 0
qresult = qresults.next()
@@ -372,7 +372,7 @@ def test_tab_2226_tblastn_007(self):
"Test parsing TBLASTN 2.2.26+ tabular output with comments (tab_2226_tblastn_007)"
xml_file = get_file('tab_2226_tblastn_007.txt')
qresults = parse(xml_file, FMT, has_comments=True)
qresults = parse(xml_file, FMT, comments=True)
counter = 0
qresult = qresults.next()
@@ -430,7 +430,7 @@ def test_tab_2226_tblastn_008(self):
"Test parsing TBLASTN 2.2.26+ tabular output with comments (tab_2226_tblastn_008)"
xml_file = get_file('tab_2226_tblastn_008.txt')
qresults = parse(xml_file, FMT, has_comments=True)
qresults = parse(xml_file, FMT, comments=True)
counter = 0
qresult = qresults.next()
@@ -546,7 +546,7 @@ def test_tab_2226_tblastn_010(self):
"Test parsing TBLASTN 2.2.26+ tabular output with comments (tab_2226_tblastn_010)"
xml_file = get_file('tab_2226_tblastn_010.txt')
qresults = parse(xml_file, FMT, has_comments=True)
qresults = parse(xml_file, FMT, comments=True)
counter = 0
# test first qresult
@@ -626,7 +626,7 @@ def test_tab_2226_tblastn_011(self):
"Test parsing TBLASTN 2.2.26+ tabular output with comments (tab_2226_tblastn_011)"
xml_file = get_file('tab_2226_tblastn_011.txt')
qresults = parse(xml_file, FMT, has_comments=True)
qresults = parse(xml_file, FMT, comments=True)
counter = 0
# test first qresult
@@ -796,7 +796,7 @@ def test_tab_2226_tblastn_012(self):
"Test parsing TBLASTN 2.2.26+ tabular output with comments (tab_2226_tblastn_012)"
xml_file = get_file('tab_2226_tblastn_012.txt')
qresults = parse(xml_file, FMT, has_comments=True)
qresults = parse(xml_file, FMT, comments=True)
counter = 0
# test first qresult
@@ -786,7 +786,7 @@ def test_blasttab_2226_single(self):
def test_blasttab_2226_multiple_first_commented(self):
"""Test blast-tab raw string retrieval, BLAST 2.2.26+, multiple queries, first, commented (tab_2226_tblastn_005.txt)"""
filename = 'Blast/tab_2226_tblastn_005.txt'
idx = SearchIO.index(filename, self.fmt, has_comments=True)
idx = SearchIO.index(filename, self.fmt, comments=True)
raw = """# TBLASTN 2.2.26+
# Query: random_s00
# Database: db/minirefseq_mrna
@@ -797,7 +797,7 @@ def test_blasttab_2226_multiple_first_commented(self):
def test_blasttab_2226_multiple_middle_commented(self):
"""Test blast-tab raw string retrieval, BLAST 2.2.26+, multiple queries, middle, commented (tab_2226_tblastn_005.txt)"""
filename = 'Blast/tab_2226_tblastn_005.txt'
idx = SearchIO.index(filename, self.fmt, has_comments=True)
idx = SearchIO.index(filename, self.fmt, comments=True)
raw = """# TBLASTN 2.2.26+
# Query: gi|16080617|ref|NP_391444.1| membrane bound lipoprotein [Bacillus subtilis subsp. subtilis str. 168]
# Database: db/minirefseq_mrna
@@ -812,7 +812,7 @@ def test_blasttab_2226_multiple_middle_commented(self):
def test_blasttab_2226_multiple_last_commented(self):
"""Test blast-tab raw string retrieval, BLAST 2.2.26+, multiple queries, last, commented (tab_2226_tblastn_005.txt)"""
filename = 'Blast/tab_2226_tblastn_005.txt'
idx = SearchIO.index(filename, self.fmt, has_comments=True)
idx = SearchIO.index(filename, self.fmt, comments=True)
raw = """# TBLASTN 2.2.26+
# Query: gi|11464971:4-101 pleckstrin [Mus musculus]
# Database: db/minirefseq_mrna
@@ -834,7 +834,7 @@ def test_blasttab_2226_multiple_last_commented(self):
def test_blasttab_2226_single_commented(self):
"""Test blast-tab raw string retrieval, BLAST 2.2.26+, single query, commented (tab_2226_tblastn_008.txt)"""
filename = 'Blast/tab_2226_tblastn_008.txt'
idx = SearchIO.index(filename, self.fmt, has_comments=True)
idx = SearchIO.index(filename, self.fmt, comments=True)
raw = """# TBLASTN 2.2.26+
# Query: gi|11464971:4-101 pleckstrin [Mus musculus]
# Database: db/minirefseq_mrna
@@ -1323,17 +1323,17 @@ def test_blasttab_2226_tblastn_004(self):
def test_blasttab_2226_tblastn_005(self):
"""Test blast-tab indexing, BLAST 2.2.26+, multiple queries, commented"""
filename = 'Blast/tab_2226_tblastn_005.txt'
self.check_index(filename, self.fmt, has_comments=True)
self.check_index(filename, self.fmt, comments=True)
def test_blasttab_2226_tblastn_006(self):
"""Test blast-tab indexing, BLAST 2.2.26+, single query, no hits, commented"""
filename = 'Blast/tab_2226_tblastn_006.txt'
self.check_index(filename, self.fmt, has_comments=True)
self.check_index(filename, self.fmt, comments=True)
def test_blasttab_comment_sing(self):
"""Test blast-tab indexing, BLAST 2.2.26+, single query, multiple hits, commented"""
filename = 'Blast/tab_2226_tblastn_008.txt'
self.check_index(filename, self.fmt, has_comments=True)
self.check_index(filename, self.fmt, comments=True)
def test_blasttab_2226_tblastn_009(self):
"""Test blast-tab indexing, BLAST 2.2.26+, custom columns"""
@@ -1343,12 +1343,12 @@ def test_blasttab_2226_tblastn_009(self):
def test_blasttab_2226_tblastn_010(self):
"""Test blast-tab indexing, BLAST 2.2.26+, custom columns, commented"""
filename = 'Blast/tab_2226_tblastn_010.txt'
self.check_index(filename, self.fmt, has_comments=True)
self.check_index(filename, self.fmt, comments=True)
def test_blasttab_2226_tblastn_011(self):
"""Test blast-tab indexing, BLAST 2.2.26+, all columns, commented"""
filename = 'Blast/tab_2226_tblastn_011.txt'
self.check_index(filename, self.fmt, has_comments=True)
self.check_index(filename, self.fmt, comments=True)
class HmmerTextIndexCases(SearchIndexCases):
@@ -74,13 +74,13 @@ def test_write_multiple_from_blasttab(self):
def test_write_single_from_blasttabc(self):
"""Test blast-tabc writing from blast-tabc, BLAST 2.2.26+, single query (tab_2226_tblastn_008.txt)"""
source = os.path.join('Blast', 'tab_2226_tblastn_008.txt')
self.parse_write_and_compare(source, self.fmt, self.out, self.fmt, has_comments=True)
self.read_write_and_compare(source, self.fmt, self.out, self.fmt, has_comments=True)
self.parse_write_and_compare(source, self.fmt, self.out, self.fmt, comments=True)
self.read_write_and_compare(source, self.fmt, self.out, self.fmt, comments=True)
def test_write_multiple_from_blasttabc(self):
"""Test blast-tabc writing from blast-tabc, BLAST 2.2.26+, multiple queries (tab_2226_tblastn_005.txt)"""
source = os.path.join('Blast', 'tab_2226_tblastn_005.txt')
self.parse_write_and_compare(source, self.fmt, self.out, self.fmt, has_comments=True)
self.parse_write_and_compare(source, self.fmt, self.out, self.fmt, comments=True)
class HmmerTabWriteCases(WriteCases):

0 comments on commit 6d3d8a9

Please sign in to comment.