diff commons/launcher/tests/Test_F_LaunchPromer.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_LaunchPromer.py	Mon Apr 29 03:20:15 2013 -0400
@@ -0,0 +1,231 @@
+import unittest
+import os
+from commons.core.utils.FileUtils import FileUtils
+from commons.launcher.LaunchPromer import LaunchPromer
+
+
+class Test_F_LaunchPromer(unittest.TestCase):
+    
+    def setUp(self):
+        self._queryFastaFileName = "query.fa"
+        self._refFastaFileName = "ref.fa"
+        self._writeInputFastaFiles()
+        self._expDeltaFileName = "expPromer.delta"
+        self._writeExpDeltaFile()
+        self._obsDeltaFileName = "obsPromer.delta"
+        self._obsCoordFileName= "obsPromer.coords"
+        self._expCoordFileName= "expPromer.coords"
+        
+    def tearDown(self):
+        try:
+            os.remove(self._queryFastaFileName)
+        except:pass
+        try:
+            os.remove(self._refFastaFileName)
+        except:pass
+        try:
+            os.remove(self._expDeltaFileName)
+        except:pass
+        try:
+            os.remove(self._obsDeltaFileName)
+        except:pass
+        
+    def test_run(self):
+        ilauncher = LaunchPromer(self._refFastaFileName, self._queryFastaFileName,"obsPromer",verbosity=1)
+        ilauncher.run()
+        self.assertTrue(FileUtils.are2FilesIdentical(self._expDeltaFileName, self._obsDeltaFileName))
+        
+    def test_run_as_script(self):
+        cmd = 'LaunchPromer.py --query %s --ref %s --prefix %s' % (self._refFastaFileName, self._queryFastaFileName, "obsPromer")
+        os.system(cmd)
+        self.assertTrue(FileUtils.are2FilesIdentical(self._expDeltaFileName, self._obsDeltaFileName))
+        
+    def test_run_as_script_gencoords_output(self):
+        self._writeExpGenCoordsFile()
+        cmd = 'LaunchPromer.py --query %s --ref %s --prefix %s --gencoords' % (self._refFastaFileName, self._queryFastaFileName, "obsPromer")
+        os.system(cmd)
+        self.assertTrue(FileUtils.are2FilesIdentical(self._expCoordFileName, self._obsCoordFileName))
+        os.remove(self._obsCoordFileName)
+        os.remove(self._expCoordFileName)
+    
+    def test_run_as_script_with_mincluster(self):
+        cmd = 'LaunchPromer.py --query %s --ref %s --prefix %s --mincluster 30' % (self._refFastaFileName, self._queryFastaFileName, "obsPromer")
+        os.system(cmd)
+        self.assertTrue(FileUtils.are2FilesIdentical(self._expDeltaFileName, self._obsDeltaFileName))      
+        
+    def test_run_as_script_showcoords_output(self):
+        self._writeExpShowCoordsFile()
+        cmd = 'LaunchPromer.py --query %s --ref %s --prefix %s --showcoords' % (self._refFastaFileName, self._queryFastaFileName, "obsPromer")
+        os.system(cmd)
+        self.assertTrue(FileUtils.are2FilesIdentical(self._expCoordFileName, self._obsCoordFileName))
+        os.remove(self._obsCoordFileName)
+        os.remove(self._expCoordFileName) 
+        
+    def _writeInputFastaFiles(self):
+        InputFile = open(self._queryFastaFileName, 'w')
+        InputFile.write('>Bovc-tA2:classI:SINE:SINE2/tRNA\n')
+        InputFile.write('GGGCTTCCCTGGTAGCTCAGCTGGTAAAGAATCCGCCTGCAATGCAGGAGACCCCGGTTC\n')
+        InputFile.write('GATTCCTGGGTCGGGAAGATCCCCTGGAGAAGGGATAGGCTACCCACTCCAGTATTCTTG\n')
+        InputFile.write('GGCTTCCCTGGTGGCTCAGACGGTAAAGAATCCGCCTGCAATGCGGGAGACCTGGGTTCG\n')
+        InputFile.write('ATCCCTGGGTTGGGAAGATCCCCTGGAGGAGGGCATGGCAACCCACTCCAGTATTCTTGC\n')
+        InputFile.write('CTGGAGAATCCCCATGGACAGAGGAGCCTGGCGGGCTACAGTCCATGGGGTCGCAAAGAG\n')
+        InputFile.write('TCGGACACGACTGAGCGACTAAGCACAGCACAG\n')
+        InputFile.write('>SUSINE2:classI:SINE:SINE2/tRNA\n')
+        InputFile.write('GGGAGTTCTCTGATGGCCTAGCGGGTTGAGGCTCCTGCGTTCTCACCGCTGTGGCTCTGG\n')
+        InputFile.write('TTGCTGCTGTGCGGCGTAGGTTCAATCCCTGGCCCAGGAATTCCCACATACTGCCTGTGT\n')
+        InputFile.write('GGCAAAAAAGAAAAAAAAAAAAAATACAAAAAAAAAAAAAACAAGAGAGAACCTGAAATA\n')
+        InputFile.write('AACGTTGCAACTCTCATTNAAAAAAAAAAA\n')
+        InputFile.write('>SINE1A_SS:classI:SINE:SINE2/tRNA\n')
+        InputFile.write('GGGAGTTCTCTTGTGGCACAGCAGGTTAAGGATCCAGCGTTGTCACTGCAGTGGCTTGGG\n')
+        InputFile.write('TCGCTGCTGTGGCACGGGTTCAATCCCTGGCCCAGGAACTTCCACATGCCACGGGCATGG\n')
+        InputFile.write('CCAAAAAAAAA\n')
+        InputFile.write('>SINE2-1_Pca:classI:SINE:SINE2/tRNA\n')
+        InputFile.write('GGGCAGTGGTGGTTCAGTGGTAGAATTCTTGCCTTCCATGCGGGAGACCCGGGTTCGATT\n')
+        InputFile.write('CCCGGCCAGTGCACCTCATGCGCAGCCACCACCCGTCTGTCAGTGGAGGCTTGCGTGTTG\n')
+        InputFile.write('CTGTGATGCTGAACAGGTTTCAGCGGAGCTTCCAGACTAAGACGGACTAGGAAGAAAGGC\n')
+        InputFile.write('CTGGCGATCTACTTCTGAAAATCAGCCAATGAAAACCCTGTGGATCACAGTGGTCTGATC\n')
+        InputFile.write('TGCAACTGATCATGGGGATGGCGCAGGACCGGGCAGCGTTTTGTTCTATTGTGCATGGGG\n')
+        InputFile.write('TCGCCATGAGTCGGGCCGACTCGATGGCAGCTAACAACAA\n')
+        InputFile.write('>SINE_FR2:classI:SINE:?\n')
+        InputFile.write('GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC\n')
+        InputFile.write('GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT\n')
+        InputFile.write('GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGA\n')
+        InputFile.write('TTGGGGATTAGGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA\n')
+        InputFile.write('TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCCAGGGTGTACC\n')
+        InputFile.write('CTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCCCGCGACCCTCAGTGGAGGAA\n')
+        InputFile.write('CAAGCGGTAGAAAGTGAGTGAGTGAGTGA\n')
+        InputFile.write('>SINEC1B2_CF:classI:SINE:?\n')
+        InputFile.write('GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCGTGATCCTGGA\n')
+        InputFile.write('GACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAGCCTGCTTCTCCCTCTGCCTG\n')
+        InputFile.write('TGTCTCTGCCTCTCTCTCTCTCTGTGTCTCTCATGAATAAATAA\n')
+        InputFile.write('>ALPINE1:classI:SINE:SINE2/tRNA\n')
+        InputFile.write('GGGGAGGGTATAGCTCAGTGGTAGAGCGCATGCTTAGCATGCACGAGGTCCTGGGTTCAA\n')
+        InputFile.write('TCCCCAGTACCTCCATTAAAAATAAATAAATAAATAAACCTAATTACCTCCCCCACCAAA\n')
+        InputFile.write('AAAAAAA\n')
+        InputFile.close()
+        
+        InputFile = open(self._refFastaFileName, 'w')
+        InputFile.write('>SINE_FR2:classI:SINE:?\n')
+        InputFile.write('GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC\n')
+        InputFile.write('GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT\n')
+        InputFile.write('GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGA\n')
+        InputFile.write('TTGGGGATTAGGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA\n')
+        InputFile.write('TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCCAGGGTGTACC\n')
+        InputFile.write('CTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCCCG\n')
+        InputFile.write('CAAGCGGTAGAAAGTGAGTGAGTGAGTGA\n')
+        InputFile.write('>SINEC1B2_CF:classI:SINE:?\n')
+        InputFile.write('GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCGTGATCCTGGA\n')
+        InputFile.write('GACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAGCCTGCTTCTCCCTCTGCCTG\n')
+        InputFile.write('TGTCTCTGCCTCTCTCTCTCTCTGTGTCTCTCATGAATAAA\n')
+        InputFile.close()
+        
+    def _writeExpDeltaFile(self):
+        with open(self._expDeltaFileName, 'w') as f:
+            f.write("%s %s\n" %(os.path.abspath(self._queryFastaFileName), os.path.abspath(self._refFastaFileName)))
+            f.write('PROMER\n')
+            f.write('>SINE_FR2:classI:SINE:? SINE_FR2:classI:SINE:? 389 371\n')
+            f.write('1 387 1 369 6 6 10\n')
+            f.write('115\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('0\n')
+            f.write('2 388 2 370 6 6 8\n')
+            f.write('115\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('0\n')
+            f.write('3 389 3 371 6 6 16\n')
+            f.write('115\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('0\n')
+            f.write('388 2 370 2 6 6 6\n')
+            f.write('10\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('0\n')
+            f.write('387 1 369 1 6 6 5\n')
+            f.write('10\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('0\n')
+            f.write('389 3 371 3 6 6 4\n')
+            f.write('11\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('1\n')
+            f.write('0\n')
+            f.write('>SINEC1B2_CF:classI:SINE:? SINEC1B2_CF:classI:SINE:? 164 161\n')
+            f.write('1 159 1 159 0 0 2\n')
+            f.write('0\n')
+            f.write('3 161 3 161 0 0 2\n')
+            f.write('0\n')
+            f.write('161 3 161 3 0 0 0\n')
+            f.write('0\n')
+            f.write('160 2 160 2 0 0 2\n')
+            f.write('0\n')
+            f.write('159 1 159 1 0 0 4\n')
+            f.write('0\n')
+            f.write('2 160 2 160 0 0 4\n')
+            f.write('0\n')
+       
+       
+
+        
+    def _writeExpGenCoordsFile(self):
+        with open(self._expCoordFileName, 'w') as f:
+            f.write("%s %s\n" %(os.path.abspath(self._queryFastaFileName), os.path.abspath(self._refFastaFileName)))
+            f.write('PROMER\n\n')
+            f.write('    [S1]     [E1]  |     [S2]     [E2]  |  [LEN 1]  [LEN 2]  |  [% IDY]  [% SIM]  [% STP]  | [FRM]  [TAGS]\n')
+            f.write('==============================================================================================================\n')
+            f.write('       1      159  |        1      159  |      159      159  |   100.00   100.00     1.89  |  1  1  SINEC1B2_CF:classI:SINE:?\tSINEC1B2_CF:classI:SINE:?\n')
+            f.write('       2      160  |        2      160  |      159      159  |   100.00   100.00     3.77  |  2  2  SINEC1B2_CF:classI:SINE:?\tSINEC1B2_CF:classI:SINE:?\n')
+            f.write('       3      161  |        3      161  |      159      159  |   100.00   100.00     1.89  |  3  3  SINEC1B2_CF:classI:SINE:?\tSINEC1B2_CF:classI:SINE:?\n')
+            f.write('     159        1  |      159        1  |      159      159  |   100.00   100.00     3.77  | -3 -3  SINEC1B2_CF:classI:SINE:?\tSINEC1B2_CF:classI:SINE:?\n')
+            f.write('     160        2  |      160        2  |      159      159  |   100.00   100.00     1.89  | -2 -2  SINEC1B2_CF:classI:SINE:?\tSINEC1B2_CF:classI:SINE:?\n')
+            f.write('     161        3  |      161        3  |      159      159  |   100.00   100.00     0.00  | -1 -1  SINEC1B2_CF:classI:SINE:?\tSINEC1B2_CF:classI:SINE:?\n')
+            f.write('       1      387  |        1      369  |      387      369  |    95.35    95.35     3.88  |  1  1  SINE_FR2:classI:SINE:?\tSINE_FR2:classI:SINE:?\n')
+            f.write('       2      388  |        2      370  |      387      369  |    95.35    95.35     3.10  |  2  2  SINE_FR2:classI:SINE:?\tSINE_FR2:classI:SINE:?\n')
+            f.write('       3      389  |        3      371  |      387      369  |    95.35    95.35     6.20  |  3  3  SINE_FR2:classI:SINE:?\tSINE_FR2:classI:SINE:?\n')
+            f.write('     387        1  |      369        1  |      387      369  |    95.35    95.35     1.94  | -3 -3  SINE_FR2:classI:SINE:?\tSINE_FR2:classI:SINE:?\n')
+            f.write('     388        2  |      370        2  |      387      369  |    95.35    95.35     2.33  | -2 -2  SINE_FR2:classI:SINE:?\tSINE_FR2:classI:SINE:?\n')
+            f.write('     389        3  |      371        3  |      387      369  |    95.35    95.35     1.55  | -1 -1  SINE_FR2:classI:SINE:?\tSINE_FR2:classI:SINE:?\n')
+    
+        
+    def _writeExpShowCoordsFile(self):
+        with open(self._expCoordFileName, 'w') as f:
+            f.write("%s %s\n" %(os.path.abspath(self._queryFastaFileName), os.path.abspath(self._refFastaFileName)))
+            f.write('PROMER\n\n')
+            f.write('[S1]\t[E1]\t[S2]\t[E2]\t[LEN 1]\t[LEN 2]\t[% IDY]\t[% SIM]\t[% STP]\t[LEN R]\t[LEN Q]\t[COV R]\t[COV Q]\t[FRM]\t[TAGS]\n')
+            f.write('1\t159\t1\t159\t159\t159\t100.00\t100.00\t1.89\t164\t161\t96.95\t98.76\t1\t1\tSINEC1B2_CF:classI:SINE:?\tSINEC1B2_CF:classI:SINE:?\n')
+            f.write('2\t160\t2\t160\t159\t159\t100.00\t100.00\t3.77\t164\t161\t96.95\t98.76\t2\t2\tSINEC1B2_CF:classI:SINE:?\tSINEC1B2_CF:classI:SINE:?\n')
+            f.write('3\t161\t3\t161\t159\t159\t100.00\t100.00\t1.89\t164\t161\t96.95\t98.76\t3\t3\tSINEC1B2_CF:classI:SINE:?\tSINEC1B2_CF:classI:SINE:?\n')
+            f.write('159\t1\t159\t1\t159\t159\t100.00\t100.00\t3.77\t164\t161\t96.95\t98.76\t-3\t-3\tSINEC1B2_CF:classI:SINE:?\tSINEC1B2_CF:classI:SINE:?\n')
+            f.write('160\t2\t160\t2\t159\t159\t100.00\t100.00\t1.89\t164\t161\t96.95\t98.76\t-2\t-2\tSINEC1B2_CF:classI:SINE:?\tSINEC1B2_CF:classI:SINE:?\n')
+            f.write('161\t3\t161\t3\t159\t159\t100.00\t100.00\t0.00\t164\t161\t96.95\t98.76\t-1\t-1\tSINEC1B2_CF:classI:SINE:?\tSINEC1B2_CF:classI:SINE:?\n')
+            f.write('1\t387\t1\t369\t387\t369\t95.35\t95.35\t3.88\t389\t371\t99.49\t99.46\t1\t1\tSINE_FR2:classI:SINE:?\tSINE_FR2:classI:SINE:?\n')
+            f.write('2\t388\t2\t370\t387\t369\t95.35\t95.35\t3.10\t389\t371\t99.49\t99.46\t2\t2\tSINE_FR2:classI:SINE:?\tSINE_FR2:classI:SINE:?\n')
+            f.write('3\t389\t3\t371\t387\t369\t95.35\t95.35\t6.20\t389\t371\t99.49\t99.46\t3\t3\tSINE_FR2:classI:SINE:?\tSINE_FR2:classI:SINE:?\n')
+            f.write('387\t1\t369\t1\t387\t369\t95.35\t95.35\t1.94\t389\t371\t99.49\t99.46\t-3\t-3\tSINE_FR2:classI:SINE:?\tSINE_FR2:classI:SINE:?\n')
+            f.write('388\t2\t370\t2\t387\t369\t95.35\t95.35\t2.33\t389\t371\t99.49\t99.46\t-2\t-2\tSINE_FR2:classI:SINE:?\tSINE_FR2:classI:SINE:?\n')
+            f.write('389\t3\t371\t3\t387\t369\t95.35\t95.35\t1.55\t389\t371\t99.49\t99.46\t-1\t-1\tSINE_FR2:classI:SINE:?\tSINE_FR2:classI:SINE:?\n')
+
+if __name__ == "__main__":
+    unittest.main()
\ No newline at end of file