diff commons/launcher/tests/Test_F_LaunchPhyML.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_LaunchPhyML.py	Mon Apr 29 03:20:15 2013 -0400
@@ -0,0 +1,83 @@
+import unittest
+import os
+from commons.core.utils.FileUtils import FileUtils
+from shutil import rmtree
+from commons.launcher.LaunchPhyML import LaunchPhyML
+
+
+class Test_F_LaunchPhyML(unittest.TestCase):
+    
+    def setUp(self):
+        self._curTestDir = os.getcwd()
+        self._testPrefix = 'test_LRA'
+        try:
+            os.makedirs(self._testPrefix)
+        except:pass
+        os.chdir(self._testPrefix)
+        
+
+        self._inputFastaFileName = "%s_input.fa" % self._testPrefix 
+        self._obsOutputFileName = self._inputFastaFileName +'_obs.phylip'
+        self._expOutputFileName = "%s_exp.phylip" % self._testPrefix 
+        self._writeInputFile()
+        
+#    def tearDown(self):
+#        os.chdir(self._curTestDir)
+#        try:
+#            rmtree(self._testPrefix)
+#        except:pass
+
+    def test_run(self):
+        #phylip use only same length sequences
+        self._writeExpFile()
+        ilauncher = LaunchPhyML(self._inputFastaFileName,verbosity=7)
+        ilauncher.run()
+        self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName))
+        
+        
+#    def test_run_as_script(self):
+#        self._writeExpOutputFile_wo_refseq()
+#        cmd = 'LaunchPhyML.py -i %s -o %s -v 5' % (self._inputFastaFileName, self._obsOutputFileName)
+#        os.system(cmd)
+#        self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName))    
+
+               
+    def _writeInputFile(self):        
+        InputFile = open(self._inputFastaFileName, 'w')
+        InputFile.write(""">sequence1
+GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC
+GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT
+GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAG
+>sequence2
+GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCGTGATCCTGGA
+GACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAGCCTGCTTCTCCCTCTGCCTG
+GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGG
+>sequence3
+ATCTTAGTTTTGCTGAGCGCCTTCATGGCTGCTTGACTATCAGACAGTATAGCAATGTCC
+TTGCCATGATAGTTCCTTTTCAGATTAAACTCTGCACAGCGTCCAATAGCACAGACTTCA
+GCTTGAATGCTGGTGTATCTGCCCATTGATTCGTGGTATTTCAACCTGGG
+""")
+        InputFile.close()    
+        
+    def _writeExpFile(self):        
+        InputFile = open(self._expOutputFileName, 'w')
+        InputFile.write(""" 3  170
+sequence1      GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGG
+sequence2      GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCG
+sequence3      ATCTTAGTTTTGCTGAGCGCCTTCATGGCTGCTTGACTATCAGACAGTAT
+
+CCCCGGGTTCGATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGG
+TGATCCTGGAGACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAG
+AGCAATGTCCTTGCCATGATAGTTCCTTTTCAGATTAAACTCTGCACAGC
+
+AGTTTGCATGTTCTCCCTGTGCCTGCGTGGGTTCTCTCCGGGTACTCCGG
+CCTGCTTCTCCCTCTGCCTGGGGCGGCACGGTGGTGTGGTGGTTAGCACT
+GTCCAATAGCACAGACTTCAGCTTGAATGCTGGTGTATCTGCCCATTGAT
+
+CTTCCTCCCACAGTCCAAAG
+GTTGCCTCACAGCAAGAAGG
+TCGTGGTATTTCAACCTGGG""")
+        InputFile.close()    
+                                   
+if __name__ == "__main__":
+    unittest.main()
\ No newline at end of file