Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 175 lines (147 sloc) 9.686 kB
aa7dcf6 @bow Refactor SearchIO indexing tests
bow authored
1 # Copyright 2012 by Wibowo Arindrarto. All rights reserved.
2 # This code is part of the Biopython distribution and governed by its
3 # license. Please see the LICENSE file that should have been included
4 # as part of this package.
5
6 """Tests for SearchIO blast-tab indexing."""
7
8 import unittest
9
10 from search_tests_common import CheckRaw, CheckIndex
11
12
13 class BlastTabRawCases(CheckRaw):
14 """Check BLAST tabular get_raw method."""
15
16 fmt = 'blast-tab'
17
18 def test_blasttab_2226_multiple_first(self):
19 """Test blast-tab raw string retrieval, BLAST 2.2.26+, multiple queries, first (tab_2226_tblastn_001.txt)"""
20 filename = 'Blast/tab_2226_tblastn_001.txt'
21 raw = """gi|16080617|ref|NP_391444.1| gi|145479850|ref|XM_001425911.1| 34.88 43 28 0 31 73 1744 1872 1e-05 34.7
22 gi|16080617|ref|NP_391444.1| gi|72012412|ref|XM_777959.1| 33.90 59 31 1 44 94 1057 1233 1e-04 31.6
23 gi|16080617|ref|NP_391444.1| gi|115975252|ref|XM_001180111.1| 33.90 59 31 1 44 94 1057 1233 1e-04 31.6
24 """
25 self.check_raw(filename, "gi|16080617|ref|NP_391444.1|", raw)
26
27 def test_blasttab_2226_multiple_last(self):
28 """Test blast-tab raw string retrieval, BLAST 2.2.26+, multiple queries, last (tab_2226_tblastn_001.txt)"""
29 filename = 'Blast/tab_2226_tblastn_001.txt'
30 raw = """gi|11464971:4-101 gi|350596019|ref|XM_003360601.2| 95.92 98 4 0 1 98 95 388 2e-67 199
31 gi|11464971:4-101 gi|350596019|ref|XM_003360601.2| 29.58 71 46 2 30 96 542 754 4e-05 32.7
32 gi|11464971:4-101 gi|301779869|ref|XM_002925302.1| 97.96 98 2 0 1 98 78 371 2e-67 202
33 gi|11464971:4-101 gi|301779869|ref|XM_002925302.1| 30.00 100 64 2 3 96 804 1103 3e-09 45.1
34 gi|11464971:4-101 gi|296223671|ref|XM_002757683.1| 97.96 98 2 0 1 98 161 454 4e-67 202
35 gi|11464971:4-101 gi|296223671|ref|XM_002757683.1| 30.00 100 64 2 3 96 866 1165 3e-09 45.1
36 gi|11464971:4-101 gi|338714227|ref|XM_001492113.3| 97.96 98 2 0 1 98 173 466 2e-66 202
37 gi|11464971:4-101 gi|338714227|ref|XM_001492113.3| 31.00 100 63 2 3 96 899 1198 1e-09 46.6
38 gi|11464971:4-101 gi|365982352|ref|XM_003667962.1| 30.77 52 27 1 12 54 3181 3336 1.7 19.6
39 """
40 self.check_raw(filename, "gi|11464971:4-101", raw)
41
42 def test_blasttab_2226_single(self):
43 """Test blast-tab raw string retrieval, BLAST 2.2.26+, single query (tab_2226_tblastn_004.txt)"""
44 filename = 'Blast/tab_2226_tblastn_004.txt'
45 raw = """gi|11464971:4-101 gi|350596019|ref|XM_003360601.2| 95.92 98 4 0 1 98 95 388 2e-67 199
46 gi|11464971:4-101 gi|350596019|ref|XM_003360601.2| 29.58 71 46 2 30 96 542 754 4e-05 32.7
47 gi|11464971:4-101 gi|301779869|ref|XM_002925302.1| 97.96 98 2 0 1 98 78 371 2e-67 202
48 gi|11464971:4-101 gi|301779869|ref|XM_002925302.1| 30.00 100 64 2 3 96 804 1103 3e-09 45.1
49 gi|11464971:4-101 gi|296223671|ref|XM_002757683.1| 97.96 98 2 0 1 98 161 454 4e-67 202
50 gi|11464971:4-101 gi|296223671|ref|XM_002757683.1| 30.00 100 64 2 3 96 866 1165 3e-09 45.1
51 gi|11464971:4-101 gi|338714227|ref|XM_001492113.3| 97.96 98 2 0 1 98 173 466 2e-66 202
52 gi|11464971:4-101 gi|338714227|ref|XM_001492113.3| 31.00 100 63 2 3 96 899 1198 1e-09 46.6
53 gi|11464971:4-101 gi|365982352|ref|XM_003667962.1| 30.77 52 27 1 12 54 3181 3336 1.7 19.6
54 """
55 self.check_raw(filename, "gi|11464971:4-101", raw)
56
57 def test_blasttab_2226_multiple_first_commented(self):
58 """Test blast-tab raw string retrieval, BLAST 2.2.26+, multiple queries, first, commented (tab_2226_tblastn_005.txt)"""
59 filename = 'Blast/tab_2226_tblastn_005.txt'
60 raw = """# TBLASTN 2.2.26+
61 # Query: random_s00
62 # Database: db/minirefseq_mrna
63 # 0 hits found
64 """
65 self.check_raw(filename, "random_s00", raw, comments=True)
66
67 def test_blasttab_2226_multiple_middle_commented(self):
68 """Test blast-tab raw string retrieval, BLAST 2.2.26+, multiple queries, middle, commented (tab_2226_tblastn_005.txt)"""
69 filename = 'Blast/tab_2226_tblastn_005.txt'
70 raw = """# TBLASTN 2.2.26+
71 # Query: gi|16080617|ref|NP_391444.1| membrane bound lipoprotein [Bacillus subtilis subsp. subtilis str. 168]
72 # Database: db/minirefseq_mrna
73 # Fields: query id, subject id, % identity, alignment length, mismatches, gap opens, q. start, q. end, s. start, s. end, evalue, bit score
74 # 3 hits found
75 gi|16080617|ref|NP_391444.1| gi|145479850|ref|XM_001425911.1| 34.88 43 28 0 31 73 1744 1872 1e-05 34.7
76 gi|16080617|ref|NP_391444.1| gi|72012412|ref|XM_777959.1| 33.90 59 31 1 44 94 1057 1233 1e-04 31.6
77 gi|16080617|ref|NP_391444.1| gi|115975252|ref|XM_001180111.1| 33.90 59 31 1 44 94 1057 1233 1e-04 31.6
78 """
79 self.check_raw(filename, "gi|16080617|ref|NP_391444.1|", raw, comments=True)
80
81 def test_blasttab_2226_multiple_last_commented(self):
82 """Test blast-tab raw string retrieval, BLAST 2.2.26+, multiple queries, last, commented (tab_2226_tblastn_005.txt)"""
83 filename = 'Blast/tab_2226_tblastn_005.txt'
84 raw = """# TBLASTN 2.2.26+
85 # Query: gi|11464971:4-101 pleckstrin [Mus musculus]
86 # Database: db/minirefseq_mrna
87 # Fields: query id, subject id, % identity, alignment length, mismatches, gap opens, q. start, q. end, s. start, s. end, evalue, bit score
88 # 9 hits found
89 gi|11464971:4-101 gi|350596019|ref|XM_003360601.2| 95.92 98 4 0 1 98 95 388 2e-67 199
90 gi|11464971:4-101 gi|350596019|ref|XM_003360601.2| 29.58 71 46 2 30 96 542 754 4e-05 32.7
91 gi|11464971:4-101 gi|301779869|ref|XM_002925302.1| 97.96 98 2 0 1 98 78 371 2e-67 202
92 gi|11464971:4-101 gi|301779869|ref|XM_002925302.1| 30.00 100 64 2 3 96 804 1103 3e-09 45.1
93 gi|11464971:4-101 gi|296223671|ref|XM_002757683.1| 97.96 98 2 0 1 98 161 454 4e-67 202
94 gi|11464971:4-101 gi|296223671|ref|XM_002757683.1| 30.00 100 64 2 3 96 866 1165 3e-09 45.1
95 gi|11464971:4-101 gi|338714227|ref|XM_001492113.3| 97.96 98 2 0 1 98 173 466 2e-66 202
96 gi|11464971:4-101 gi|338714227|ref|XM_001492113.3| 31.00 100 63 2 3 96 899 1198 1e-09 46.6
97 gi|11464971:4-101 gi|365982352|ref|XM_003667962.1| 30.77 52 27 1 12 54 3181 3336 1.7 19.6
98 """
99 self.check_raw(filename, "gi|11464971:4-101", raw, comments=True)
100
101 def test_blasttab_2226_single_commented(self):
102 """Test blast-tab raw string retrieval, BLAST 2.2.26+, single query, commented (tab_2226_tblastn_008.txt)"""
103 filename = 'Blast/tab_2226_tblastn_008.txt'
104 raw = """# TBLASTN 2.2.26+
105 # Query: gi|11464971:4-101 pleckstrin [Mus musculus]
106 # Database: db/minirefseq_mrna
107 # Fields: query id, subject id, % identity, alignment length, mismatches, gap opens, q. start, q. end, s. start, s. end, evalue, bit score
108 # 9 hits found
109 gi|11464971:4-101 gi|350596019|ref|XM_003360601.2| 95.92 98 4 0 1 98 95 388 2e-67 199
110 gi|11464971:4-101 gi|350596019|ref|XM_003360601.2| 29.58 71 46 2 30 96 542 754 4e-05 32.7
111 gi|11464971:4-101 gi|301779869|ref|XM_002925302.1| 97.96 98 2 0 1 98 78 371 2e-67 202
112 gi|11464971:4-101 gi|301779869|ref|XM_002925302.1| 30.00 100 64 2 3 96 804 1103 3e-09 45.1
113 gi|11464971:4-101 gi|296223671|ref|XM_002757683.1| 97.96 98 2 0 1 98 161 454 4e-67 202
114 gi|11464971:4-101 gi|296223671|ref|XM_002757683.1| 30.00 100 64 2 3 96 866 1165 3e-09 45.1
115 gi|11464971:4-101 gi|338714227|ref|XM_001492113.3| 97.96 98 2 0 1 98 173 466 2e-66 202
116 gi|11464971:4-101 gi|338714227|ref|XM_001492113.3| 31.00 100 63 2 3 96 899 1198 1e-09 46.6
117 gi|11464971:4-101 gi|365982352|ref|XM_003667962.1| 30.77 52 27 1 12 54 3181 3336 1.7 19.6
118 """
119 self.check_raw(filename, "gi|11464971:4-101", raw, comments=True)
120
121
122 class BlastTabIndexCases(CheckIndex):
123
124 fmt = 'blast-tab'
125
126 def test_blasttab_2226_tblastn_001(self):
127 """Test blast-tab indexing, BLAST 2.2.26+, multiple queries"""
128 filename = 'Blast/tab_2226_tblastn_001.txt'
129 self.check_index(filename, self.fmt)
130
131 def test_blasttab_2226_tblastn_002(self):
132 """Test blast-tab indexing, BLAST 2.2.26+, single query, no hits"""
133 filename = 'Blast/tab_2226_tblastn_002.txt'
134 self.check_index(filename, self.fmt)
135
136 def test_blasttab_2226_tblastn_004(self):
137 """Test blast-tab indexing, BLAST 2.2.26+, single query, multiple hits"""
138 filename = 'Blast/tab_2226_tblastn_004.txt'
139 self.check_index(filename, self.fmt)
140
141 def test_blasttab_2226_tblastn_005(self):
142 """Test blast-tab indexing, BLAST 2.2.26+, multiple queries, commented"""
143 filename = 'Blast/tab_2226_tblastn_005.txt'
144 self.check_index(filename, self.fmt, comments=True)
145
146 def test_blasttab_2226_tblastn_006(self):
147 """Test blast-tab indexing, BLAST 2.2.26+, single query, no hits, commented"""
148 filename = 'Blast/tab_2226_tblastn_006.txt'
149 self.check_index(filename, self.fmt, comments=True)
150
151 def test_blasttab_comment_sing(self):
152 """Test blast-tab indexing, BLAST 2.2.26+, single query, multiple hits, commented"""
153 filename = 'Blast/tab_2226_tblastn_008.txt'
154 self.check_index(filename, self.fmt, comments=True)
155
156 def test_blasttab_2226_tblastn_009(self):
157 """Test blast-tab indexing, BLAST 2.2.26+, custom columns"""
158 filename = 'Blast/tab_2226_tblastn_009.txt'
159 self.check_index(filename, self.fmt, fields=['qseqid', 'sseqid'])
160
161 def test_blasttab_2226_tblastn_010(self):
162 """Test blast-tab indexing, BLAST 2.2.26+, custom columns, commented"""
163 filename = 'Blast/tab_2226_tblastn_010.txt'
164 self.check_index(filename, self.fmt, comments=True)
165
166 def test_blasttab_2226_tblastn_011(self):
167 """Test blast-tab indexing, BLAST 2.2.26+, all columns, commented"""
168 filename = 'Blast/tab_2226_tblastn_011.txt'
169 self.check_index(filename, self.fmt, comments=True)
170
171
172 if __name__ == "__main__":
b67cebf @peterjc Fix common PEP8 violation in unittest verbosity argument
peterjc authored
173 runner = unittest.TextTestRunner(verbosity=2)
aa7dcf6 @bow Refactor SearchIO indexing tests
bow authored
174 unittest.main(testRunner=runner)
Something went wrong with that request. Please try again.