annotate commons/launcher/tests/Test_F_LaunchMCL.py @ 31:0ab839023fe4

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