Mercurial > repos > yufei-luo > s_mart
comparison commons/core/coord/test/Test_MatchUtils.py @ 6:769e306b7933
Change the repository level.
author | yufei-luo |
---|---|
date | Fri, 18 Jan 2013 04:54:14 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
5:ea3082881bf8 | 6:769e306b7933 |
---|---|
1 # Copyright INRA (Institut National de la Recherche Agronomique) | |
2 # http://www.inra.fr | |
3 # http://urgi.versailles.inra.fr | |
4 # | |
5 # This software is governed by the CeCILL license under French law and | |
6 # abiding by the rules of distribution of free software. You can use, | |
7 # modify and/ or redistribute the software under the terms of the CeCILL | |
8 # license as circulated by CEA, CNRS and INRIA at the following URL | |
9 # "http://www.cecill.info". | |
10 # | |
11 # As a counterpart to the access to the source code and rights to copy, | |
12 # modify and redistribute granted by the license, users are provided only | |
13 # with a limited warranty and the software's author, the holder of the | |
14 # economic rights, and the successive licensors have only limited | |
15 # liability. | |
16 # | |
17 # In this respect, the user's attention is drawn to the risks associated | |
18 # with loading, using, modifying and/or developing or reproducing the | |
19 # software by the user in light of its specific status of free software, | |
20 # that may mean that it is complicated to manipulate, and that also | |
21 # therefore means that it is reserved for developers and experienced | |
22 # professionals having in-depth computer knowledge. Users are therefore | |
23 # encouraged to load and test the software's suitability as regards their | |
24 # requirements in conditions enabling the security of their systems and/or | |
25 # data to be ensured and, more generally, to use and operate it in the | |
26 # same conditions as regards security. | |
27 # | |
28 # The fact that you are presently reading this means that you have had | |
29 # knowledge of the CeCILL license and that you accept its terms. | |
30 | |
31 | |
32 import unittest | |
33 import os | |
34 from commons.core.utils.FileUtils import FileUtils | |
35 from commons.core.coord.MatchUtils import MatchUtils | |
36 from commons.core.coord.Match import Match | |
37 from commons.core.seq.BioseqDB import BioseqDB | |
38 | |
39 | |
40 class Test_MatchUtils( unittest.TestCase ): | |
41 | |
42 def test_getMatchListFromFile( self ): | |
43 inFile = "dummyInFile" | |
44 inFileHandler = open( inFile, "w" ) | |
45 inFileHandler.write( "query.name\tquery.start\tquery.end\tquery.length\tquery.length.%\tmatch.length.%\tsubject.name\tsubject.start\tsubject.end\tsubject.length\tsubject.length.%\tE.value\tScore\tIdentity\tpath\n" ) | |
46 m1 = Match() | |
47 m1.setFromTuple( ("QName", 1, 5, 5, 0.1, 0.2, "SName1", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 1) ) | |
48 m1.write( inFileHandler ) | |
49 m2 = Match() | |
50 m2.setFromTuple( ("QName", 1, 5, 5, 0.1, 0.2, "SName2", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 1) ) | |
51 m2.write( inFileHandler ) | |
52 inFileHandler.close() | |
53 | |
54 lExp = [ m1, m2 ] | |
55 | |
56 lObs = MatchUtils.getMatchListFromFile( inFile ) | |
57 | |
58 self.assertEquals( lExp, lObs ) | |
59 | |
60 os.remove( inFile ) | |
61 | |
62 def test_getDictOfListsWithSubjectAsKey( self ): | |
63 m1 = Match() | |
64 m1.setFromTuple( ("QName", 1, 5, 5, 0.1, 0.2, "SName1", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 1) ) | |
65 m2 = Match() | |
66 m2.setFromTuple( ("QName", 1, 5, 5, 0.1, 0.2, "SName2", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 1) ) | |
67 lMatch = [ m1, m2 ] | |
68 | |
69 dExp = { "SName1": [ m1 ], "SName2": [ m2 ] } | |
70 | |
71 dObs = MatchUtils.getDictOfListsWithSubjectAsKey( lMatch ) | |
72 | |
73 self.assertEquals( dExp, dObs ) | |
74 | |
75 def test_getDictOfListsWithQueryAsKey( self ): | |
76 m1 = Match() | |
77 m1.setFromTuple( ("QName1", 1, 5, 5, 0.1, 0.2, "SName1", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 1) ) | |
78 m2 = Match() | |
79 m2.setFromTuple( ("QName2", 1, 5, 5, 0.1, 0.2, "SName2", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 1) ) | |
80 m3 = Match() | |
81 m3.setFromTuple( ("QName1", 1, 5, 5, 0.1, 0.2, "SName3", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 1) ) | |
82 lMatch = [ m1, m2, m3 ] | |
83 | |
84 dExp = { "QName1": [ m1, m3 ], "QName2": [ m2 ] } | |
85 | |
86 dObs = MatchUtils.getDictOfListsWithQueryAsKey( lMatch ) | |
87 | |
88 self.assertEquals( dExp, dObs ) | |
89 | |
90 def test_getIdListFromMatchList( self ): | |
91 m1 = Match() | |
92 m1.setFromTuple( ("QName", 1, 5, 5, 0.1, 0.2, "SName1", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 1) ) | |
93 m2 = Match() | |
94 m2.setFromTuple( ("QName", 1, 5, 5, 0.1, 0.2, "SName2", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 10) ) | |
95 lMatch = [ m1, m2 ] | |
96 | |
97 lExp = [1, 10] | |
98 | |
99 lObs = MatchUtils.getIdListFromMatchList( lMatch ) | |
100 | |
101 self.assertEquals(lExp, lObs) | |
102 | |
103 def test_getIdListFromMatchList_empty_list( self ): | |
104 lMatch = [] | |
105 lExp = [] | |
106 | |
107 lObs = MatchUtils.getIdListFromMatchList( lMatch ) | |
108 | |
109 self.assertEquals(lExp, lObs) | |
110 | |
111 def test_writeListInFile_without_header( self ): | |
112 m1 = Match() | |
113 m1.setFromTuple( ("QName", 1, 5, 5, 0.1, 0.2, "SName1", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 1) ) | |
114 m2 = Match() | |
115 m2.setFromTuple( ("QName", 1, 5, 5, 0.1, 0.2, "SName2", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 10) ) | |
116 lMatch = [ m1, m2 ] | |
117 | |
118 line1 = "QName\t1\t5\t5\t0.100000\t0.200000\tSName1\t5\t25\t20\t0.150000\t1e-20\t15\t87.200000\t1\n" | |
119 line2 = "QName\t1\t5\t5\t0.100000\t0.200000\tSName2\t5\t25\t20\t0.150000\t1e-20\t15\t87.200000\t10\n" | |
120 | |
121 expFileName = "expFileName.match" | |
122 expFileHandle = open ( expFileName, 'w' ) | |
123 expFileHandle.write(line1) | |
124 expFileHandle.write(line2) | |
125 expFileHandle.close() | |
126 | |
127 obsFileName = "obsFileName.match" | |
128 | |
129 MatchUtils.writeListInFile( lMatch, obsFileName ) | |
130 | |
131 self.assertTrue( FileUtils.are2FilesIdentical( expFileName, obsFileName ) ) | |
132 | |
133 os.remove( obsFileName ) | |
134 os.remove( expFileName ) | |
135 | |
136 def test_writeListInFile_with_header( self ): | |
137 m1 = Match() | |
138 m1.setFromTuple( ("QName", 1, 5, 5, 0.1, 0.2, "SName1", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 1) ) | |
139 m2 = Match() | |
140 m2.setFromTuple( ("QName", 1, 5, 5, 0.1, 0.2, "SName2", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 10) ) | |
141 lMatch = [ m1, m2 ] | |
142 | |
143 headerLine = "query.name\tquery.start\tquery.end\tquery.length\tquery.length.%\tmatch.length.%\tsubject.name\tsubject.start\tsubject.end\tsubject.length\tsubject.length.%\tE.value\tScore\tIdentity\tpath\n" | |
144 | |
145 line1 = headerLine | |
146 line2 = "QName\t1\t5\t5\t0.100000\t0.200000\tSName1\t5\t25\t20\t0.150000\t1e-20\t15\t87.200000\t1\n" | |
147 line3 = "QName\t1\t5\t5\t0.100000\t0.200000\tSName2\t5\t25\t20\t0.150000\t1e-20\t15\t87.200000\t10\n" | |
148 | |
149 expFileName = "expFileName.match" | |
150 expFileHandle = open ( expFileName, 'w' ) | |
151 expFileHandle.write(line1) | |
152 expFileHandle.write(line2) | |
153 expFileHandle.write(line3) | |
154 expFileHandle.close() | |
155 | |
156 obsFileName = "obsFileName.match" | |
157 | |
158 MatchUtils.writeListInFile( lMatch, obsFileName, header=headerLine ) | |
159 | |
160 self.assertTrue( FileUtils.are2FilesIdentical( expFileName, obsFileName ) ) | |
161 | |
162 os.remove( obsFileName ) | |
163 os.remove( expFileName ) | |
164 | |
165 def test_writeListInFile_with_append_mode( self ): | |
166 m1 = Match() | |
167 m1.setFromTuple( ("QName", 1, 5, 5, 0.1, 0.2, "SName1", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 1) ) | |
168 m2 = Match() | |
169 m2.setFromTuple( ("QName", 1, 5, 5, 0.1, 0.2, "SName2", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 10) ) | |
170 lMatch = [ m1, m2 ] | |
171 | |
172 line1 = "QName\t1\t5\t5\t0.100000\t0.200000\tSName1\t5\t25\t20\t0.150000\t1e-20\t15\t87.200000\t1\n" | |
173 line2 = "QName\t1\t5\t5\t0.100000\t0.200000\tSName2\t5\t25\t20\t0.150000\t1e-20\t15\t87.200000\t10\n" | |
174 | |
175 expFileName = "expFileName.match" | |
176 expFileHandle = open ( expFileName, 'w' ) | |
177 expFileHandle.write(line1) | |
178 expFileHandle.write(line1) | |
179 expFileHandle.write(line2) | |
180 expFileHandle.close() | |
181 | |
182 obsFileName = "obsFileName.match" | |
183 obsFileHandle = open ( obsFileName, 'w' ) | |
184 obsFileHandle.write(line1) | |
185 obsFileHandle.close() | |
186 | |
187 MatchUtils.writeListInFile( lMatch, obsFileName, 'a' ) | |
188 | |
189 self.assertTrue( FileUtils.are2FilesIdentical( expFileName, obsFileName ) ) | |
190 | |
191 os.remove( obsFileName ) | |
192 os.remove( expFileName ) | |
193 | |
194 def test_rmvDuplicateMatches(self): | |
195 m1 = Match() | |
196 m1.setFromTuple( ("QName", 1, 5, 5, 0.1, 0.2, "SName", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 1) ) | |
197 m2 = Match() | |
198 m2.setFromTuple( ("QName", 1, 5, 5, 0.1, 0.2, "SName2", 5, 25, 20, 0.15, 1e-20, 15, 86.2, 1) ) | |
199 m3 = Match() | |
200 m3.setFromTuple( ("QName", 1, 5, 5, 0.1, 0.2, "SName", 5, 25, 20, 0.15, 1e-20, 15, 87.2, 1) ) | |
201 lMatch = [ m1, m3, m2 ] | |
202 | |
203 lExp = [m1, m2] | |
204 lObs = MatchUtils.rmvDuplicateMatches(lMatch) | |
205 | |
206 self.assertEquals(lExp, lObs) | |
207 | |
208 def test_filterDiffQrySbj_same_seq(self): | |
209 fastaFileName = "file.fa" | |
210 self._writeFastaFile(fastaFileName) | |
211 qryDB = BioseqDB(fastaFileName) | |
212 tabFileName = "file.tab" | |
213 self._writeMatchFile(tabFileName) | |
214 | |
215 expListToKeep = ["HELITRON2"] | |
216 obsListToKeep = MatchUtils.filterDiffQrySbj(qryDB,tabFileName, 0.95, 0.98, 2) | |
217 self.assertEquals(expListToKeep, obsListToKeep) | |
218 os.remove(fastaFileName) | |
219 os.remove(tabFileName) | |
220 | |
221 def test_filterDiffQrySbj_TE_included_in_67percent_in_other_TE(self): | |
222 fastaFileName = "file.fa" | |
223 self._writeFastaFile2(fastaFileName) | |
224 qryDB = BioseqDB(fastaFileName) | |
225 tabFileName = "file.tab" | |
226 self._writeMatchFile2(tabFileName) | |
227 expListToKeep = [] | |
228 obsListToKeep = MatchUtils.filterDiffQrySbj(qryDB, tabFileName, 0.95, 0.98, 2) | |
229 self.assertEquals(expListToKeep, obsListToKeep) | |
230 os.remove(fastaFileName) | |
231 os.remove(tabFileName) | |
232 | |
233 def test_getNbDistinctSequencesInsideMatchesWithThresh_query(self): | |
234 tabFileName = "file.tab" | |
235 self._writeMatchFile3(tabFileName) | |
236 lMatches = MatchUtils.getMatchListFromFile(tabFileName) | |
237 expNbDistinctMatches = 1 | |
238 obsNbDistinctMatches = MatchUtils.getNbDistinctSequencesInsideMatchesWithThresh(lMatches,0.95, 0.98,"query") | |
239 self.assertEquals(expNbDistinctMatches, obsNbDistinctMatches) | |
240 os.remove(tabFileName) | |
241 | |
242 def test_getNbDistinctSequencesInsideMatchesWithThresh_subject(self): | |
243 tabFileName = "file.tab" | |
244 self._writeMatchFile3(tabFileName) | |
245 lMatches = MatchUtils.getMatchListFromFile(tabFileName) | |
246 expNbDistinctMatches = 1 | |
247 obsNbDistinctMatches = MatchUtils.getNbDistinctSequencesInsideMatchesWithThresh(lMatches,0.95, 0.98,"subject") | |
248 self.assertEquals(expNbDistinctMatches, obsNbDistinctMatches) | |
249 os.remove(tabFileName) | |
250 | |
251 def test_convertMatchFileToAlignFile(self): | |
252 inputMatchFileName = "file.tab" | |
253 expAlignFileName = "expected.align" | |
254 obsAlignFileName = "file.align" | |
255 | |
256 self._writeExpAlignFile(expAlignFileName) | |
257 self._writeMatchFile4(inputMatchFileName) | |
258 MatchUtils.convertMatchFileToAlignFile(inputMatchFileName) | |
259 | |
260 self.assertTrue(FileUtils.are2FilesIdentical(expAlignFileName, obsAlignFileName)) | |
261 | |
262 os.remove(inputMatchFileName) | |
263 os.remove(expAlignFileName) | |
264 os.remove(obsAlignFileName) | |
265 | |
266 def test_convertMatchFileToAlignFile_empty_file(self): | |
267 inputMatchFileName = "file.tab" | |
268 expAlignFileName = "expected.align" | |
269 obsAlignFileName = "file.align" | |
270 | |
271 f = open(expAlignFileName, "w") | |
272 f.close() | |
273 f = open(inputMatchFileName, "w") | |
274 f.close() | |
275 MatchUtils.convertMatchFileToAlignFile(inputMatchFileName) | |
276 | |
277 self.assertTrue(FileUtils.are2FilesIdentical(expAlignFileName, obsAlignFileName)) | |
278 | |
279 os.remove(inputMatchFileName) | |
280 os.remove(expAlignFileName) | |
281 os.remove(obsAlignFileName) | |
282 | |
283 def test_generateMatchFileWithNewPathId(self): | |
284 inputMatchFileName = "file.tab" | |
285 expMatchFileName = "expected.tab" | |
286 obsMatchFileName = "obsFile.tab" | |
287 | |
288 self._writeMatchFile5(inputMatchFileName) | |
289 self._writeExpMatchFile(expMatchFileName) | |
290 MatchUtils.generateMatchFileWithNewPathId(inputMatchFileName, obsMatchFileName) | |
291 | |
292 self.assertTrue(FileUtils.are2FilesIdentical(expMatchFileName, obsMatchFileName)) | |
293 | |
294 os.remove(inputMatchFileName) | |
295 os.remove(expMatchFileName) | |
296 os.remove(obsMatchFileName) | |
297 | |
298 def test_generateMatchFileWithNewPathId_empty_file(self): | |
299 inputMatchFileName = "file.tab" | |
300 expMatchFileName = "expected.tab" | |
301 obsMatchFileName = "obsFile.tab" | |
302 | |
303 f = open(expMatchFileName, "w") | |
304 f.write("query.name\tquery.start\tquery.end\tquery.length\tquery.length.%\tmatch.length.%\tsubject.name\tsubject.start\tsubject.end\tsubject.length\tsubject.length.%\tE.value\tScore\tIdentity\tpath\n") | |
305 f.close() | |
306 f = open(inputMatchFileName, "w") | |
307 f.close() | |
308 MatchUtils.generateMatchFileWithNewPathId(inputMatchFileName, obsMatchFileName) | |
309 | |
310 self.assertTrue(FileUtils.are2FilesIdentical(expMatchFileName, obsMatchFileName)) | |
311 | |
312 os.remove(inputMatchFileName) | |
313 os.remove(expMatchFileName) | |
314 os.remove(obsMatchFileName) | |
315 | |
316 def test_convertMatchFileIntoABCFileOnQueryCoverage(self): | |
317 matchFileName = "dummy.tab" | |
318 with open(matchFileName, "w") as f: | |
319 f.write("query.name\tquery.start\tquery.end\tquery.length\tquery.length.%\tmatch.length.%\tsubject.name\tsubject.start\tsubject.end\tsubject.length\tsubject.length.%\tE.value\tScore\tIdentity\tpath\n") | |
320 f.write("chr3\t1\t100\t100\t0.98\t0.95\tchr5\t11\t110\t100\t0.95\t1e-52\t133\t87.200000\n") | |
321 f.write("chr7\t1\t200\t200\t0.98\t0.95\tchr2\t11\t210\t200\t0.95\t1e-78\t235\t98.900000\n") | |
322 f.write("chr5\t1\t100\t100\t0.95\t0.95\tchr3\t11\t110\t100\t0.98\t1e-52\t133\t87.200000\n") | |
323 f.write("chr2\t1\t200\t200\t0.95\t0.95\tchr7\t11\t210\t200\t0.98\t1e-78\t235\t98.900000\n") | |
324 expFileName = "exp.abc" | |
325 with open(expFileName, "w") as f: | |
326 f.write("chr3\tchr5\t0.98\n") | |
327 f.write("chr7\tchr2\t0.98\n") | |
328 f.write("chr5\tchr3\t0.95\n") | |
329 f.write("chr2\tchr7\t0.95\n") | |
330 obsFileName = "obs.abc" | |
331 | |
332 MatchUtils.convertMatchFileIntoABCFileOnQueryCoverage(matchFileName, obsFileName) | |
333 | |
334 self.assertTrue(FileUtils.are2FilesIdentical(expFileName, obsFileName)) | |
335 | |
336 os.remove(matchFileName) | |
337 os.remove(expFileName) | |
338 os.remove(obsFileName) | |
339 | |
340 def test_convertMatchFileIntoABCFileOnQueryCoverage_coverage_threshold_85(self): | |
341 matchFileName = "dummy.tab" | |
342 with open(matchFileName, "w") as f: | |
343 f.write("query.name\tquery.start\tquery.end\tquery.length\tquery.length.%\tmatch.length.%\tsubject.name\tsubject.start\tsubject.end\tsubject.length\tsubject.length.%\tE.value\tScore\tIdentity\tpath\n") | |
344 f.write("chr3\t1\t100\t100\t0.98\t0.95\tchr5\t11\t110\t100\t0.95\t1e-52\t133\t87.200000\n") | |
345 f.write("chr7\t1\t200\t200\t0.98\t0.95\tchr2\t11\t210\t200\t0.95\t1e-78\t235\t98.900000\n") | |
346 f.write("chr5\t1\t100\t100\t0.85\t0.95\tchr3\t11\t110\t100\t0.98\t1e-52\t133\t87.200000\n") | |
347 f.write("chr2\t1\t200\t200\t0.80\t0.95\tchr7\t11\t210\t200\t0.98\t1e-78\t235\t98.900000\n") | |
348 expFileName = "exp.abc" | |
349 with open(expFileName, "w") as f: | |
350 f.write("chr3\tchr5\t0.98\n") | |
351 f.write("chr7\tchr2\t0.98\n") | |
352 f.write("chr5\tchr3\t0.85\n") | |
353 obsFileName = "obs.abc" | |
354 | |
355 MatchUtils.convertMatchFileIntoABCFileOnQueryCoverage(matchFileName, obsFileName, coverage = 0.85) | |
356 | |
357 self.assertTrue(FileUtils.are2FilesIdentical(expFileName, obsFileName)) | |
358 | |
359 os.remove(matchFileName) | |
360 os.remove(expFileName) | |
361 os.remove(obsFileName) | |
362 | |
363 def _writeFastaFile(self, fileName): | |
364 f = open(fileName, "w") | |
365 f.write(">HELITRON3\n") | |
366 f.write("GGCCAGTCACAATGGGGGTTTCACTGGTGTGTCATGCACATTTAATAGGGGTAAGACTGA\n") | |
367 f.write("ATAAAAAATGATTATTTGCATGAAATGGGGATGAGAGAGAAGGAAAGAGTTTCATCCTGG\n") | |
368 f.write("GATTCGTTTCATTCACCGGATCTCTTGCGTCCGCCTCCGCCGTGCGACCTCCGCATTCTC\n") | |
369 f.write(">HELITRON2\n") | |
370 f.write("GGCCAGTCACAATGGGGGTTTCACTGGTGTGTCATGCACATTTAATAGGGGTAAGACTGA\n") | |
371 f.write("ATAAAAAATGATTATTTGCATGAAATGGGGATGAGAGAGAAGGAAAGAGTTTCATCCTGG\n") | |
372 f.write("GATTCGTTTCATTCACCGGATCTCTTGCGTCCGCCTCCGCCGTGCGACCTCCGCATTCTC\n") | |
373 f.close() | |
374 | |
375 def _writeMatchFile(self, fileName): | |
376 f = open(fileName, "w") | |
377 f.write("query.name\tquery.start\tquery.end\tquery.length\tquery.length.%\tmatch.length.%\tsubject.name\tsubject.start\tsubject.end\tsubject.length\tsubject.length.%\tE.value\tScore\tIdentity\tpath\n") | |
378 f.write("HELITRON3\t1\t180\t180\t1\t1\tHELITRON2\t1\t180\t180\t1\t2e-103\t357\t100\t1\n") | |
379 f.close() | |
380 | |
381 def _writeFastaFile2(self, fileName): | |
382 f = open(fileName, "w") | |
383 f.write(">header2\n") | |
384 f.write("TTTCACTGGTGTGTCATGCACATTTAATAGGGGTAAGACTGAATAAAAAATGATTATTTG\n") | |
385 f.write("CATGAAATGGGGATGAGAGAGAAGGAAAGAGTTTCATCCTGGGATTCGTTTCATTCACCG\n") | |
386 f.close() | |
387 | |
388 def _writeMatchFile2(self, fileName): | |
389 f = open(fileName, "w") | |
390 f.write("query.name\tquery.start\tquery.end\tquery.length\tquery.length.%\tmatch.length.%\tsubject.name\tsubject.start\tsubject.end\tsubject.length\tsubject.length.%\tE.value\tScore\tIdentity\tpath\n") | |
391 f.write("header2\t1\t120\t120\t1\t0.674157\tBS31790\t19\t138\t120\t0.674157\t3e-68\t238\t100\t1\n") | |
392 f.close() | |
393 | |
394 def _writeMatchFile3(self, fileName): | |
395 f = open(fileName, "w") | |
396 f.write("query.name\tquery.start\tquery.end\tquery.length\tquery.length.%\tmatch.length.%\tsubject.name\tsubject.start\tsubject.end\tsubject.length\tsubject.length.%\tE.value\tScore\tIdentity\tpath\n") | |
397 f.write("header2\t1\t120\t120\t0.674157\t0.674157\tBS31790\t19\t138\t120\t0.674157\t3e-68\t238\t100\t1\n") | |
398 f.write("header3\t1\t120\t120\t0.99\t0.994157\tBS31790\t19\t138\t120\t0.994157\t3e-68\t238\t100\t1\n") | |
399 f.write("header4\t1\t120\t120\t1\t0.94157\tBS31790\t19\t138\t120\t0.674157\t3e-68\t238\t67\t1\n") | |
400 f.close() | |
401 | |
402 def _writeMatchFile4(self, fileName): | |
403 f = open(fileName, "w") | |
404 f.write("query.name\tquery.start\tquery.end\tquery.length\tquery.length.%\tmatch.length.%\tsubject.name\tsubject.start\tsubject.end\tsubject.length\tsubject.length.%\tE.value\tScore\tIdentity\tpath\n") | |
405 f.write("header2\t1\t120\t120\t0.674157\t0.674157\tBS31790\t19\t138\t120\t0.674157\t3e-68\t238\t100\t1\n") | |
406 f.write("header3\t120\t220\t120\t0.99\t0.994157\tBS31790\t19\t138\t120\t0.994157\t3e-65\t238\t100\t1\n") | |
407 f.write("header4\t1\t120\t120\t1\t0.94157\tBS31790\t19\t138\t120\t0.674157\t3e-67\t244\t90\t1\n") | |
408 f.close() | |
409 | |
410 def _writeExpAlignFile(self,fileName): | |
411 f = open(fileName, "w") | |
412 f.write("header2\t1\t120\tBS31790\t19\t138\t3e-68\t238.0\t100.0\n") | |
413 f.write("header3\t120\t220\tBS31790\t19\t138\t3e-65\t238.0\t100.0\n") | |
414 f.write("header4\t1\t120\tBS31790\t19\t138\t3e-67\t244.0\t90.0\n") | |
415 f.close() | |
416 | |
417 def _writeMatchFile5(self,fileName): | |
418 f = open(fileName, "w") | |
419 f.write("query.name\tquery.start\tquery.end\tquery.length\tquery.length.%\tmatch.length.%\tsubject.name\tsubject.start\tsubject.end\tsubject.length\tsubject.length.%\tE.value\tScore\tIdentity\tpath\n") | |
420 f.write("header2\t1\t120\t120\t0.674157\t0.674157\tBS31790\t19\t138\t120\t0.674157\t3e-68\t238\t100\t1\n") | |
421 f.write("header2\t124\t144\t120\t0.674157\t0.674157\tBS31790\t19\t138\t120\t0.674157\t3e-68\t238\t100\t1\n") | |
422 f.write("header3\t120\t220\t120\t0.99\t0.994157\tBS31790\t19\t138\t120\t0.994157\t3e-65\t238\t100\t1\n") | |
423 f.write("header4\t1\t120\t120\t1\t0.94157\tBS31790\t19\t138\t120\t0.674157\t3e-67\t244\t90\t1\n") | |
424 f.close() | |
425 | |
426 def _writeExpMatchFile(self,fileName): | |
427 f = open(fileName, "w") | |
428 f.write("query.name\tquery.start\tquery.end\tquery.length\tquery.length.%\tmatch.length.%\tsubject.name\tsubject.start\tsubject.end\tsubject.length\tsubject.length.%\tE.value\tScore\tIdentity\tpath\n") | |
429 f.write("header2\t1\t120\t120\t0.674157\t0.674157\tBS31790\t19\t138\t120\t0.674157\t3e-68\t238\t100.000000\t1\n") | |
430 f.write("header2\t124\t144\t120\t0.674157\t0.674157\tBS31790\t19\t138\t120\t0.674157\t3e-68\t238\t100.000000\t1\n") | |
431 f.write("header3\t120\t220\t120\t0.990000\t0.994157\tBS31790\t19\t138\t120\t0.994157\t3e-65\t238\t100.000000\t2\n") | |
432 f.write("header4\t1\t120\t120\t1.000000\t0.941570\tBS31790\t19\t138\t120\t0.674157\t3e-67\t244\t90.000000\t3\n") | |
433 f.close() | |
434 | |
435 | |
436 test_suite = unittest.TestSuite() | |
437 test_suite.addTest( unittest.makeSuite( Test_MatchUtils ) ) | |
438 if __name__ == "__main__": | |
439 unittest.TextTestRunner(verbosity=2).run( test_suite ) |