Mercurial > repos > yufei-luo > s_mart
comparison commons/pyRepetUnit/hmmer/hmmOutput/tests/TestHmmpfamOutputProcessing.py @ 31:0ab839023fe4
Uploaded
author | m-zytnicki |
---|---|
date | Tue, 30 Apr 2013 14:33:21 -0400 |
parents | 94ab73e8a190 |
children |
comparison
equal
deleted
inserted
replaced
30:5677346472b5 | 31:0ab839023fe4 |
---|---|
1 import os | |
2 import unittest | |
3 from commons.pyRepetUnit.hmmer.hmmOutput.HmmpfamOutputProcessing import HmmpfamOutputProcessing | |
4 from commons.core.utils.FileUtils import FileUtils | |
5 | |
6 class TestHmmpfamOutputProcessing(unittest.TestCase): | |
7 | |
8 def setUp(self): | |
9 self.fileUtils = FileUtils() | |
10 self.hmmpfamOutputProcess = HmmpfamOutputProcessing() | |
11 self._inputFile = "./datas/Outputhmmpfam" | |
12 self._inputFile2 = "./datas/test_hmmpfam_output" | |
13 self._outputFile = "./datas/dummyAlignFile.align" | |
14 | |
15 def testReadHmmOutput(self): | |
16 file = open( self._inputFile ) | |
17 pfamOutput = self.hmmpfamOutputProcess.readHmmOutput(file) | |
18 self.assertEqual(["7LES_DROME", "437", "522", "fn3", "1", "84", "8.8e-15", "48.3"], pfamOutput.get(0)) | |
19 self.assertEqual(["7LES_DROME", "825", "914", "fn3", "1", "84", "2.2e-06", "13.4"], pfamOutput.get(1)) | |
20 self.assertEqual(["7LES_DROME", "1292", "1389", "fn3", "1", "84", "1.2e-06", "15.9"], pfamOutput.get(2)) | |
21 self.assertEqual(["7LES_DROME", "1799", "1891", "fn3", "1", "84", "2.3e-19", "63.5"], pfamOutput.get(3)) | |
22 self.assertEqual(["7LES_DROME", "1899", "1978", "fn3", "1", "84", "1.5e-06", "15.2"], pfamOutput.get(4)) | |
23 self.assertEqual(["7LES_DROME", "1993", "2107", "fn3", "1", "84", "4.3e-07", "20.3"], pfamOutput.get(5)) | |
24 self.assertEqual(["7LES_DROME", "2209", "2483", "pkinase", "1", "294", "6e-95", "314.6"], pfamOutput.get(6)) | |
25 self.assertEqual(["7LES_DROME", "2223", "2284", "rrm", "1", "77", "0.72", "-40.4"], pfamOutput.get(7)) | |
26 file.close() | |
27 | |
28 def test_readHmmOutput_empty_file(self): | |
29 file = open( "./datas/OutputhmmpfamEmpty", "w" ) | |
30 file.close() | |
31 file = open( "./datas/OutputhmmpfamEmpty") | |
32 pfamOutput = self.hmmpfamOutputProcess.readHmmOutput(file) | |
33 file.close() | |
34 self.assertEqual(None, pfamOutput) | |
35 os.system("rm ./datas/OutputhmmpfamEmpty") | |
36 | |
37 def testParseHmmpfamOutput2Align(self): | |
38 self.hmmpfamOutputProcess.readHmmOutputsAndWriteAlignFile(self._inputFile2, self._outputFile) | |
39 self.assertTrue(FileUtils.isRessourceExists(self._outputFile)) | |
40 self.assertEqual(18, FileUtils.getNbLinesInSingleFile(self._outputFile)) | |
41 os.system("rm " + self._outputFile) | |
42 | |
43 def test_parseHmmpfamOutput2Align_empty_file(self): | |
44 file = open("./datas/dummy_hmmpfam_output", "w") | |
45 file.close() | |
46 self._inputFile = "./datas/dummy_hmmpfam_output" | |
47 self.hmmpfamOutputProcess.readHmmOutputsAndWriteAlignFile( self._inputFile, self._outputFile ) | |
48 self.assertTrue(FileUtils.isEmpty(self._outputFile)) | |
49 os.system("rm " + self._inputFile) | |
50 os.system("rm " + self._outputFile) | |
51 | |
52 def test_parseHmmpfamOutput2Align_file_not_exists(self): | |
53 self._inputFile = "./datas/dummy_hmmpfam_output" | |
54 self.hmmpfamOutputProcess.readHmmOutputsAndWriteAlignFile(self._inputFile, self._outputFile ) | |
55 self.assertFalse(FileUtils.isRessourceExists(self._outputFile)) | |
56 | |
57 if __name__ == "__main__": | |
58 unittest.main() |