annotate commons/launcher/tests/Test_F_LaunchRepeatMasker.py @ 18:94ab73e8a190

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