annotate SMART/Java/Python/structure/test/Test_Transcript.py @ 6:769e306b7933

Change the repository level.
author yufei-luo
date Fri, 18 Jan 2013 04:54:14 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1 import unittest
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2 from SMART.Java.Python.structure.Interval import Interval
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 from SMART.Java.Python.structure.Transcript import Transcript
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
4
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
5 class Test_Transcript(unittest.TestCase):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
7 def test_getSize(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
8 transcript1 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
9 transcript1.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
10 transcript1.setStart(2000)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
11 transcript1.setEnd(3000)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
12 transcript1.setChromosome("arm_X")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
13
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
14 self.assertEqual(transcript1.getSize(), 1001)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
15
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
16 transcript2 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
17 transcript2.copy(transcript1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
18 self.assertEqual(transcript1.getSize(), 1001)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
19
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
20 transcript3 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
21 transcript3.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
22 transcript3.setChromosome("arm_X")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
23
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
24 exon1 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
25 exon1.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
26 exon1.setChromosome("arm_X")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
27 exon1.setStart(100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
28 exon1.setEnd(200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
29 transcript3.addExon(exon1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
30
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31 exon2 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32 exon2.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 exon2.setChromosome("arm_X")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34 exon2.setStart(300)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35 exon2.setEnd(400)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36 transcript3.addExon(exon2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 self.assertEqual(transcript3.getSize(), 203)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 def test_overlapWithExons(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42 exon1_1 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 exon1_1.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44 exon1_1.setStart(100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45 exon1_1.setEnd(200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46 exon1_1.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
47
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
48 exon1_2 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
49 exon1_2.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
50 exon1_2.setStart(500)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
51 exon1_2.setEnd(600)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
52 exon1_2.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
53
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
54 transcript1 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
55 transcript1.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
56 transcript1.setStart(100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
57 transcript1.setEnd(600)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
58 transcript1.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
59 transcript1.addExon(exon1_1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
60 transcript1.addExon(exon1_2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
61
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
62 exon2_1 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
63 exon2_1.copy(exon1_1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
64
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
65 transcript2 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
66 transcript2.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
67 transcript2.setStart(100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
68 transcript2.setEnd(200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
69 transcript2.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
70 transcript2.addExon(exon2_1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
71
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
72 self.assertTrue(transcript1.overlapWithExon(transcript2))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
73
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
74 transcript2.reverse()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
75 try:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
76 self.assertFalse(transcript1.overlapWithExon(transcript2))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
77 except Exception:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
78 pass
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
79
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
80 transcript2.reverse()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
81 transcript2.setChromosome("chr2")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
82 self.assertFalse(transcript1.overlapWithExon(transcript2))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
83
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
84 exon3_1 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
85 exon3_1.copy(exon1_1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
86 exon3_1.setEnd(400)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
87 exon3_1.setStart(300)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
88
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
89 transcript3 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
90 transcript3.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
91 transcript3.setStart(300)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
92 transcript3.setEnd(400)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
93 transcript3.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
94 transcript3.addExon(exon3_1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
95 self.assertFalse(transcript1.overlapWithExon(transcript3))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
96
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
97
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
98 def test_merge(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
99 exon1_1 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
100 exon1_1.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
101 exon1_1.setStart(100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
102 exon1_1.setEnd(200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
103 exon1_1.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
104
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
105 exon1_2 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
106 exon1_2.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
107 exon1_2.setStart(500)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
108 exon1_2.setEnd(600)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
109 exon1_2.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
110
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
111 transcript1 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
112 transcript1.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
113 transcript1.setEnd(600)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
114 transcript1.setStart(100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
115 transcript1.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
116 transcript1.addExon(exon1_1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
117 transcript1.addExon(exon1_2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
118
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
119 exon2_1 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
120 exon2_1.copy(exon1_1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
121
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
122 transcript2 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
123 transcript2.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
124 transcript2.setEnd(200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
125 transcript2.setStart(100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
126 transcript2.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
127 transcript2.addExon(exon2_1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
128
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
129 transcript1.merge(transcript2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
130 transcript1.sortExonsIncreasing()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
131 exons = transcript1.getExons()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
132 self.assertEqual(len(exons), 2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
133 exon1, exon2 = exons
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
134 self.assertEqual(exon1.getStart(), 100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
135 self.assertEqual(exon1.getEnd(), 200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
136 self.assertEqual(exon2.getStart(), 500)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
137 self.assertEqual(exon2.getEnd(), 600)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
138
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
139 transcript2.setChromosome("chr2")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
140 try:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
141 transcript1.merge(transcript2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
142 self.fail()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
143 except Exception:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
144 pass
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
145
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
146 exon3_1 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
147 exon3_1.copy(exon1_1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
148 exon3_1.setEnd(650)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
149 exon3_1.setStart(550)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
150
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
151 transcript3 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
152 transcript3.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
153 transcript3.setEnd(650)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
154 transcript3.setStart(550)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
155 transcript3.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
156 transcript3.addExon(exon3_1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
157
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
158 transcript1.merge(transcript3)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
159 self.assertEqual(transcript1.getStart(), 100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
160 self.assertEqual(transcript1.getEnd(), 650)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
161 exons = transcript1.getExons()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
162 self.assertEqual(len(exons), 2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
163 exon1, exon2 = exons
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
164 self.assertEqual(exon1.getStart(), 100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
165 self.assertEqual(exon1.getEnd(), 200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
166 self.assertEqual(exon2.getStart(), 500)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
167 self.assertEqual(exon2.getEnd(), 650)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
168
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
169 exon4_1 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
170 exon4_1.copy(exon1_1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
171 exon4_1.setEnd(400)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
172 exon4_1.setStart(300)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
173
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
174 transcript4 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
175 transcript4.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
176 transcript4.setStart(300)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
177 transcript4.setEnd(400)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
178 transcript4.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
179 transcript4.addExon(exon4_1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
180
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
181 transcript1.merge(transcript4)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
182 self.assertEqual(transcript1.getStart(), 100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
183 self.assertEqual(transcript1.getEnd(), 650)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
184 transcript1.sortExonsIncreasing()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
185 exons = transcript1.getExons()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
186 self.assertEqual(len(exons), 3)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
187 exon1, exon2, exon3 = exons
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
188 self.assertEqual(exon1.getStart(), 100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
189 self.assertEqual(exon1.getEnd(), 200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
190 self.assertEqual(exon2.getStart(), 300)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
191 self.assertEqual(exon2.getEnd(), 400)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
192 self.assertEqual(exon3.getStart(), 500)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
193 self.assertEqual(exon3.getEnd(), 650)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
194
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
195
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
196 def test_extendStart(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
197 transcript1 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
198 transcript1.setStart(2000)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
199 transcript1.setEnd(3000)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
200 transcript1.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
201 transcript1.setChromosome("arm_X")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
202
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
203 transcript2 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
204 transcript2.copy(transcript1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
205 transcript2.setDirection("-")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
206
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
207 transcript1.extendStart(1000)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
208 transcript2.extendStart(1000)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
209
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
210
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
211 self.assertEqual(transcript1.getDirection(), 1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
212 self.assertEqual(transcript1.getStart(), 1000)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
213 self.assertEqual(transcript1.getEnd(), 3000)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
214 self.assertEqual(transcript1.getChromosome(), "arm_X")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
215
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
216 self.assertEqual(transcript2.getDirection(), -1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
217 self.assertEqual(transcript2.getStart(), 2000)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
218 self.assertEqual(transcript2.getEnd(), 4000)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
219 self.assertEqual(transcript2.getChromosome(), "arm_X")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
220
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
221
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
222 def test_restrictStart(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
223 exon1_1 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
224 exon1_1.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
225 exon1_1.setStart(100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
226 exon1_1.setEnd(200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
227 exon1_1.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
228
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
229 exon1_2 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
230 exon1_2.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
231 exon1_2.setStart(300)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
232 exon1_2.setEnd(500)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
233 exon1_2.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
234
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
235 transcript1 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
236 transcript1.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
237 transcript1.setStart(100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
238 transcript1.setEnd(500)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
239 transcript1.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
240 transcript1.addExon(exon1_1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
241 transcript1.addExon(exon1_2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
242
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
243 transcript1.restrictStart(301)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
244 exons = transcript1.getExons()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
245 self.assertEqual(len(exons), 2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
246 exon1, exon2 = exons
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
247 self.assertEqual(exon1.getStart(), 100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
248 self.assertEqual(exon1.getEnd(), 200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
249 self.assertEqual(exon2.getStart(), 300)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
250 self.assertEqual(exon2.getEnd(), 400)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
251
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
252
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
253 def test__include(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
254 iTranscript1 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
255 iTranscript1.setName("transcript1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
256 iTranscript1.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
257 iTranscript1.setStart(100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
258 iTranscript1.setEnd(200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
259 iTranscript1.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
260
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
261 iTranscript2 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
262 iTranscript2.copy(iTranscript1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
263 iTranscript2.setName("transcript2")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
264 self.assertTrue(iTranscript1.include(iTranscript2))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
265 self.assertTrue(iTranscript2.include(iTranscript1))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
266
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
267 iTranscript2.setChromosome("chr2")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
268 self.assertFalse(iTranscript1.include(iTranscript2))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
269 self.assertFalse(iTranscript2.include(iTranscript1))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
270
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
271 iTranscript2.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
272 exon = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
273 exon.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
274 exon.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
275 exon.setStart(300)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
276 exon.setEnd(400)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
277 iTranscript1.addExon(exon)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
278 self.assertTrue(iTranscript1.include(iTranscript2))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
279 self.assertFalse(iTranscript2.include(iTranscript1))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
280
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
281 exon = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
282 exon.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
283 exon.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
284 exon.setStart(500)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
285 exon.setEnd(600)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
286 iTranscript2.addExon(exon)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
287 self.assertFalse(iTranscript1.include(iTranscript2))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
288 self.assertFalse(iTranscript2.include(iTranscript1))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
289
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
290
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
291 def test__getDifference(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
292 iTranscript1 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
293 iTranscript1.setName("transcript1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
294 iTranscript1.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
295 iTranscript1.setStart(100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
296 iTranscript1.setEnd(400)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
297 iTranscript1.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
298
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
299 iTranscript2 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
300 iTranscript2.setName("transcript1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
301 iTranscript2.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
302 iTranscript2.setStart(200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
303 iTranscript2.setEnd(400)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
304 iTranscript2.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
305
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
306 newTranscript = iTranscript1.getDifference(iTranscript2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
307 self.assertTrue(newTranscript.getStart(), 100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
308 self.assertTrue(newTranscript.getEnd(), 199)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
309 exons = newTranscript.getExons()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
310 self.assertTrue(len(exons), 1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
311 exon1 = exons[0]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
312 self.assertTrue(exon1.getStart(), 100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
313 self.assertTrue(exon1.getEnd(), 199)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
314
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
315 iTranscript2 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
316 iTranscript2.setName("transcript1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
317 iTranscript2.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
318 iTranscript2.setStart(100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
319 iTranscript2.setEnd(200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
320 iTranscript2.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
321
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
322 newTranscript = iTranscript1.getDifference(iTranscript2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
323 self.assertTrue(newTranscript.getStart(), 201)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
324 self.assertTrue(newTranscript.getEnd(), 400)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
325 exons = newTranscript.getExons()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
326 self.assertTrue(len(exons), 1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
327 exon1 = exons[0]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
328 self.assertTrue(exon1.getStart(), 201)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
329 self.assertTrue(exon1.getEnd(), 400)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
330
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
331 iTranscript2 = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
332 iTranscript2.setName("transcript1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
333 iTranscript2.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
334 iTranscript2.setStart(200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
335 iTranscript2.setEnd(300)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
336 iTranscript2.setDirection("+")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
337
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
338 newTranscript = iTranscript1.getDifference(iTranscript2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
339 self.assertTrue(newTranscript.getStart(), 100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
340 self.assertTrue(newTranscript.getEnd(), 400)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
341 exons = newTranscript.getExons()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
342 self.assertTrue(len(exons), 2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
343 exon1, exon2 = exons
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
344 self.assertTrue(exon1.getStart(), 100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
345 self.assertTrue(exon1.getEnd(), 199)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
346 self.assertTrue(exon2.getStart(), 301)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
347 self.assertTrue(exon2.getEnd(), 400)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
348
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
349
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
350 if __name__ == '__main__':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
351 unittest.main()