18
|
1 import os
|
|
2 import unittest
|
|
3 from commons.pyRepetUnit.hmmer.hmmOutput.HmmscanOutputProcessing import HmmscanOutputProcessing
|
|
4 from commons.core.utils.FileUtils import FileUtils
|
|
5
|
|
6 class TestHmmscanOutputProcessing(unittest.TestCase):
|
|
7
|
|
8 def setUp(self):
|
|
9 self.hmmscanOutputProcess = HmmscanOutputProcessing()
|
|
10 self._inputFile = "./datas/hmmscanOutputTab.txt"
|
|
11 self._inputFileScan2 = "./datas/hmmscanOutput"
|
|
12 self._outputFileScan2 = "./datas/hmmscanOutput.align"
|
|
13 self._outputFile = "./datas/dummyFile.align"
|
|
14
|
|
15 def tearDown(self):
|
|
16 if os.path.exists(self._outputFile):
|
|
17 os.remove(self._outputFile)
|
|
18
|
|
19 def testReadHmmerscanOutput(self):
|
|
20 file = open( self._inputFile )
|
|
21 pfamOutput = self.hmmscanOutputProcess.readHmmOutput(file)
|
|
22 self.assertEqual(["Polinton-1_DY:classII:Polinton_4", "2742", "2766", "rve", "50", "78", "2.4e+03", "-3.3"], pfamOutput.get(0))
|
|
23 self.assertEqual(["Polinton-1_DY:classII:Polinton_4", "2951", "3101", "rve", "4", "168", "6.7e-30", "103.4"], pfamOutput.get(1))
|
|
24 self.assertEqual(["Polinton-1_DY:classII:Polinton_4", "3198", "3228", "Chromo", "4", "51", "8.5e-06", "24.7"], pfamOutput.get(2))
|
|
25 self.assertEqual(["Polinton-1_DY:classII:Polinton_4", "2117", "2125", "GARS_A", "196", "204", "11", "2.5"], pfamOutput.get(3))
|
|
26 file.close()
|
|
27
|
|
28 def test_readHmmerscanOutput_empty_file(self):
|
|
29 file = open( "./datas/OutputhmmscanEmpty", "w" )
|
|
30 file.close()
|
|
31 file = open( "./datas/OutputhmmscanEmpty")
|
|
32 pfamOutput = self.hmmscanOutputProcess.readHmmOutput(file)
|
|
33 file.close()
|
|
34 self.assertEqual(None, pfamOutput)
|
|
35 os.system("rm ./datas/OutputhmmscanEmpty")
|
|
36
|
|
37 def testParseHmmscanOutput2Align(self):
|
|
38 self.hmmscanOutputProcess.readHmmOutputsAndWriteAlignFile(self._inputFileScan2, self._outputFile)
|
|
39 self.assertTrue(FileUtils.isRessourceExists(self._outputFile))
|
|
40 self.assertTrue(FileUtils.are2FilesIdentical(self._outputFileScan2, self._outputFile))
|
|
41 os.system("rm " + self._outputFile)
|
|
42
|
|
43 def test_parseHmmscanOutput2Align_empty_file(self):
|
|
44 file = open("./datas/dummy_hmmpfam_output", "w")
|
|
45 file.close()
|
|
46 self._inputFile = "./datas/dummy_hmmpfam_output"
|
|
47 self.hmmscanOutputProcess.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_parseHmmscanOutput2Align_file_not_exists(self):
|
|
53 self._inputFile = "./datas/dummy_hmmpfam_output"
|
|
54 self.hmmscanOutputProcess.readHmmOutputsAndWriteAlignFile(self._inputFile, self._outputFile )
|
|
55 self.assertFalse(FileUtils.isRessourceExists(self._outputFile))
|
|
56
|
|
57 if __name__ == "__main__":
|
|
58 unittest.main() |