18
|
1 import unittest
|
|
2 import os
|
|
3 from commons.core.utils.FileUtils import FileUtils
|
|
4 from commons.launcher.LaunchTRF import LaunchTRF
|
|
5
|
|
6
|
|
7 class Test_F_LaunchTRF(unittest.TestCase):
|
|
8
|
|
9 def setUp(self):
|
|
10 self._inputFastaFileName = "input.fa"
|
|
11 self._obsTRFOutputFileName = "obsTRF.TRF.set"
|
|
12 self._expTRFOutputFileName = "expTRF.TRF.set"
|
|
13 self._writeInputFile()
|
|
14 self._writeExpTRFOutputFile()
|
|
15
|
|
16 def tearDown(self):
|
|
17 try:
|
|
18 os.remove(self._inputFastaFileName)
|
|
19 except:pass
|
|
20
|
|
21 try:
|
|
22 os.remove(self._expTRFOutputFileName)
|
|
23 except:pass
|
|
24 try:
|
|
25 os.remove(self._obsTRFOutputFileName)
|
|
26 except:pass
|
|
27 try:
|
|
28 os.remove("input.fa.2.3.5.80.10.20.15.dat")
|
|
29 except:pass
|
|
30
|
|
31 def test_run(self):
|
|
32 ilauncher = LaunchTRF(self._inputFastaFileName,self._obsTRFOutputFileName,verbosity=5)
|
|
33 ilauncher.run()
|
|
34 self.assertTrue(FileUtils.are2FilesIdentical(self._expTRFOutputFileName, self._obsTRFOutputFileName))
|
|
35
|
|
36 def test_run_as_script(self):
|
|
37 cmd = 'LaunchTRF.py -i %s -o %s -v 3' % (self._inputFastaFileName, self._obsTRFOutputFileName)
|
|
38 os.system(cmd)
|
|
39 self.assertTrue(FileUtils.are2FilesIdentical(self._expTRFOutputFileName, self._obsTRFOutputFileName))
|
|
40
|
|
41 def test_run_as_scriptNoOutputGiven(self):
|
|
42 cmd = 'LaunchTRF.py -i %s -v 3' % (self._inputFastaFileName)
|
|
43 os.system(cmd)
|
|
44 self._obsTRFOutputFileName = "input.fa.TRF.set"
|
|
45 self.assertTrue(FileUtils.are2FilesIdentical(self._expTRFOutputFileName, self._obsTRFOutputFileName))
|
|
46
|
|
47 def test_run_as_scriptNoOutputGivenDoClean(self):
|
|
48 cmd = 'LaunchTRF.py -i %s -c -v 3' % (self._inputFastaFileName)
|
|
49 os.system(cmd)
|
|
50 self._obsTRFOutputFileName = "input.fa.TRF.set"
|
|
51 datFilePath = os.path.join(os.getcwd(),"%s.2.3.5.80.10.20.15.dat" % self._inputFastaFileName)
|
|
52 self.assertFalse(os.path.exists(datFilePath))
|
|
53
|
|
54 def _writeInputFile(self):
|
|
55 InputFile = open(self._inputFastaFileName, 'w')
|
|
56 InputFile.write('>sequence\n')
|
|
57 InputFile.write('GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC\n')
|
|
58 InputFile.write('GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT\n')
|
|
59 InputFile.write('GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGA\n')
|
|
60 InputFile.write('TTGGGGATTAGGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA\n')
|
|
61 InputFile.write('TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCCAGGGTGTACC\n')
|
|
62 InputFile.write('CTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCCCG\n')
|
|
63 InputFile.write('CAAGCGGTAGAAAGTGAGTGAGTGAGTGA\n')
|
|
64 InputFile.write('>sequence2\n')
|
|
65 InputFile.write('GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCGTGATCCTGGA\n')
|
|
66 InputFile.write('GACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAGCCTGCTTCTCCCTCTGCCTG\n')
|
|
67 InputFile.write('TGTCTCTGCCTCTCTCTCTCTCTGTGTCTCTCATGAATAAA\n')
|
|
68 InputFile.close()
|
|
69
|
|
70 def _writeExpTRFOutputFile(self):
|
|
71 with open(self._expTRFOutputFileName,'w') as expTRFOutputFile:
|
|
72 expTRFOutputFile.write("""1\t(GTGGT)2\tsequence\t11\t21
|
|
73 2\t(GGT)5\tsequence\t10\t23
|
|
74 3\t(GTGTGA)4\tsequence\t222\t242
|
|
75 4\t(GTCCA)2\tsequence\t282\t292
|
|
76 5\t(AGTG)4\tsequence\t355\t371
|
|
77 6\t(GCCTGTCTCTCCTCT)4\tsequence2\t100\t152
|
|
78 7\t(CTCTGCCTGTGT)3\tsequence2\t112\t151
|
|
79 8\t(TC)23\tsequence2\t107\t152
|
|
80 """)
|
|
81
|
|
82
|
|
83 if __name__ == "__main__":
|
|
84 unittest.main() |