annotate SMART/Java/Python/test/Test_F_getExons.py @ 25:7809e72960fe

Deleted selected files
author m-zytnicki
date Mon, 29 Apr 2013 03:29:14 -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 unittest
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
2 import os
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
3 from SMART.Java.Python.getExons import GetExons
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
4 from commons.core.parsing.GffParser import GffParser
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
5
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6 class Test_F_GetExons(unittest.TestCase):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
7
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
8 def setUp(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
9 self._inputFileName = "inputFileTest.bed"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
10 self._writeInputFile()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11 self._outputFileName = "output.gff3"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 def tearDown(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14 os.remove(self._inputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15 os.remove(self._outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17 def test_run_simple(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18 ge = GetExons(0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 ge.setInputFile(self._inputFileName, "bed")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 ge.setOutputFile(self._outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21 ge.run()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22 parser = GffParser(self._outputFileName, 0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23 self.assertEqual(parser.getNbTranscripts(), 5)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24 for cpt, transcript in enumerate(parser.getIterator()):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25 self.assertEqual(transcript.getChromosome(), "arm_X")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26 self.assertEqual(transcript.getDirection(), 1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 self.assertEqual(transcript.getNbExons(), 1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 if cpt == 0:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29 self.assertEqual(transcript.getStart(), 10000001)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30 self.assertEqual(transcript.getEnd(), 10000100)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 elif cpt == 1:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32 self.assertEqual(transcript.getStart(), 10000201)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 self.assertEqual(transcript.getEnd(), 10000300)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34 elif cpt == 2:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35 self.assertEqual(transcript.getStart(), 10000401)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36 self.assertEqual(transcript.getEnd(), 10000500)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
37 elif cpt == 3:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
38 self.assertEqual(transcript.getStart(), 10000601)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
39 self.assertEqual(transcript.getEnd(), 10000700)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
40 elif cpt == 4:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
41 self.assertEqual(transcript.getStart(), 10000801)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
42 self.assertEqual(transcript.getEnd(), 10000900)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
43
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
44 def test_run_firstExon(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
45 ge = GetExons(0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
46 ge.setInputFile(self._inputFileName, "bed")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
47 ge.setOutputFile(self._outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
48 ge.setSelection("1")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
49 ge.run()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
50 parser = GffParser(self._outputFileName, 0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
51 self.assertEqual(parser.getNbTranscripts(), 1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
52 for cpt, transcript in enumerate(parser.getIterator()):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
53 self.assertEqual(transcript.getChromosome(), "arm_X")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
54 self.assertEqual(transcript.getDirection(), 1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
55 self.assertEqual(transcript.getNbExons(), 1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
56 self.assertEqual(transcript.getStart(), 10000001)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
57 self.assertEqual(transcript.getEnd(), 10000100)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
58
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
59 def test_run_lastExon(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
60 ge = GetExons(0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
61 ge.setInputFile(self._inputFileName, "bed")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
62 ge.setOutputFile(self._outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
63 ge.setSelection("-1")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
64 ge.run()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
65 parser = GffParser(self._outputFileName, 0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
66 self.assertEqual(parser.getNbTranscripts(), 1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
67 for cpt, transcript in enumerate(parser.getIterator()):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
68 self.assertEqual(transcript.getChromosome(), "arm_X")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
69 self.assertEqual(transcript.getDirection(), 1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
70 self.assertEqual(transcript.getNbExons(), 1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
71 self.assertEqual(transcript.getStart(), 10000801)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
72 self.assertEqual(transcript.getEnd(), 10000900)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
73
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
74 def test_run_first_lastExon(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
75 ge = GetExons(0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
76 ge.setInputFile(self._inputFileName, "bed")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
77 ge.setOutputFile(self._outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
78 ge.setSelection("1,-1")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
79 ge.run()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
80 parser = GffParser(self._outputFileName, 0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
81 self.assertEqual(parser.getNbTranscripts(), 2)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
82 for cpt, transcript in enumerate(parser.getIterator()):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
83 self.assertEqual(transcript.getChromosome(), "arm_X")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
84 self.assertEqual(transcript.getDirection(), 1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
85 self.assertEqual(transcript.getNbExons(), 1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
86 if cpt == 0:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
87 self.assertEqual(transcript.getStart(), 10000001)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
88 self.assertEqual(transcript.getEnd(), 10000100)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
89 elif cpt == 1:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
90 self.assertEqual(transcript.getStart(), 10000801)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
91 self.assertEqual(transcript.getEnd(), 10000900)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
92
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
93 def test_run_interval(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
94 ge = GetExons(0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
95 ge.setInputFile(self._inputFileName, "bed")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
96 ge.setOutputFile(self._outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
97 ge.setSelection("2..3")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
98 ge.run()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
99 parser = GffParser(self._outputFileName, 0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
100 self.assertEqual(parser.getNbTranscripts(), 2)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
101 for cpt, transcript in enumerate(parser.getIterator()):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
102 self.assertEqual(transcript.getChromosome(), "arm_X")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
103 self.assertEqual(transcript.getDirection(), 1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
104 self.assertEqual(transcript.getNbExons(), 1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
105 if cpt == 0:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
106 self.assertEqual(transcript.getStart(), 10000201)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
107 self.assertEqual(transcript.getEnd(), 10000300)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
108 elif cpt == 1:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
109 self.assertEqual(transcript.getStart(), 10000401)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
110 self.assertEqual(transcript.getEnd(), 10000500)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
111
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
112 def test_run_interval_element(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
113 ge = GetExons(0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
114 ge.setInputFile(self._inputFileName, "bed")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
115 ge.setOutputFile(self._outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
116 ge.setSelection("2..3,-1")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
117 ge.run()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
118 parser = GffParser(self._outputFileName, 0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
119 self.assertEqual(parser.getNbTranscripts(), 3)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
120 for cpt, transcript in enumerate(parser.getIterator()):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
121 self.assertEqual(transcript.getChromosome(), "arm_X")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
122 self.assertEqual(transcript.getDirection(), 1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
123 self.assertEqual(transcript.getNbExons(), 1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
124 if cpt == 0:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
125 self.assertEqual(transcript.getStart(), 10000201)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
126 self.assertEqual(transcript.getEnd(), 10000300)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
127 elif cpt == 1:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
128 self.assertEqual(transcript.getStart(), 10000401)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
129 self.assertEqual(transcript.getEnd(), 10000500)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
130 elif cpt == 2:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
131 self.assertEqual(transcript.getStart(), 10000801)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
132 self.assertEqual(transcript.getEnd(), 10000900)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
133
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
134
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
135
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
136 def _writeInputFile(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
137 f = open(self._inputFileName, "w")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
138 f.write("arm_X\t10000001\t10000900\ttest1.1\t100\t+\t10000100\t10000200\t0\t5\t100,100,100,100,100,\t0,200,400,600,800,\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
139 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
140
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
141
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
142
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
143 if __name__ == "__main__":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
144 unittest.main()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
145