comparison commons/launcher/tests/Test_F_LaunchMCL.py @ 18:94ab73e8a190

Uploaded
author m-zytnicki
date Mon, 29 Apr 2013 03:20:15 -0400
parents
children
comparison
equal deleted inserted replaced
17:b0e8584489e6 18:94ab73e8a190
1 from commons.core.utils.FileUtils import FileUtils
2 import unittest
3 import os
4 import shutil
5 from commons.launcher.LaunchMCL import LaunchMCL
6
7 class Test_F_LaunchMCL(unittest.TestCase):
8 # TODO: test query coverage filter
9
10 def setUp(self):
11 self._inputFileName = "DmelChr4_LTRharvest_expected_with_default_params.fa"
12 try:
13 shutil.rmtree("MCLtmpDirectory")
14 os.remove(self._inputFileName)
15 except:
16 pass
17 try:
18 os.symlink("%s/Tools/%s" % (os.environ["REPET_DATA"], self._inputFileName), self._inputFileName)
19 except:
20 pass
21 self._outputFileName = "%s_MCL.fa" % os.path.splitext(self._inputFileName)[0]
22
23 def tearDown(self):
24 try:
25 os.remove(self._inputFileName)
26 os.remove(self._outputFileName)
27 shutil.rmtree("MCLtmpDirectory")
28 except:
29 pass
30 try:
31 os.remove("DmelChr4_LTRharvest_expected_with_default_params_MCL.map")
32 except:
33 pass
34
35 def test_run(self):
36 iLaunchMCL = LaunchMCL(self._inputFileName, doClean = True, verbosity = 1)
37 iLaunchMCL.run()
38 expFileName = "%s/Tools/DmelChr4_LTRharvest_MCL_expected.fa" % os.environ["REPET_DATA"]
39 self.assertTrue(FileUtils.are2FilesIdentical(expFileName, self._outputFileName))
40
41 def test_run_with_map_file(self):
42 iLaunchMCL = LaunchMCL(self._inputFileName, isCluster2Map = True, doClean = False, verbosity = 1)
43 # iLaunchMCL.setCoverageThreshold(0.60)
44 iLaunchMCL.run()
45 expFastaFileName = "%s/Tools/DmelChr4_LTRharvest_MCL_expected.fa" % os.environ["REPET_DATA"]
46 expMapFileName = "%s/Tools/DmelChr4_LTRharvest_MCL_expected.map" % os.environ["REPET_DATA"]
47 obsMapFileName = "%s.map" % os.path.splitext(self._outputFileName)[0]
48
49 self.assertTrue(FileUtils.are2FilesIdentical(expFastaFileName, self._outputFileName))
50 self.assertTrue(FileUtils.are2FilesIdentical(expMapFileName, obsMapFileName))
51
52 os.remove(obsMapFileName)
53
54 def test_run_clusterConsensus_headers(self):
55 os.remove(self._inputFileName)
56 self._inputFileName = "DmelChr4_LTRharvest_MCL_ClusterConsHeaders_input.fa"
57 os.symlink("%s/Tools/%s" % (os.environ["REPET_DATA"], self._inputFileName), self._inputFileName)
58 iLaunchMCL = LaunchMCL(self._inputFileName, isClusterConsensusHeaders = True, doClean = True, verbosity = 1)
59 iLaunchMCL.run()
60 expFastaFileName = "%s/Tools/DmelChr4_LTRharvest_MCL_ClusterConsHeaders_expected.fa" % os.environ["REPET_DATA"]
61 self._outputFileName = "%s_MCL.fa" % os.path.splitext(self._inputFileName)[0]
62
63 self.assertTrue(FileUtils.are2FilesIdentical(expFastaFileName, self._outputFileName))
64
65 def test_run_as_script(self):
66 cmd = "LaunchMCL.py -i %s -j -v 6" % self._inputFileName
67 os.system(cmd)
68 expFileName = "%s/Tools/DmelChr4_LTRharvest_MCL_expected.fa" % os.environ["REPET_DATA"]
69 self.assertTrue(FileUtils.are2FilesIdentical(expFileName, self._outputFileName))
70 self.assertTrue(FileUtils.isRessourceExists("MCLtmpDirectory"))
71
72 def test_run_as_script_allParams(self):
73 cmd = "LaunchMCL.py -i %s -j -I 1.5 -T 0.0 -m -v 6" % self._inputFileName
74 os.system(cmd)
75 expFileName = "%s/Tools/DmelChr4_LTRharvest_MCL_expected.fa" % os.environ["REPET_DATA"]
76 self.assertTrue(FileUtils.are2FilesIdentical(expFileName, self._outputFileName))
77 self.assertTrue(FileUtils.isRessourceExists("MCLtmpDirectory"))
78
79 def test_run_as_script_without_join(self):
80 cmd = "LaunchMCL.py -i %s -v 2" % self._inputFileName
81 os.system(cmd)
82 expFileName = "%s/Tools/DmelChr4_LTRharvest_MCL_expected.fa" % os.environ["REPET_DATA"]
83 self.assertTrue(FileUtils.are2FilesIdentical(expFileName, self._outputFileName))
84 self.assertTrue(FileUtils.isRessourceExists("MCLtmpDirectory"))
85
86 if __name__ == "__main__":
87 unittest.main()