18
|
1 import unittest
|
|
2 import os
|
|
3 from commons.core.utils.FileUtils import FileUtils
|
|
4 from commons.launcher.LaunchRefAlign import LaunchRefAlign
|
|
5 from shutil import rmtree
|
|
6
|
|
7
|
|
8 class Test_F_LaunchRefAlign(unittest.TestCase):
|
|
9
|
|
10 def setUp(self):
|
|
11 self._curTestDir = os.getcwd()
|
|
12 self._testPrefix = 'test_LRA'
|
|
13 try:
|
|
14 os.makedirs(self._testPrefix)
|
|
15 except:pass
|
|
16 os.chdir(self._testPrefix)
|
|
17
|
|
18
|
|
19 self._inputFastaFileName = "%s_input.fa" % self._testPrefix
|
|
20 self._obsOutputFileName = self._inputFastaFileName +'.fa_aln'
|
|
21 self._expOutputFileName = "%s_exp.fa_aln" % self._testPrefix
|
|
22 self._writeInputFile()
|
|
23
|
|
24 def tearDown(self):
|
|
25 os.chdir(self._curTestDir)
|
|
26 try:
|
|
27 rmtree(self._testPrefix)
|
|
28 except:pass
|
|
29
|
|
30 def test_run(self):
|
|
31 self._writeExpOutputFile_wo_refseq()
|
|
32 ilauncher = LaunchRefAlign(self._inputFastaFileName,verbosity=5)
|
|
33 ilauncher.run()
|
|
34 self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName))
|
|
35
|
|
36 def test_run_KeepRefSeq(self):
|
|
37 self._writeExpOutputFile_with_refseq()
|
|
38 ilauncher = LaunchRefAlign(self._inputFastaFileName,verbosity=5, keepRefseq=True)
|
|
39 ilauncher.run()
|
|
40
|
|
41 self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName))
|
|
42
|
|
43 def test_run_as_script(self):
|
|
44 self._writeExpOutputFile_wo_refseq()
|
|
45 cmd = 'LaunchRefAlign.py -i %s -o %s -v 5' % (self._inputFastaFileName, self._obsOutputFileName)
|
|
46 os.system(cmd)
|
|
47 self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName))
|
|
48
|
|
49 def test_run_as_script_KeepRefSeq(self):
|
|
50 self._writeExpOutputFile_with_refseq()
|
|
51 cmd = 'LaunchRefAlign.py -i %s -r -o %s -v 5' % (self._inputFastaFileName, self._obsOutputFileName)
|
|
52 os.system(cmd)
|
|
53 self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName))
|
|
54
|
|
55 def _writeInputFile(self):
|
|
56 InputFile = open(self._inputFastaFileName, 'w')
|
|
57 InputFile.write('>sequence\n')
|
|
58 InputFile.write('GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC\n')
|
|
59 InputFile.write('GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT\n')
|
|
60 InputFile.write('GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGA\n')
|
|
61 InputFile.write('TTGGGGATTAGGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA\n')
|
|
62 InputFile.write('TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCCAGGGTGTACC\n')
|
|
63 InputFile.write('CTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCCCG\n')
|
|
64 InputFile.write('CAAGCGGTAGAAAGTGAGTGAGTGAGTGA\n')
|
|
65 InputFile.write('>sequence2\n')
|
|
66 InputFile.write('GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCGTGATCCTGGA\n')
|
|
67 InputFile.write('GACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAGCCTGCTTCTCCCTCTGCCTG\n')
|
|
68 InputFile.write('TGTCTCTGCCTCTCTCTCTCTCTGTGTCTCTCATGAATAAA\n')
|
|
69 InputFile.close()
|
|
70
|
|
71 def _writeExpOutputFile_wo_refseq(self):
|
|
72 with open(self._expOutputFileName,'w') as expOutputFile:
|
|
73 expOutputFile.write(""">sequence2
|
|
74 GGGCAGC-CGGTGGTGCGGT--TTAGCGCTGTTGGCCCAGGGCGTGATGGACCCGGGATC
|
|
75 GATCCCACATCGGG--------------CTCCCTGCATGGAGCCTGC---TTCTCCCTCT
|
|
76 GCCTGTGTCTCTTCTCTC------------------------------------------
|
|
77 ------------------------------------------------------------
|
|
78 ----------TCTCTCTGTGTCTCTCATGA-ATAAA------------------------
|
|
79 ------------------------------------------------------------
|
|
80 -----------
|
|
81 """)
|
|
82
|
|
83 def _writeExpOutputFile_with_refseq(self):
|
|
84 with open(self._expOutputFileName,'w') as expOutputFile:
|
|
85 expOutputFile.write(""">sequence
|
|
86 GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC
|
|
87 GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT
|
|
88 GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGA
|
|
89 TTGGGGATTAGGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA
|
|
90 TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCCAGGGTGTACC
|
|
91 CTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCCCGCAAGCGGTAGAAAGTGAG
|
|
92 TGAGTGAGTGA
|
|
93 >sequence2
|
|
94 GGGCAGC-CGGTGGTGCGGT--TTAGCGCTGTTGGCCCAGGGCGTGATGGACCCGGGATC
|
|
95 GATCCCACATCGGG--------------CTCCCTGCATGGAGCCTGC---TTCTCCCTCT
|
|
96 GCCTGTGTCTCTTCTCTC------------------------------------------
|
|
97 ------------------------------------------------------------
|
|
98 ----------TCTCTCTGTGTCTCTCATGA-ATAAA------------------------
|
|
99 ------------------------------------------------------------
|
|
100 -----------
|
|
101 """)
|
|
102
|
|
103 if __name__ == "__main__":
|
|
104 unittest.main() |