18
|
1 import unittest
|
|
2 import os
|
|
3 from commons.core.utils.FileUtils import FileUtils
|
|
4 from commons.launcher.LaunchRepeatMasker import LaunchRepeatMasker
|
|
5
|
|
6
|
|
7 class Test_F_RepeatMasker(unittest.TestCase):
|
|
8
|
|
9 def setUp(self):
|
|
10 self._queryFastaFileName = "query.fa"
|
|
11 self._libFastaFileName = "lib.fa"
|
|
12 self._expMaskedQueryFileName = "expMaskedQuery.fa"
|
|
13 self._obsMaskedQueryFileName = "%s.masked" % self._queryFastaFileName
|
|
14
|
|
15 self._expCatFileName = "expCat.fa"
|
|
16 self._obsCatFileName = "%s.cat" % self._queryFastaFileName
|
|
17
|
|
18 self._writeInputFastaFiles()
|
|
19 self._writeExpMaskedQueryFile()
|
|
20 self._writeExpCatFile()
|
|
21
|
|
22 def tearDown(self):
|
|
23 os.remove(self._queryFastaFileName)
|
|
24 os.remove(self._libFastaFileName)
|
|
25 os.remove(self._expMaskedQueryFileName)
|
|
26 os.remove(self._obsMaskedQueryFileName)
|
|
27 os.remove(self._expCatFileName)
|
|
28 os.remove(self._obsCatFileName)
|
|
29 os.remove("%s.tbl" % self._queryFastaFileName)
|
|
30 os.remove("%s.out" % self._queryFastaFileName)
|
|
31 os.remove("%s.ori.out" % self._queryFastaFileName)
|
|
32
|
|
33 def test_run(self):
|
|
34 ilauncher = LaunchRepeatMasker(self._queryFastaFileName, self._libFastaFileName,verbosity=1 )
|
|
35 ilauncher.run()
|
|
36 self.assertTrue(FileUtils.are2FilesIdentical(self._obsMaskedQueryFileName, self._expMaskedQueryFileName))
|
|
37
|
|
38 def test_run_as_script(self):
|
|
39 #FIXME : change path to launcher
|
|
40 cmd = 'python %s/commons/launcher/LaunchRepeatMasker.py -q %s -l %s' % (os.environ["REPET_PATH"],self._queryFastaFileName, self._libFastaFileName)
|
|
41 os.system(cmd)
|
|
42 self.assertTrue(FileUtils.are2FilesIdentical(self._obsMaskedQueryFileName, self._expMaskedQueryFileName))
|
|
43
|
|
44 def _writeInputFastaFiles(self):
|
|
45 InputFile = open(self._queryFastaFileName, 'w')
|
|
46 InputFile.write('>Bovc-tA2:classI:SINE:SINE2/tRNA\n')
|
|
47 InputFile.write('GGGCTTCCCTGGTAGCTCAGCTGGTAAAGAATCCGCCTGCAATGCAGGAGACCCCGGTTC\n')
|
|
48 InputFile.write('GATTCCTGGGTCGGGAAGATCCCCTGGAGAAGGGATAGGCTACCCACTCCAGTATTCTTG\n')
|
|
49 InputFile.write('GGCTTCCCTGGTGGCTCAGACGGTAAAGAATCCGCCTGCAATGCGGGAGACCTGGGTTCG\n')
|
|
50 InputFile.write('ATCCCTGGGTTGGGAAGATCCCCTGGAGGAGGGCATGGCAACCCACTCCAGTATTCTTGC\n')
|
|
51 InputFile.write('CTGGAGAATCCCCATGGACAGAGGAGCCTGGCGGGCTACAGTCCATGGGGTCGCAAAGAG\n')
|
|
52 InputFile.write('TCGGACACGACTGAGCGACTAAGCACAGCACAGGTCTTTCCTGCCACTTACCTCCTTCCA\n')
|
|
53 InputFile.write('GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC\n')
|
|
54 InputFile.write('GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT\n')
|
|
55 InputFile.write('GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGA\n')
|
|
56 InputFile.write('TTGGGGATTAGGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA\n')
|
|
57 InputFile.write('TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCCAGGGTGTACC\n')
|
|
58 InputFile.write('CTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCCCGCGACCCTCAGTGGAGGAA\n')
|
|
59 InputFile.write('GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCGTGATCCTGGA\n')
|
|
60 InputFile.write('GACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAGCCTGCTTCTCCCTCTGCCTG\n')
|
|
61 InputFile.write('GGGGAGGGTATAGCTCAGTGGTAGAGCGCATGCTTAGCATGCACGAGGTCCTGGGTTCAA\n')
|
|
62 InputFile.write('TCCCCAGTACCTCCATTAAAAATAAATAAATAAATAAACCTAATTACCTCCCCCACCAAA\n')
|
|
63 InputFile.write('AAAAAAA\n')
|
|
64 InputFile.close()
|
|
65
|
|
66 InputFile = open(self._libFastaFileName, 'w')
|
|
67 InputFile.write('>RefLib\n')
|
|
68 InputFile.write('GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC\n')
|
|
69 InputFile.write('GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT\n')
|
|
70 InputFile.close()
|
|
71
|
|
72 def _writeExpMaskedQueryFile(self):
|
|
73 f = open(self._expMaskedQueryFileName, 'w')
|
|
74 f.write('>Bovc-tA2:classI:SINE:SINE2/tRNA\n')
|
|
75 f.write('GGGCTTCCCTGGTAGCTCAGCTGGTAAAGAATCCGCCTGCAATGCAGGAG\n')
|
|
76 f.write('ACCCCGGTTCGATTCCTGGGTCGGGAAGATCCCCTGGAGAAGGGATAGGC\n')
|
|
77 f.write('TACCCACTCCAGTATTCTTGGGCTTCCCTGGTGGCTCAGACGGTAAAGAA\n')
|
|
78 f.write('TCCGCCTGCAATGCGGGAGACCTGGGTTCGATCCCTGGGTTGGGAAGATC\n')
|
|
79 f.write('CCCTGGAGGAGGGCATGGCAACCCACTCCAGTATTCTTGCCTGGAGAATC\n')
|
|
80 f.write('CCCATGGACAGAGGAGCCTGGCGGGCTACAGTCCATGGGGTCGCAAAGAG\n')
|
|
81 f.write('TCGGACACGACTGAGCGACTAAGCACAGCACAGGTCTTTCCTGCCACTTA\n')
|
|
82 f.write('CCTCCTTCCANNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\n')
|
|
83 f.write('NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\n')
|
|
84 f.write('NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNGCCTGCGTGGGTTCTCTCCG\n')
|
|
85 f.write('GGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGATTGGGGATTA\n')
|
|
86 f.write('GGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA\n')
|
|
87 f.write('TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCC\n')
|
|
88 f.write('AGGGTGTACCCTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCC\n')
|
|
89 f.write('CGCGACCCTCAGTGGAGGAAGGGCAGCCTGGGTGGCTCAGCGGTTTAGCG\n')
|
|
90 f.write('CCTGCCTTTGGCCCAGGGCGTGATCCTGGAGACCCGGGATCGAGTCCCAC\n')
|
|
91 f.write('ATCGGGCTCCCTGCATGGAGCCTGCTTCTCCCTCTGCCTGGGGGAGGGTA\n')
|
|
92 f.write('TAGCTCAGTGGTAGAGCGCATGCTTAGCATGCACGAGGTCCTGGGTTCAA\n')
|
|
93 f.write('TCCCCAGTACCTCCATTAAAAATAAATAAATAAATAAACCTAATTACCTC\n')
|
|
94 f.write('CCCCACCAAAAAAAAAA\n')
|
|
95 f.close()
|
|
96
|
|
97 def _writeExpCatFile(self):
|
|
98 f = open(self._expCatFileName, 'w')
|
|
99 f.write('958 0.00 0.00 0.00 Bovc-tA2:classI:SINE:SINE2/tRNA 361 480 (487) RefLib 1 120 (0) 5\n')
|
|
100 f.write('## Total Sequences: 1\n')
|
|
101 f.write('## Total Length: 967\n')
|
|
102 f.write('## Total NonMask ( excluding >20bp runs of N/X bases ): 967\n')
|
|
103 f.write('## Total NonSub ( excluding all non ACGT bases ):967\n')
|
|
104 f.write('RepeatMasker version open-3.2.6 , default mode\n')
|
|
105 f.write('run with blastp version 2.0MP-WashU\n')
|
|
106 f.write('RepBase Update 20080801, RM database version 20080801\n')
|
|
107 f.close()
|
|
108
|
|
109 if __name__ == "__main__":
|
|
110 unittest.main() |