annotate commons/launcher/tests/Test_F_BlatProgramLauncher.py @ 19:9bcfa7936eec

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