18
|
1 import os
|
|
2 import unittest
|
|
3 from commons.core.utils.FileUtils import FileUtils
|
|
4 from devTools.tests.MockFastaSupctg30 import MockFastaSupctg30
|
|
5 from devTools.tests.MockMiniProtBankSupctg30 import MockMiniProtBankSupctg30
|
|
6 from commons.launcher.tests.MockDataBankForBlat import MockDataBankForBlat
|
|
7 from commons.launcher.tests.MockESTBankForBlat import MockESTBankForBlat
|
|
8 from commons.launcher.tests.MockOutputForBlat import MockOutputForBlat
|
|
9 from commons.launcher.BlatProgramLauncher import BlatProgramLauncher
|
|
10
|
|
11 class Test_F_BlatProgramLauncher(unittest.TestCase):
|
|
12
|
|
13 def test_run_empty_result(self):
|
|
14 queryFileName = "smallProtBank_supctg30.fa"
|
|
15 mock = MockMiniProtBankSupctg30()
|
|
16 mock.write(queryFileName)
|
|
17 subjectFileName = "subjectBank.fa"
|
|
18 mock = MockFastaSupctg30()
|
|
19 mock.write(subjectFileName)
|
|
20
|
|
21 expOutputFileName = "expBlatOutput.blast.align"
|
|
22 self.writeEmptyExpOutputFile(expOutputFileName)
|
|
23
|
|
24 obsOutputFileName = "obsBlatOutput.blast.align"
|
|
25
|
|
26 bpl = BlatProgramLauncher()
|
|
27 bpl.setInputFile(queryFileName)
|
|
28 bpl.setSubjectFile(subjectFileName)
|
|
29 bpl.setOutputFile(obsOutputFileName)
|
|
30 bpl.setProgramParameters("")
|
|
31 bpl.run()
|
|
32
|
|
33 blastFileName = queryFileName + ".blast"
|
|
34
|
|
35 self.assertTrue(os.path.exists(obsOutputFileName))
|
|
36 self.assertTrue(FileUtils.are2FilesIdentical(expOutputFileName, obsOutputFileName))
|
|
37
|
|
38 os.remove(queryFileName)
|
|
39 os.remove(subjectFileName)
|
|
40 os.remove(blastFileName)
|
|
41 os.remove(expOutputFileName)
|
|
42 os.remove(obsOutputFileName)
|
|
43
|
|
44 def test_as_script_empty_result(self):
|
|
45 queryFileName = "smallProtBank_supctg30.fa"
|
|
46 mock = MockMiniProtBankSupctg30()
|
|
47 mock.write(queryFileName)
|
|
48 subjectFileName = "subjectBank.fa"
|
|
49 mock = MockFastaSupctg30()
|
|
50 mock.write(subjectFileName)
|
|
51
|
|
52 expOutputFileName = "expBlatOutput.blast.align"
|
|
53 self.writeEmptyExpOutputFile(expOutputFileName)
|
|
54
|
|
55 obsOutputFileName = "obsBlatOutput.blast.align"
|
|
56
|
|
57 cmd2Launch = "python ../BlatProgramLauncher.py -s " + subjectFileName + " -i " + queryFileName + " -p '' -o " + obsOutputFileName
|
|
58
|
|
59 os.system(cmd2Launch)
|
|
60
|
|
61 blastFileName = queryFileName + ".blast"
|
|
62
|
|
63 self.assertTrue(os.path.exists(obsOutputFileName))
|
|
64 self.assertTrue(FileUtils.are2FilesIdentical(expOutputFileName, obsOutputFileName))
|
|
65
|
|
66 os.remove(queryFileName)
|
|
67 os.remove(subjectFileName)
|
|
68 os.remove(blastFileName)
|
|
69 os.remove(expOutputFileName)
|
|
70 os.remove(obsOutputFileName)
|
|
71
|
|
72 def test_run(self):
|
|
73 queryFileName = "smallESTBank.fa"
|
|
74 mock = MockESTBankForBlat()
|
|
75 mock.write(queryFileName)
|
|
76 subjectFileName = "subjectBank.fa"
|
|
77 mock = MockDataBankForBlat()
|
|
78 mock.write(subjectFileName)
|
|
79
|
|
80 expOutputFileName = "expBlatOutput.blast.align"
|
|
81 mock = MockOutputForBlat()
|
|
82 mock.write(expOutputFileName)
|
|
83
|
|
84 obsOutputFileName = "obsBlatOutput.blast.align"
|
|
85
|
|
86 bpl = BlatProgramLauncher()
|
|
87 bpl.setInputFile(queryFileName)
|
|
88 bpl.setSubjectFile(subjectFileName)
|
|
89 bpl.setOutputFile(obsOutputFileName)
|
|
90 bpl.setProgramParameters("")
|
|
91 bpl.run()
|
|
92
|
|
93 blastFileName = queryFileName + ".blast"
|
|
94
|
|
95 self.assertTrue(os.path.exists(obsOutputFileName))
|
|
96 self.assertTrue(FileUtils.are2FilesIdentical(expOutputFileName, obsOutputFileName))
|
|
97
|
|
98 os.remove(queryFileName)
|
|
99 os.remove(subjectFileName)
|
|
100 os.remove(blastFileName)
|
|
101 os.remove(expOutputFileName)
|
|
102 os.remove(obsOutputFileName)
|
|
103
|
|
104 def test_as_script(self):
|
|
105 queryFileName = "smallESTBank.fa"
|
|
106 mock = MockESTBankForBlat()
|
|
107 mock.write(queryFileName)
|
|
108 subjectFileName = "subjectBank.fa"
|
|
109 mock = MockDataBankForBlat()
|
|
110 mock.write(subjectFileName)
|
|
111
|
|
112 expOutputFileName = "expBlatOutput.blast.align"
|
|
113 mock = MockOutputForBlat()
|
|
114 mock.write(expOutputFileName)
|
|
115
|
|
116 obsOutputFileName = "obsBlatOutput.blast.align"
|
|
117
|
|
118 cmd2Launch = "python ../BlatProgramLauncher.py -s " + subjectFileName + " -i " + queryFileName + " -p '' -o " + obsOutputFileName
|
|
119
|
|
120 os.system(cmd2Launch)
|
|
121
|
|
122 blastFileName = queryFileName + ".blast"
|
|
123
|
|
124 self.assertTrue(os.path.exists(obsOutputFileName))
|
|
125 self.assertTrue(FileUtils.are2FilesIdentical(expOutputFileName, obsOutputFileName))
|
|
126
|
|
127 os.remove(queryFileName)
|
|
128 os.remove(subjectFileName)
|
|
129 os.remove(blastFileName)
|
|
130 os.remove(expOutputFileName)
|
|
131 os.remove(obsOutputFileName)
|
|
132
|
|
133 def writeEmptyExpOutputFile(self, outputFileName):
|
|
134 f = open(outputFileName, "w")
|
|
135 f.write("")
|
|
136 f.close()
|
|
137
|
|
138 if __name__ == "__main__":
|
|
139 unittest.main() |