18
|
1 import unittest
|
|
2 import os
|
|
3 from commons.core.utils.FileUtils import FileUtils
|
|
4 from commons.launcher.LaunchPromer import LaunchPromer
|
|
5
|
|
6
|
|
7 class Test_F_LaunchPromer(unittest.TestCase):
|
|
8
|
|
9 def setUp(self):
|
|
10 self._queryFastaFileName = "query.fa"
|
|
11 self._refFastaFileName = "ref.fa"
|
|
12 self._writeInputFastaFiles()
|
|
13 self._expDeltaFileName = "expPromer.delta"
|
|
14 self._writeExpDeltaFile()
|
|
15 self._obsDeltaFileName = "obsPromer.delta"
|
|
16 self._obsCoordFileName= "obsPromer.coords"
|
|
17 self._expCoordFileName= "expPromer.coords"
|
|
18
|
|
19 def tearDown(self):
|
|
20 try:
|
|
21 os.remove(self._queryFastaFileName)
|
|
22 except:pass
|
|
23 try:
|
|
24 os.remove(self._refFastaFileName)
|
|
25 except:pass
|
|
26 try:
|
|
27 os.remove(self._expDeltaFileName)
|
|
28 except:pass
|
|
29 try:
|
|
30 os.remove(self._obsDeltaFileName)
|
|
31 except:pass
|
|
32
|
|
33 def test_run(self):
|
|
34 ilauncher = LaunchPromer(self._refFastaFileName, self._queryFastaFileName,"obsPromer",verbosity=1)
|
|
35 ilauncher.run()
|
|
36 self.assertTrue(FileUtils.are2FilesIdentical(self._expDeltaFileName, self._obsDeltaFileName))
|
|
37
|
|
38 def test_run_as_script(self):
|
|
39 cmd = 'LaunchPromer.py --query %s --ref %s --prefix %s' % (self._refFastaFileName, self._queryFastaFileName, "obsPromer")
|
|
40 os.system(cmd)
|
|
41 self.assertTrue(FileUtils.are2FilesIdentical(self._expDeltaFileName, self._obsDeltaFileName))
|
|
42
|
|
43 def test_run_as_script_gencoords_output(self):
|
|
44 self._writeExpGenCoordsFile()
|
|
45 cmd = 'LaunchPromer.py --query %s --ref %s --prefix %s --gencoords' % (self._refFastaFileName, self._queryFastaFileName, "obsPromer")
|
|
46 os.system(cmd)
|
|
47 self.assertTrue(FileUtils.are2FilesIdentical(self._expCoordFileName, self._obsCoordFileName))
|
|
48 os.remove(self._obsCoordFileName)
|
|
49 os.remove(self._expCoordFileName)
|
|
50
|
|
51 def test_run_as_script_with_mincluster(self):
|
|
52 cmd = 'LaunchPromer.py --query %s --ref %s --prefix %s --mincluster 30' % (self._refFastaFileName, self._queryFastaFileName, "obsPromer")
|
|
53 os.system(cmd)
|
|
54 self.assertTrue(FileUtils.are2FilesIdentical(self._expDeltaFileName, self._obsDeltaFileName))
|
|
55
|
|
56 def test_run_as_script_showcoords_output(self):
|
|
57 self._writeExpShowCoordsFile()
|
|
58 cmd = 'LaunchPromer.py --query %s --ref %s --prefix %s --showcoords' % (self._refFastaFileName, self._queryFastaFileName, "obsPromer")
|
|
59 os.system(cmd)
|
|
60 self.assertTrue(FileUtils.are2FilesIdentical(self._expCoordFileName, self._obsCoordFileName))
|
|
61 os.remove(self._obsCoordFileName)
|
|
62 os.remove(self._expCoordFileName)
|
|
63
|
|
64 def _writeInputFastaFiles(self):
|
|
65 InputFile = open(self._queryFastaFileName, 'w')
|
|
66 InputFile.write('>Bovc-tA2:classI:SINE:SINE2/tRNA\n')
|
|
67 InputFile.write('GGGCTTCCCTGGTAGCTCAGCTGGTAAAGAATCCGCCTGCAATGCAGGAGACCCCGGTTC\n')
|
|
68 InputFile.write('GATTCCTGGGTCGGGAAGATCCCCTGGAGAAGGGATAGGCTACCCACTCCAGTATTCTTG\n')
|
|
69 InputFile.write('GGCTTCCCTGGTGGCTCAGACGGTAAAGAATCCGCCTGCAATGCGGGAGACCTGGGTTCG\n')
|
|
70 InputFile.write('ATCCCTGGGTTGGGAAGATCCCCTGGAGGAGGGCATGGCAACCCACTCCAGTATTCTTGC\n')
|
|
71 InputFile.write('CTGGAGAATCCCCATGGACAGAGGAGCCTGGCGGGCTACAGTCCATGGGGTCGCAAAGAG\n')
|
|
72 InputFile.write('TCGGACACGACTGAGCGACTAAGCACAGCACAG\n')
|
|
73 InputFile.write('>SUSINE2:classI:SINE:SINE2/tRNA\n')
|
|
74 InputFile.write('GGGAGTTCTCTGATGGCCTAGCGGGTTGAGGCTCCTGCGTTCTCACCGCTGTGGCTCTGG\n')
|
|
75 InputFile.write('TTGCTGCTGTGCGGCGTAGGTTCAATCCCTGGCCCAGGAATTCCCACATACTGCCTGTGT\n')
|
|
76 InputFile.write('GGCAAAAAAGAAAAAAAAAAAAAATACAAAAAAAAAAAAAACAAGAGAGAACCTGAAATA\n')
|
|
77 InputFile.write('AACGTTGCAACTCTCATTNAAAAAAAAAAA\n')
|
|
78 InputFile.write('>SINE1A_SS:classI:SINE:SINE2/tRNA\n')
|
|
79 InputFile.write('GGGAGTTCTCTTGTGGCACAGCAGGTTAAGGATCCAGCGTTGTCACTGCAGTGGCTTGGG\n')
|
|
80 InputFile.write('TCGCTGCTGTGGCACGGGTTCAATCCCTGGCCCAGGAACTTCCACATGCCACGGGCATGG\n')
|
|
81 InputFile.write('CCAAAAAAAAA\n')
|
|
82 InputFile.write('>SINE2-1_Pca:classI:SINE:SINE2/tRNA\n')
|
|
83 InputFile.write('GGGCAGTGGTGGTTCAGTGGTAGAATTCTTGCCTTCCATGCGGGAGACCCGGGTTCGATT\n')
|
|
84 InputFile.write('CCCGGCCAGTGCACCTCATGCGCAGCCACCACCCGTCTGTCAGTGGAGGCTTGCGTGTTG\n')
|
|
85 InputFile.write('CTGTGATGCTGAACAGGTTTCAGCGGAGCTTCCAGACTAAGACGGACTAGGAAGAAAGGC\n')
|
|
86 InputFile.write('CTGGCGATCTACTTCTGAAAATCAGCCAATGAAAACCCTGTGGATCACAGTGGTCTGATC\n')
|
|
87 InputFile.write('TGCAACTGATCATGGGGATGGCGCAGGACCGGGCAGCGTTTTGTTCTATTGTGCATGGGG\n')
|
|
88 InputFile.write('TCGCCATGAGTCGGGCCGACTCGATGGCAGCTAACAACAA\n')
|
|
89 InputFile.write('>SINE_FR2:classI:SINE:?\n')
|
|
90 InputFile.write('GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC\n')
|
|
91 InputFile.write('GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT\n')
|
|
92 InputFile.write('GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGA\n')
|
|
93 InputFile.write('TTGGGGATTAGGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA\n')
|
|
94 InputFile.write('TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCCAGGGTGTACC\n')
|
|
95 InputFile.write('CTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCCCGCGACCCTCAGTGGAGGAA\n')
|
|
96 InputFile.write('CAAGCGGTAGAAAGTGAGTGAGTGAGTGA\n')
|
|
97 InputFile.write('>SINEC1B2_CF:classI:SINE:?\n')
|
|
98 InputFile.write('GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCGTGATCCTGGA\n')
|
|
99 InputFile.write('GACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAGCCTGCTTCTCCCTCTGCCTG\n')
|
|
100 InputFile.write('TGTCTCTGCCTCTCTCTCTCTCTGTGTCTCTCATGAATAAATAA\n')
|
|
101 InputFile.write('>ALPINE1:classI:SINE:SINE2/tRNA\n')
|
|
102 InputFile.write('GGGGAGGGTATAGCTCAGTGGTAGAGCGCATGCTTAGCATGCACGAGGTCCTGGGTTCAA\n')
|
|
103 InputFile.write('TCCCCAGTACCTCCATTAAAAATAAATAAATAAATAAACCTAATTACCTCCCCCACCAAA\n')
|
|
104 InputFile.write('AAAAAAA\n')
|
|
105 InputFile.close()
|
|
106
|
|
107 InputFile = open(self._refFastaFileName, 'w')
|
|
108 InputFile.write('>SINE_FR2:classI:SINE:?\n')
|
|
109 InputFile.write('GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC\n')
|
|
110 InputFile.write('GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT\n')
|
|
111 InputFile.write('GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGA\n')
|
|
112 InputFile.write('TTGGGGATTAGGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA\n')
|
|
113 InputFile.write('TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCCAGGGTGTACC\n')
|
|
114 InputFile.write('CTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCCCG\n')
|
|
115 InputFile.write('CAAGCGGTAGAAAGTGAGTGAGTGAGTGA\n')
|
|
116 InputFile.write('>SINEC1B2_CF:classI:SINE:?\n')
|
|
117 InputFile.write('GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCGTGATCCTGGA\n')
|
|
118 InputFile.write('GACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAGCCTGCTTCTCCCTCTGCCTG\n')
|
|
119 InputFile.write('TGTCTCTGCCTCTCTCTCTCTCTGTGTCTCTCATGAATAAA\n')
|
|
120 InputFile.close()
|
|
121
|
|
122 def _writeExpDeltaFile(self):
|
|
123 with open(self._expDeltaFileName, 'w') as f:
|
|
124 f.write("%s %s\n" %(os.path.abspath(self._queryFastaFileName), os.path.abspath(self._refFastaFileName)))
|
|
125 f.write('PROMER\n')
|
|
126 f.write('>SINE_FR2:classI:SINE:? SINE_FR2:classI:SINE:? 389 371\n')
|
|
127 f.write('1 387 1 369 6 6 10\n')
|
|
128 f.write('115\n')
|
|
129 f.write('1\n')
|
|
130 f.write('1\n')
|
|
131 f.write('1\n')
|
|
132 f.write('1\n')
|
|
133 f.write('1\n')
|
|
134 f.write('0\n')
|
|
135 f.write('2 388 2 370 6 6 8\n')
|
|
136 f.write('115\n')
|
|
137 f.write('1\n')
|
|
138 f.write('1\n')
|
|
139 f.write('1\n')
|
|
140 f.write('1\n')
|
|
141 f.write('1\n')
|
|
142 f.write('0\n')
|
|
143 f.write('3 389 3 371 6 6 16\n')
|
|
144 f.write('115\n')
|
|
145 f.write('1\n')
|
|
146 f.write('1\n')
|
|
147 f.write('1\n')
|
|
148 f.write('1\n')
|
|
149 f.write('1\n')
|
|
150 f.write('0\n')
|
|
151 f.write('388 2 370 2 6 6 6\n')
|
|
152 f.write('10\n')
|
|
153 f.write('1\n')
|
|
154 f.write('1\n')
|
|
155 f.write('1\n')
|
|
156 f.write('1\n')
|
|
157 f.write('1\n')
|
|
158 f.write('0\n')
|
|
159 f.write('387 1 369 1 6 6 5\n')
|
|
160 f.write('10\n')
|
|
161 f.write('1\n')
|
|
162 f.write('1\n')
|
|
163 f.write('1\n')
|
|
164 f.write('1\n')
|
|
165 f.write('1\n')
|
|
166 f.write('0\n')
|
|
167 f.write('389 3 371 3 6 6 4\n')
|
|
168 f.write('11\n')
|
|
169 f.write('1\n')
|
|
170 f.write('1\n')
|
|
171 f.write('1\n')
|
|
172 f.write('1\n')
|
|
173 f.write('1\n')
|
|
174 f.write('0\n')
|
|
175 f.write('>SINEC1B2_CF:classI:SINE:? SINEC1B2_CF:classI:SINE:? 164 161\n')
|
|
176 f.write('1 159 1 159 0 0 2\n')
|
|
177 f.write('0\n')
|
|
178 f.write('3 161 3 161 0 0 2\n')
|
|
179 f.write('0\n')
|
|
180 f.write('161 3 161 3 0 0 0\n')
|
|
181 f.write('0\n')
|
|
182 f.write('160 2 160 2 0 0 2\n')
|
|
183 f.write('0\n')
|
|
184 f.write('159 1 159 1 0 0 4\n')
|
|
185 f.write('0\n')
|
|
186 f.write('2 160 2 160 0 0 4\n')
|
|
187 f.write('0\n')
|
|
188
|
|
189
|
|
190
|
|
191
|
|
192 def _writeExpGenCoordsFile(self):
|
|
193 with open(self._expCoordFileName, 'w') as f:
|
|
194 f.write("%s %s\n" %(os.path.abspath(self._queryFastaFileName), os.path.abspath(self._refFastaFileName)))
|
|
195 f.write('PROMER\n\n')
|
|
196 f.write(' [S1] [E1] | [S2] [E2] | [LEN 1] [LEN 2] | [% IDY] [% SIM] [% STP] | [FRM] [TAGS]\n')
|
|
197 f.write('==============================================================================================================\n')
|
|
198 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')
|
|
199 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')
|
|
200 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')
|
|
201 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')
|
|
202 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')
|
|
203 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')
|
|
204 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')
|
|
205 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')
|
|
206 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')
|
|
207 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')
|
|
208 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')
|
|
209 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')
|
|
210
|
|
211
|
|
212 def _writeExpShowCoordsFile(self):
|
|
213 with open(self._expCoordFileName, 'w') as f:
|
|
214 f.write("%s %s\n" %(os.path.abspath(self._queryFastaFileName), os.path.abspath(self._refFastaFileName)))
|
|
215 f.write('PROMER\n\n')
|
|
216 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')
|
|
217 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')
|
|
218 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')
|
|
219 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')
|
|
220 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')
|
|
221 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')
|
|
222 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')
|
|
223 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')
|
|
224 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')
|
|
225 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')
|
|
226 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')
|
|
227 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')
|
|
228 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')
|
|
229
|
|
230 if __name__ == "__main__":
|
|
231 unittest.main() |