Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rename blast-tab arg 'has_comments' to 'comments'
  • Loading branch information
bow committed Aug 7, 2012
1 parent a4e3d53 commit 6d3d8a9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
15 changes: 7 additions & 8 deletions Bio/SearchIO/BlastIO/blasttab.py
Expand Up @@ -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()

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down
14 changes: 7 additions & 7 deletions Tests/test_SearchIO_blasttab.py
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions Tests/test_SearchIO_index.py
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"""
Expand All @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions Tests/test_SearchIO_write.py
Expand Up @@ -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):
Expand Down

0 comments on commit 6d3d8a9

Please sign in to comment.