18
|
1 import unittest
|
|
2 import os, os.path
|
|
3 from SMART.Java.Python.misc import Utils
|
|
4
|
|
5 SMART_PATH = os.environ["REPET_PATH"] + "/SMART"
|
|
6
|
|
7 class Test_F_compareOverlapping(unittest.TestCase):
|
|
8
|
|
9 def setUp(self):
|
|
10 self._inputFileQuery = "inputFileTest1.bed"
|
|
11 self._inputFileReference = "inputFileTest2.bed"
|
|
12 self._inputFileName3 = "inputFileTest3.bed"
|
|
13 self._expOutputFileName = "expOutput.gff3"
|
|
14 self._outputFileName = "output.gff3"
|
|
15 self._writeInputFileQuery()
|
|
16 self._writeInputFileRefence()
|
|
17 self._writeInputFile3()
|
|
18
|
|
19 def tearDown(self):
|
|
20 for fileName in (self._inputFileQuery, self._inputFileReference, self._inputFileName3, self._expOutputFileName, self._outputFileName):
|
|
21 if os.path.exists(fileName):
|
|
22 os.remove(fileName)
|
|
23
|
|
24 def test_runAsScript_withoutOption(self):
|
|
25 self._writeOutputFile_withoutOption(self._expOutputFileName)
|
|
26 os.system("python %s/Java/Python/CompareOverlapping.py -i %s -f bed -j %s -g bed -o %s -v 0" % (SMART_PATH, self._inputFileQuery, self._inputFileReference, self._outputFileName))
|
|
27 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
|
|
28
|
|
29 def test_runAsScript_optionNFirstNucleotide(self):
|
|
30 self._writeOutputFile_NFirstNucleotide(self._expOutputFileName)
|
|
31 os.system("python %s/Java/Python/CompareOverlapping.py -i %s -f bed -j %s -g bed -o %s -S 200 -s 200 -v 0" % (SMART_PATH, self._inputFileQuery, self._inputFileReference, self._outputFileName))
|
|
32 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
|
|
33
|
|
34 def test_runAsScript_optionNLastNucleotide(self):
|
|
35 self._writeOutputFile_NLastNucleotide(self._expOutputFileName)
|
|
36 os.system("python %s/Java/Python/CompareOverlapping.py -i %s -f bed -j %s -g bed -o %s -U 200 -u 200 -v 0" % (SMART_PATH, self._inputFileQuery, self._inputFileReference, self._outputFileName))
|
|
37 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
|
|
38
|
|
39 def test_runAsScript_option_5PrimeExtension(self):
|
|
40 self._writeOutputFile_5PrimeExtension(self._expOutputFileName)
|
|
41 os.system("python %s/Java/Python/CompareOverlapping.py -i %s -f bed -j %s -g bed -o %s -E 110 -e 110 -v 0" % (SMART_PATH, self._inputFileQuery, self._inputFileReference, self._outputFileName))
|
|
42 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
|
|
43
|
|
44 def test_runAsScript_option_3PrimeExtension(self):
|
|
45 self._writeOutputFile_3PrimeExtension(self._expOutputFileName)
|
|
46 os.system("python %s/Java/Python/CompareOverlapping.py -i %s -f bed -j %s -g bed -o %s -N 110 -n 110 -v 0" % (SMART_PATH, self._inputFileQuery, self._inputFileReference, self._outputFileName))
|
|
47 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
|
|
48
|
|
49 def test_runAsScript_colinear(self):
|
|
50 self._writeOutputFile_colinear(self._expOutputFileName)
|
|
51 os.system("python %s/Java/Python/CompareOverlapping.py -i %s -f bed -j %s -g bed -o %s -c -v 0" % (SMART_PATH, self._inputFileQuery, self._inputFileReference, self._outputFileName))
|
|
52 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
|
|
53
|
|
54 def test_runAsScript_antisense(self):
|
|
55 self._writeOutputFile_antisense(self._expOutputFileName)
|
|
56 os.system("python %s/Java/Python/CompareOverlapping.py -i %s -f bed -j %s -g bed -o %s -a -v 0" % (SMART_PATH, self._inputFileQuery, self._inputFileReference, self._outputFileName))
|
|
57 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
|
|
58
|
|
59 def test_runAsScript_minOverlap(self):
|
|
60 self._writeOutputFile_minOverlap(self._expOutputFileName)
|
|
61 os.system("python %s/Java/Python/CompareOverlapping.py -i %s -f bed -j %s -g bed -o %s -m 51 -v 0" % (SMART_PATH, self._inputFileQuery, self._inputFileName3, self._outputFileName))
|
|
62 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
|
|
63
|
|
64 def test_runAsScript_pcOverlap(self):
|
|
65 self._writeOutputFile_pcOverlap(self._expOutputFileName)
|
|
66 os.system("python %s/Java/Python/CompareOverlapping.py -i %s -f bed -j %s -g bed -o %s -p 60 -v 0" % (SMART_PATH, self._inputFileQuery, self._inputFileName3, self._outputFileName))
|
|
67 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
|
|
68
|
|
69 def test_runAsScript_included(self):
|
|
70 self._writeOutputFile_included(self._expOutputFileName)
|
|
71 os.system("python %s/Java/Python/CompareOverlapping.py -i %s -f bed -j %s -g bed -o %s -k -v 0" % (SMART_PATH, self._inputFileQuery, self._inputFileReference, self._outputFileName))
|
|
72 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
|
|
73
|
|
74 def test_runAsScript_including(self):
|
|
75 self._writeOutputFile_including(self._expOutputFileName)
|
|
76 os.system("python %s/Java/Python/CompareOverlapping.py -i %s -f bed -j %s -g bed -o %s -K -v 0" % (SMART_PATH, self._inputFileQuery, self._inputFileReference, self._outputFileName))
|
|
77 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
|
|
78
|
|
79 def test_runAsScript_includeNotOverlap(self):
|
|
80 self._writeOutputFile_includeNotOverlap(self._expOutputFileName)
|
|
81 os.system("python %s/Java/Python/CompareOverlapping.py -i %s -f bed -j %s -g bed -o %s -O -v 0" % (SMART_PATH, self._inputFileQuery, self._inputFileReference, self._outputFileName))
|
|
82 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
|
|
83
|
|
84 def test_runAsScript_exclude(self):
|
|
85 self._writeOutputFile_exclude(self._expOutputFileName)
|
|
86 os.system("python %s/Java/Python/CompareOverlapping.py -i %s -f bed -j %s -g bed -o %s -x -v 0" % (SMART_PATH, self._inputFileQuery, self._inputFileReference, self._outputFileName))
|
|
87 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
|
|
88
|
|
89 def _writeInputFileQuery(self):
|
|
90 f = open(self._inputFileQuery, "w")
|
|
91 f.write("arm_X\t1000\t2000\ttest1.1\t1000\t+\t1000\t2000\t0\t1\t1000,\t0,\n")
|
|
92 f.write("arm_X\t1000\t2000\ttest1.2\t1000\t-\t1000\t2000\t0\t1\t1000,\t0,\n")
|
|
93 f.write("arm_X\t100\t200\ttest1.3\t1000\t+\t100\t200\t0\t1\t100,\t0,\n")
|
|
94 f.write("arm_X\t100\t3200\ttest1.4\t1000\t+\t100\t3200\t0\t1\t3100,\t0,\n")
|
|
95 f.close()
|
|
96
|
|
97 def _writeInputFileRefence(self):
|
|
98 f = open(self._inputFileReference, "w")
|
|
99 f.write("arm_X\t1000\t2000\ttest2.1\t1000\t+\t1000\t2000\t0\t1\t1000,\t0,\n")
|
|
100 f.close()
|
|
101
|
|
102 def _writeInputFile3(self):
|
|
103 f = open(self._inputFileName3, "w")
|
|
104 f.write("arm_X\t1000\t2000\ttest2.1\t1000\t+\t1000\t2000\t0\t1\t1000,\t0,\n")
|
|
105 f.write("arm_X\t250\t350\ttest2.2\t1000\t+\t250\t350\t0\t1\t100,\t0,\n")
|
|
106 f.write("arm_X\t150\t250\ttest2.3\t1000\t+\t150\t250\t0\t1\t100,\t0,\n")
|
|
107 f.close()
|
|
108
|
|
109 def _writeOutputFile_withoutOption(self, outputFileName):
|
|
110 f = open(outputFileName, "w")
|
|
111 f.write("arm_X\tS-MART\ttranscript\t100\t3199\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.4;Name=test1.4\n")
|
|
112 f.write("arm_X\tS-MART\ttranscript\t1000\t1999\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.1;Name=test1.1\n")
|
|
113 f.write("arm_X\tS-MART\ttranscript\t1000\t1999\t.\t-\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.2;Name=test1.2\n")
|
|
114 f.close()
|
|
115
|
|
116 def _writeOutputFile_NFirstNucleotide(self, outputFileName):
|
|
117 f = open(outputFileName, "w")
|
|
118 f.write("arm_X\tS-MART\ttranscript\t1000\t1199\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.1;Name=test1.1\n")
|
|
119 f.close()
|
|
120
|
|
121 def _writeOutputFile_NLastNucleotide(self, outputFileName):
|
|
122 f = open(outputFileName, "w")
|
|
123 f.write("arm_X\tS-MART\ttranscript\t1800\t1999\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.1;Name=test1.1\n")
|
|
124 f.close()
|
|
125
|
|
126 def _writeOutputFile_5PrimeExtension(self, outputFileName):
|
|
127 f = open(outputFileName, "w")
|
|
128 f.write("arm_X\tS-MART\ttranscript\t0\t3199\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.4;Name=test1.4\n")
|
|
129 f.write("arm_X\tS-MART\ttranscript\t890\t1999\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.1;Name=test1.1\n")
|
|
130 f.write("arm_X\tS-MART\ttranscript\t1000\t2109\t.\t-\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.2;Name=test1.2\n")
|
|
131 f.close()
|
|
132
|
|
133 def _writeOutputFile_3PrimeExtension(self, outputFileName):
|
|
134 f = open(outputFileName, "w")
|
|
135 f.write("arm_X\tS-MART\ttranscript\t100\t3309\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.4;Name=test1.4\n")
|
|
136 f.write("arm_X\tS-MART\ttranscript\t1000\t2109\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.1;Name=test1.1\n")
|
|
137 f.write("arm_X\tS-MART\ttranscript\t890\t1999\t.\t-\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.2;Name=test1.2\n")
|
|
138 f.close()
|
|
139
|
|
140 def _writeOutputFile_colinear(self, outputFileName):
|
|
141 f = open(outputFileName, "w")
|
|
142 f.write("arm_X\tS-MART\ttranscript\t100\t3199\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.4;Name=test1.4\n")
|
|
143 f.write("arm_X\tS-MART\ttranscript\t1000\t1999\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.1;Name=test1.1\n")
|
|
144 f.close()
|
|
145
|
|
146 def _writeOutputFile_antisense(self, outputFileName):
|
|
147 f = open(outputFileName, "w")
|
|
148 f.write("arm_X\tS-MART\ttranscript\t1000\t1999\t.\t-\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.2;Name=test1.2\n")
|
|
149 f.close()
|
|
150
|
|
151 def _writeOutputFile_minOverlap(self, outputFileName):
|
|
152 f = open(outputFileName, "w")
|
|
153 f.write("arm_X\tS-MART\ttranscript\t100\t3199\t.\t+\t.\toverlapWith=test2.3,test2.2,test2.1;nbOverlaps=3.000000;ID=test1.4;Name=test1.4\n")
|
|
154 f.write("arm_X\tS-MART\ttranscript\t1000\t1999\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.1;Name=test1.1\n")
|
|
155 f.write("arm_X\tS-MART\ttranscript\t1000\t1999\t.\t-\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.2;Name=test1.2\n")
|
|
156 f.close()
|
|
157
|
|
158 def _writeOutputFile_pcOverlap(self, outputFileName):
|
|
159 f = open(outputFileName, "w")
|
|
160 f.write("arm_X\tS-MART\ttranscript\t1000\t1999\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.1;Name=test1.1\n")
|
|
161 f.write("arm_X\tS-MART\ttranscript\t1000\t1999\t.\t-\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.2;Name=test1.2\n")
|
|
162 f.close()
|
|
163
|
|
164 def _writeOutputFile_includeNotOverlap(self, outputFileName):
|
|
165 f = open(outputFileName, "w")
|
|
166 f.write("arm_X\tS-MART\ttranscript\t100\t3199\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.4;Name=test1.4\n")
|
|
167 f.write("arm_X\tS-MART\ttranscript\t100\t199\t.\t+\t.\tnbOverlaps=0;ID=test1.3;Name=test1.3\n")
|
|
168 f.write("arm_X\tS-MART\ttranscript\t1000\t1999\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.1;Name=test1.1\n")
|
|
169 f.write("arm_X\tS-MART\ttranscript\t1000\t1999\t.\t-\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.2;Name=test1.2\n")
|
|
170 f.close()
|
|
171
|
|
172 def _writeOutputFile_exclude(self, outputFileName):
|
|
173 f = open(outputFileName, "w")
|
|
174 f.write("arm_X\tS-MART\ttranscript\t100\t199\t.\t+\t.\tID=test1.3;Name=test1.3\n")
|
|
175 f.close()
|
|
176
|
|
177 def _writeOutputFile_included(self, outputFileName):
|
|
178 f = open(outputFileName, "w")
|
|
179 f.write("arm_X\tS-MART\ttranscript\t1000\t1999\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.1;Name=test1.1\n")
|
|
180 f.write("arm_X\tS-MART\ttranscript\t1000\t1999\t.\t-\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.2;Name=test1.2\n")
|
|
181 f.close()
|
|
182
|
|
183 def _writeOutputFile_including(self, outputFileName):
|
|
184 f = open(outputFileName, "w")
|
|
185 f.write("arm_X\tS-MART\ttranscript\t100\t3199\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.4;Name=test1.4\n")
|
|
186 f.write("arm_X\tS-MART\ttranscript\t1000\t1999\t.\t+\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.1;Name=test1.1\n")
|
|
187 f.write("arm_X\tS-MART\ttranscript\t1000\t1999\t.\t-\t.\toverlapWith=test2.1;nbOverlaps=1.000000;ID=test1.2;Name=test1.2\n")
|
|
188 f.close()
|
|
189
|
|
190 def _writeInputFileQuery_withExon(self):
|
|
191 f = open(self._inputFileQuery, "w")
|
|
192 f.write("arm_X\t1000\t2000\ttest1.1\t1000\t+\t1000\t2000\t0\t1\t1000,\t0,\n")
|
|
193 f.write("arm_X\t1000\t2000\ttest1.2\t1000\t-\t1000\t2000\t0\t1\t1000,\t0,\n")
|
|
194 f.write("arm_X\t100\t200\ttest1.3\t1000\t+\t100\t200\t0\t1\t100,\t0,\n")
|
|
195 f.write("arm_X\t100\t3200\ttest1.4\t1000\t+\t100\t3200\t0\t2\t100,100,\t0,3000,\n")
|
|
196 f.close()
|
|
197
|
|
198 if __name__ == "__main__":
|
|
199 unittest.main()
|