18
|
1 import unittest
|
|
2 import os
|
|
3 from commons.core.utils.FileUtils import FileUtils
|
|
4 from commons.launcher.LaunchNucmer import LaunchNucmer
|
|
5
|
|
6 class Test_F_LaunchNucmer(unittest.TestCase):
|
|
7
|
|
8 def setUp(self):
|
|
9 self._queryFastaFileName = "query.fa"
|
|
10 self._refFastaFileName = "ref.fa"
|
|
11 self._writeInputFastaFiles()
|
|
12 self._expDeltaFileName = "expNucmer.delta"
|
|
13 self._writeExpDeltaFile()
|
|
14 self._obsDeltaFileName = "obsNucmer.delta"
|
|
15 self._obsCoordFileName= "obsNucmer.coords"
|
|
16 self._expCoordFileName= "expNucmer.coords"
|
|
17
|
|
18 def tearDown(self):
|
|
19 try:
|
|
20 os.remove(self._queryFastaFileName)
|
|
21 except:pass
|
|
22 try:
|
|
23 os.remove(self._refFastaFileName)
|
|
24 except:pass
|
|
25 try:
|
|
26 os.remove(self._expDeltaFileName)
|
|
27 except:pass
|
|
28 try:
|
|
29 os.remove(self._obsDeltaFileName)
|
|
30 except:pass
|
|
31
|
|
32 def test_run(self):
|
|
33 ilauncher = LaunchNucmer(self._refFastaFileName, self._queryFastaFileName,"obsNucmer",verbosity=1)
|
|
34 ilauncher.run()
|
|
35 self.assertTrue(FileUtils.are2FilesIdentical(self._expDeltaFileName, self._obsDeltaFileName))
|
|
36
|
|
37 def test_run_as_script(self):
|
|
38 cmd = 'LaunchNucmer.py --query %s --ref %s --prefix %s' % (self._refFastaFileName, self._queryFastaFileName, "obsNucmer")
|
|
39 os.system(cmd)
|
|
40 self.assertTrue(FileUtils.are2FilesIdentical(self._expDeltaFileName, self._obsDeltaFileName))
|
|
41
|
|
42 def test_run_as_script_gencoords_output(self):
|
|
43 self._writeExpGenCoordsFile()
|
|
44 cmd = 'LaunchNucmer.py --query %s --ref %s --prefix %s --gencoords' % (self._refFastaFileName, self._queryFastaFileName, "obsNucmer")
|
|
45 os.system(cmd)
|
|
46 self.assertTrue(FileUtils.are2FilesIdentical(self._expCoordFileName, self._obsCoordFileName))
|
|
47 os.remove(self._obsCoordFileName)
|
|
48 os.remove(self._expCoordFileName)
|
|
49
|
|
50 def test_run_as_script_with_mincluster(self):
|
|
51 cmd = 'LaunchNucmer.py --query %s --ref %s --prefix %s --mincluster 30' % (self._refFastaFileName, self._queryFastaFileName, "obsNucmer")
|
|
52 os.system(cmd)
|
|
53 self.assertTrue(FileUtils.are2FilesIdentical(self._expDeltaFileName, self._obsDeltaFileName))
|
|
54
|
|
55 def test_run_as_script_showcoords_output(self):
|
|
56 self._writeExpShowCoordsFile()
|
|
57 cmd = 'LaunchNucmer.py --query %s --ref %s --prefix %s --showcoords' % (self._refFastaFileName, self._queryFastaFileName, "obsNucmer")
|
|
58 os.system(cmd)
|
|
59 self.assertTrue(FileUtils.are2FilesIdentical(self._expCoordFileName, self._obsCoordFileName))
|
|
60 os.remove(self._obsCoordFileName)
|
|
61 os.remove(self._expCoordFileName)
|
|
62
|
|
63 def _writeInputFastaFiles(self):
|
|
64 InputFile = open(self._queryFastaFileName, 'w')
|
|
65 InputFile.write('>Bovc-tA2:classI:SINE:SINE2/tRNA\n')
|
|
66 InputFile.write('GGGCTTCCCTGGTAGCTCAGCTGGTAAAGAATCCGCCTGCAATGCAGGAGACCCCGGTTC\n')
|
|
67 InputFile.write('GATTCCTGGGTCGGGAAGATCCCCTGGAGAAGGGATAGGCTACCCACTCCAGTATTCTTG\n')
|
|
68 InputFile.write('GGCTTCCCTGGTGGCTCAGACGGTAAAGAATCCGCCTGCAATGCGGGAGACCTGGGTTCG\n')
|
|
69 InputFile.write('ATCCCTGGGTTGGGAAGATCCCCTGGAGGAGGGCATGGCAACCCACTCCAGTATTCTTGC\n')
|
|
70 InputFile.write('CTGGAGAATCCCCATGGACAGAGGAGCCTGGCGGGCTACAGTCCATGGGGTCGCAAAGAG\n')
|
|
71 InputFile.write('TCGGACACGACTGAGCGACTAAGCACAGCACAG\n')
|
|
72 InputFile.write('>SUSINE2:classI:SINE:SINE2/tRNA\n')
|
|
73 InputFile.write('GGGAGTTCTCTGATGGCCTAGCGGGTTGAGGCTCCTGCGTTCTCACCGCTGTGGCTCTGG\n')
|
|
74 InputFile.write('TTGCTGCTGTGCGGCGTAGGTTCAATCCCTGGCCCAGGAATTCCCACATACTGCCTGTGT\n')
|
|
75 InputFile.write('GGCAAAAAAGAAAAAAAAAAAAAATACAAAAAAAAAAAAAACAAGAGAGAACCTGAAATA\n')
|
|
76 InputFile.write('AACGTTGCAACTCTCATTNAAAAAAAAAAA\n')
|
|
77 InputFile.write('>SINE1A_SS:classI:SINE:SINE2/tRNA\n')
|
|
78 InputFile.write('GGGAGTTCTCTTGTGGCACAGCAGGTTAAGGATCCAGCGTTGTCACTGCAGTGGCTTGGG\n')
|
|
79 InputFile.write('TCGCTGCTGTGGCACGGGTTCAATCCCTGGCCCAGGAACTTCCACATGCCACGGGCATGG\n')
|
|
80 InputFile.write('CCAAAAAAAAA\n')
|
|
81 InputFile.write('>SINE2-1_Pca:classI:SINE:SINE2/tRNA\n')
|
|
82 InputFile.write('GGGCAGTGGTGGTTCAGTGGTAGAATTCTTGCCTTCCATGCGGGAGACCCGGGTTCGATT\n')
|
|
83 InputFile.write('CCCGGCCAGTGCACCTCATGCGCAGCCACCACCCGTCTGTCAGTGGAGGCTTGCGTGTTG\n')
|
|
84 InputFile.write('CTGTGATGCTGAACAGGTTTCAGCGGAGCTTCCAGACTAAGACGGACTAGGAAGAAAGGC\n')
|
|
85 InputFile.write('CTGGCGATCTACTTCTGAAAATCAGCCAATGAAAACCCTGTGGATCACAGTGGTCTGATC\n')
|
|
86 InputFile.write('TGCAACTGATCATGGGGATGGCGCAGGACCGGGCAGCGTTTTGTTCTATTGTGCATGGGG\n')
|
|
87 InputFile.write('TCGCCATGAGTCGGGCCGACTCGATGGCAGCTAACAACAA\n')
|
|
88 InputFile.write('>SINE_FR2:classI:SINE:?\n')
|
|
89 InputFile.write('GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC\n')
|
|
90 InputFile.write('GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT\n')
|
|
91 InputFile.write('GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGA\n')
|
|
92 InputFile.write('TTGGGGATTAGGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA\n')
|
|
93 InputFile.write('TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCCAGGGTGTACC\n')
|
|
94 InputFile.write('CTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCCCGCGACCCTCAGTGGAGGAA\n')
|
|
95 InputFile.write('CAAGCGGTAGAAAGTGAGTGAGTGAGTGA\n')
|
|
96 InputFile.write('>SINEC1B2_CF:classI:SINE:?\n')
|
|
97 InputFile.write('GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCGTGATCCTGGA\n')
|
|
98 InputFile.write('GACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAGCCTGCTTCTCCCTCTGCCTG\n')
|
|
99 InputFile.write('TGTCTCTGCCTCTCTCTCTCTCTGTGTCTCTCATGAATAAATAA\n')
|
|
100 InputFile.write('>ALPINE1:classI:SINE:SINE2/tRNA\n')
|
|
101 InputFile.write('GGGGAGGGTATAGCTCAGTGGTAGAGCGCATGCTTAGCATGCACGAGGTCCTGGGTTCAA\n')
|
|
102 InputFile.write('TCCCCAGTACCTCCATTAAAAATAAATAAATAAATAAACCTAATTACCTCCCCCACCAAA\n')
|
|
103 InputFile.write('AAAAAAA\n')
|
|
104 InputFile.close()
|
|
105
|
|
106 InputFile = open(self._refFastaFileName, 'w')
|
|
107 InputFile.write('>SINE_FR2:classI:SINE:?\n')
|
|
108 InputFile.write('GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC\n')
|
|
109 InputFile.write('GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT\n')
|
|
110 InputFile.write('GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGA\n')
|
|
111 InputFile.write('TTGGGGATTAGGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA\n')
|
|
112 InputFile.write('TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCCAGGGTGTACC\n')
|
|
113 InputFile.write('CTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCCCG\n')
|
|
114 InputFile.write('CAAGCGGTAGAAAGTGAGTGAGTGAGTGA\n')
|
|
115 InputFile.write('>SINEC1B2_CF:classI:SINE:?\n')
|
|
116 InputFile.write('GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCGTGATCCTGGA\n')
|
|
117 InputFile.write('GACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAGCCTGCTTCTCCCTCTGCCTG\n')
|
|
118 InputFile.write('TGTCTCTGCCTCTCTCTCTCTCTGTGTCTCTCATGAATAAA\n')
|
|
119 InputFile.close()
|
|
120
|
|
121 def _writeExpDeltaFile(self):
|
|
122 f = open(self._expDeltaFileName, 'w')
|
|
123 f.write("%s %s\n" %(os.path.abspath(self._queryFastaFileName), os.path.abspath(self._refFastaFileName)))
|
|
124 f.write('NUCMER\n')
|
|
125 f.write('>SINE_FR2:classI:SINE:? SINE_FR2:classI:SINE:? 389 371\n')
|
|
126 f.write('1 343 1 343 0 0 0\n')
|
|
127 f.write('0\n')
|
|
128 f.write('>SINEC1B2_CF:classI:SINE:? SINEC1B2_CF:classI:SINE:? 164 161\n')
|
|
129 f.write('1 161 1 161 0 0 0\n')
|
|
130 f.write('0\n')
|
|
131 f.close()
|
|
132
|
|
133 def _writeExpGenCoordsFile(self):
|
|
134 f = open(self._expCoordFileName, 'w')
|
|
135 f.write("%s %s\n" %(os.path.abspath(self._queryFastaFileName), os.path.abspath(self._refFastaFileName)))
|
|
136 f.write('NUCMER\n\n')
|
|
137 f.write(' [S1] [E1] | [S2] [E2] | [LEN 1] [LEN 2] | [% IDY] | [TAGS]\n')
|
|
138 f.write('=====================================================================================\n')
|
|
139 f.write(' 1 161 | 1 161 | 161 161 | 100.00 | SINEC1B2_CF:classI:SINE:?\tSINEC1B2_CF:classI:SINE:?\n')
|
|
140 f.write(' 1 343 | 1 343 | 343 343 | 100.00 | SINE_FR2:classI:SINE:?\tSINE_FR2:classI:SINE:?\n')
|
|
141 f.close()
|
|
142
|
|
143 def _writeExpShowCoordsFile(self):
|
|
144 f = open(self._expCoordFileName, 'w')
|
|
145 f.write("%s %s\n" %(os.path.abspath(self._queryFastaFileName), os.path.abspath(self._refFastaFileName)))
|
|
146 f.write('NUCMER\n\n')
|
|
147 f.write('[S1]\t[E1]\t[S2]\t[E2]\t[LEN 1]\t[LEN 2]\t[% IDY]\t[LEN R]\t[LEN Q]\t[COV R]\t[COV Q]\t[FRM]\t[TAGS]\n')
|
|
148 f.write('1\t161\t1\t161\t161\t161\t100.00\t164\t161\t98.17\t100.00\t1\t1\tSINEC1B2_CF:classI:SINE:?\tSINEC1B2_CF:classI:SINE:?\n')
|
|
149 f.write('1\t343\t1\t343\t343\t343\t100.00\t389\t371\t88.17\t92.45\t1\t1\tSINE_FR2:classI:SINE:?\tSINE_FR2:classI:SINE:?\n')
|
|
150 f.close()
|
|
151
|
|
152 if __name__ == "__main__":
|
|
153 unittest.main() |