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

Uploaded
author m-zytnicki
date Mon, 29 Apr 2013 03:20:15 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commons/launcher/tests/Test_F_LaunchMCL.py	Mon Apr 29 03:20:15 2013 -0400
@@ -0,0 +1,87 @@
+from commons.core.utils.FileUtils import FileUtils
+import unittest
+import os
+import shutil
+from commons.launcher.LaunchMCL import LaunchMCL
+
+class Test_F_LaunchMCL(unittest.TestCase):
+# TODO: test query coverage filter
+
+    def setUp(self):
+        self._inputFileName = "DmelChr4_LTRharvest_expected_with_default_params.fa"
+        try:
+            shutil.rmtree("MCLtmpDirectory")
+            os.remove(self._inputFileName)
+        except:
+            pass
+        try:
+            os.symlink("%s/Tools/%s" % (os.environ["REPET_DATA"], self._inputFileName), self._inputFileName)
+        except:
+            pass
+        self._outputFileName = "%s_MCL.fa" % os.path.splitext(self._inputFileName)[0]
+        
+    def tearDown(self):
+        try:
+            os.remove(self._inputFileName)
+            os.remove(self._outputFileName)
+            shutil.rmtree("MCLtmpDirectory")
+        except:
+            pass
+        try:
+            os.remove("DmelChr4_LTRharvest_expected_with_default_params_MCL.map")
+        except:
+            pass    
+        
+    def test_run(self):
+        iLaunchMCL = LaunchMCL(self._inputFileName, doClean = True, verbosity = 1)
+        iLaunchMCL.run()
+        expFileName = "%s/Tools/DmelChr4_LTRharvest_MCL_expected.fa" % os.environ["REPET_DATA"]
+        self.assertTrue(FileUtils.are2FilesIdentical(expFileName, self._outputFileName))
+
+    def test_run_with_map_file(self):
+        iLaunchMCL = LaunchMCL(self._inputFileName, isCluster2Map = True, doClean = False, verbosity = 1)
+#        iLaunchMCL.setCoverageThreshold(0.60)
+        iLaunchMCL.run()
+        expFastaFileName = "%s/Tools/DmelChr4_LTRharvest_MCL_expected.fa" % os.environ["REPET_DATA"]
+        expMapFileName = "%s/Tools/DmelChr4_LTRharvest_MCL_expected.map" % os.environ["REPET_DATA"]
+        obsMapFileName = "%s.map" % os.path.splitext(self._outputFileName)[0]
+        
+        self.assertTrue(FileUtils.are2FilesIdentical(expFastaFileName, self._outputFileName))
+        self.assertTrue(FileUtils.are2FilesIdentical(expMapFileName, obsMapFileName))
+        
+        os.remove(obsMapFileName)
+
+    def test_run_clusterConsensus_headers(self):
+        os.remove(self._inputFileName)
+        self._inputFileName = "DmelChr4_LTRharvest_MCL_ClusterConsHeaders_input.fa"
+        os.symlink("%s/Tools/%s" % (os.environ["REPET_DATA"], self._inputFileName), self._inputFileName)
+        iLaunchMCL = LaunchMCL(self._inputFileName, isClusterConsensusHeaders = True, doClean = True, verbosity = 1)
+        iLaunchMCL.run()
+        expFastaFileName = "%s/Tools/DmelChr4_LTRharvest_MCL_ClusterConsHeaders_expected.fa" % os.environ["REPET_DATA"]
+        self._outputFileName = "%s_MCL.fa" % os.path.splitext(self._inputFileName)[0]
+        
+        self.assertTrue(FileUtils.are2FilesIdentical(expFastaFileName, self._outputFileName))
+      
+    def test_run_as_script(self):
+        cmd = "LaunchMCL.py -i %s -j -v 6" % self._inputFileName
+        os.system(cmd)
+        expFileName = "%s/Tools/DmelChr4_LTRharvest_MCL_expected.fa" % os.environ["REPET_DATA"]
+        self.assertTrue(FileUtils.are2FilesIdentical(expFileName, self._outputFileName))
+        self.assertTrue(FileUtils.isRessourceExists("MCLtmpDirectory"))
+
+    def test_run_as_script_allParams(self):
+        cmd = "LaunchMCL.py -i %s -j -I 1.5 -T 0.0 -m -v 6" % self._inputFileName
+        os.system(cmd)
+        expFileName = "%s/Tools/DmelChr4_LTRharvest_MCL_expected.fa" % os.environ["REPET_DATA"]
+        self.assertTrue(FileUtils.are2FilesIdentical(expFileName, self._outputFileName))
+        self.assertTrue(FileUtils.isRessourceExists("MCLtmpDirectory"))
+
+    def test_run_as_script_without_join(self):
+        cmd = "LaunchMCL.py -i %s -v 2" % self._inputFileName
+        os.system(cmd)
+        expFileName = "%s/Tools/DmelChr4_LTRharvest_MCL_expected.fa" % os.environ["REPET_DATA"]
+        self.assertTrue(FileUtils.are2FilesIdentical(expFileName, self._outputFileName))
+        self.assertTrue(FileUtils.isRessourceExists("MCLtmpDirectory"))
+        
+if __name__ == "__main__":
+    unittest.main()
\ No newline at end of file