1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ext.ensembl; |
22 |
|
|
23 |
|
import java.util.Locale; |
24 |
|
|
25 |
|
import static org.testng.AssertJUnit.assertEquals; |
26 |
|
import static org.testng.AssertJUnit.assertFalse; |
27 |
|
import static org.testng.AssertJUnit.assertNull; |
28 |
|
import static org.testng.AssertJUnit.assertTrue; |
29 |
|
|
30 |
|
import jalview.datamodel.Sequence; |
31 |
|
import jalview.datamodel.SequenceDummy; |
32 |
|
import jalview.datamodel.SequenceFeature; |
33 |
|
import jalview.datamodel.SequenceI; |
34 |
|
import jalview.gui.JvOptionPane; |
35 |
|
import jalview.io.gff.SequenceOntologyFactory; |
36 |
|
import jalview.io.gff.SequenceOntologyLite; |
37 |
|
import jalview.util.MapList; |
38 |
|
|
39 |
|
import java.util.List; |
40 |
|
|
41 |
|
import org.testng.Assert; |
42 |
|
import org.testng.annotations.AfterClass; |
43 |
|
import org.testng.annotations.BeforeClass; |
44 |
|
import org.testng.annotations.Test; |
45 |
|
|
|
|
| 0% |
Uncovered Elements: 135 (135) |
Complexity: 9 |
Complexity Density: 0.07 |
|
46 |
|
public class EnsemblCdnaTest |
47 |
|
{ |
48 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
49 |
0 |
@BeforeClass(alwaysRun = true)... |
50 |
|
public void setUpJvOptionPane() |
51 |
|
{ |
52 |
0 |
JvOptionPane.setInteractiveMode(false); |
53 |
0 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
54 |
|
} |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
56 |
0 |
@BeforeClass(alwaysRun = true)... |
57 |
|
public void setUp() |
58 |
|
{ |
59 |
0 |
SequenceOntologyFactory.setInstance(new SequenceOntologyLite()); |
60 |
|
} |
61 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
0 |
@AfterClass(alwaysRun = true)... |
63 |
|
public void tearDown() |
64 |
|
{ |
65 |
0 |
SequenceOntologyFactory.setInstance(null); |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
|
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 1 |
Complexity Density: 0.03 |
4-
|
|
72 |
0 |
@Test(groups = "Functional")... |
73 |
|
public void testGetGenomicRangesFromFeatures_reverseStrand() |
74 |
|
{ |
75 |
0 |
EnsemblCdna testee = new EnsemblCdna(); |
76 |
0 |
SequenceI genomic = new SequenceDummy("chr7"); |
77 |
0 |
genomic.setStart(10000); |
78 |
0 |
genomic.setEnd(50000); |
79 |
0 |
String transcriptId = "ABC123"; |
80 |
|
|
81 |
|
|
82 |
0 |
SequenceFeature sf = new SequenceFeature("exon", "", 20000, 20500, 0f, |
83 |
|
null); |
84 |
0 |
sf.setValue("Parent", transcriptId); |
85 |
0 |
sf.setStrand("-"); |
86 |
0 |
genomic.addSequenceFeature(sf); |
87 |
|
|
88 |
|
|
89 |
0 |
sf = new SequenceFeature("coding_exon", "", 10500, 10600, 0f, null); |
90 |
0 |
sf.setValue("Parent", transcriptId); |
91 |
0 |
sf.setStrand("-"); |
92 |
0 |
genomic.addSequenceFeature(sf); |
93 |
|
|
94 |
|
|
95 |
0 |
sf = new SequenceFeature("exon", "", 11500, 12600, 0f, null); |
96 |
0 |
sf.setValue("Parent", "anotherOne"); |
97 |
0 |
genomic.addSequenceFeature(sf); |
98 |
|
|
99 |
|
|
100 |
0 |
sf = new SequenceFeature("transcript", "", 10000, 50000, 0f, null); |
101 |
0 |
genomic.addSequenceFeature(sf); |
102 |
|
|
103 |
0 |
MapList ranges = testee.getGenomicRangesFromFeatures(genomic, |
104 |
|
transcriptId, 23); |
105 |
0 |
List<int[]> fromRanges = ranges.getFromRanges(); |
106 |
0 |
assertEquals(2, fromRanges.size()); |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
0 |
assertEquals(20500, fromRanges.get(0)[0]); |
113 |
0 |
assertEquals(20000, fromRanges.get(0)[1]); |
114 |
0 |
assertEquals(10600, fromRanges.get(1)[0]); |
115 |
0 |
assertEquals(10500, fromRanges.get(1)[1]); |
116 |
|
|
117 |
0 |
List<int[]> toRanges = ranges.getToRanges(); |
118 |
0 |
assertEquals(1, toRanges.size()); |
119 |
0 |
assertEquals(23, toRanges.get(0)[0]); |
120 |
0 |
assertEquals(624, toRanges.get(0)[1]); |
121 |
|
} |
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 1 |
Complexity Density: 0.03 |
4-
|
|
127 |
0 |
@Test(groups = "Functional")... |
128 |
|
public void testGetGenomicRangesFromFeatures() |
129 |
|
{ |
130 |
0 |
EnsemblCdna testee = new EnsemblCdna(); |
131 |
0 |
SequenceI genomic = new SequenceDummy("chr7"); |
132 |
0 |
genomic.setStart(10000); |
133 |
0 |
genomic.setEnd(50000); |
134 |
0 |
String transcriptId = "ABC123"; |
135 |
|
|
136 |
|
|
137 |
0 |
SequenceFeature sf = new SequenceFeature("exon", "", 20000, 20500, 0f, |
138 |
|
null); |
139 |
0 |
sf.setValue("Parent", transcriptId); |
140 |
0 |
sf.setStrand("+"); |
141 |
0 |
genomic.addSequenceFeature(sf); |
142 |
|
|
143 |
|
|
144 |
0 |
sf = new SequenceFeature("coding_exon", "", 10500, 10600, 0f, null); |
145 |
0 |
sf.setValue("Parent", transcriptId); |
146 |
0 |
sf.setStrand("+"); |
147 |
0 |
genomic.addSequenceFeature(sf); |
148 |
|
|
149 |
|
|
150 |
0 |
sf = new SequenceFeature("exon", "", 11500, 12600, 0f, null); |
151 |
0 |
sf.setValue("Parent", "anotherOne"); |
152 |
0 |
genomic.addSequenceFeature(sf); |
153 |
|
|
154 |
|
|
155 |
0 |
sf = new SequenceFeature("transcript", "", 10000, 50000, 0f, null); |
156 |
0 |
sf.setStrand("-"); |
157 |
0 |
genomic.addSequenceFeature(sf); |
158 |
|
|
159 |
0 |
MapList ranges = testee.getGenomicRangesFromFeatures(genomic, |
160 |
|
transcriptId, 23); |
161 |
0 |
List<int[]> fromRanges = ranges.getFromRanges(); |
162 |
0 |
assertEquals(2, fromRanges.size()); |
163 |
|
|
164 |
0 |
assertEquals(10500, fromRanges.get(0)[0]); |
165 |
0 |
assertEquals(10600, fromRanges.get(0)[1]); |
166 |
0 |
assertEquals(20000, fromRanges.get(1)[0]); |
167 |
0 |
assertEquals(20500, fromRanges.get(1)[1]); |
168 |
|
|
169 |
0 |
List<int[]> toRanges = ranges.getToRanges(); |
170 |
0 |
assertEquals(1, toRanges.size()); |
171 |
0 |
assertEquals(23, toRanges.get(0)[0]); |
172 |
0 |
assertEquals(624, toRanges.get(0)[1]); |
173 |
|
} |
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
4-
|
|
179 |
0 |
@Test(groups = "Functional")... |
180 |
|
public void testGetGenomicRangesFromFeatures_mixedStrand() |
181 |
|
{ |
182 |
0 |
EnsemblCdna testee = new EnsemblCdna(); |
183 |
0 |
SequenceI genomic = new SequenceDummy("chr7"); |
184 |
0 |
genomic.setStart(10000); |
185 |
0 |
genomic.setEnd(50000); |
186 |
0 |
String transcriptId = "ABC123"; |
187 |
|
|
188 |
0 |
SequenceFeature sf = new SequenceFeature("exon", "", 20000, 20500, 0f, |
189 |
|
null); |
190 |
0 |
sf.setValue("Parent", "transcript:" + transcriptId); |
191 |
0 |
sf.setStrand("-"); |
192 |
0 |
genomic.addSequenceFeature(sf); |
193 |
|
|
194 |
0 |
sf = new SequenceFeature("coding_exon", "", 10500, 10600, 0f, null); |
195 |
0 |
sf.setValue("Parent", "transcript:" + transcriptId); |
196 |
0 |
sf.setStrand("+"); |
197 |
0 |
genomic.addSequenceFeature(sf); |
198 |
|
|
199 |
0 |
MapList ranges = testee.getGenomicRangesFromFeatures(genomic, |
200 |
|
transcriptId, 23); |
201 |
0 |
assertNull(ranges); |
202 |
|
} |
203 |
|
|
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
4-
|
|
208 |
0 |
@Test(groups = "Functional")... |
209 |
|
public void testRetainFeature() |
210 |
|
{ |
211 |
0 |
String accId = "ABC123"; |
212 |
0 |
EnsemblCdna testee = new EnsemblCdna(); |
213 |
|
|
214 |
0 |
SequenceFeature sf = new SequenceFeature("transcript", "", 20000, 20500, |
215 |
|
0f, null); |
216 |
0 |
assertFalse(testee.retainFeature(sf, accId)); |
217 |
|
|
218 |
0 |
sf = new SequenceFeature("aberrant_processed_transcript", "", 20000, |
219 |
|
20500, 0f, null); |
220 |
0 |
assertFalse(testee.retainFeature(sf, accId)); |
221 |
|
|
222 |
0 |
sf = new SequenceFeature("NMD_transcript_variant", "", 20000, 20500, 0f, |
223 |
|
null); |
224 |
0 |
assertFalse(testee.retainFeature(sf, accId)); |
225 |
|
|
226 |
|
|
227 |
0 |
sf = new SequenceFeature("sequence_variant", "", 20000, 20500, 0f, |
228 |
|
null); |
229 |
0 |
assertTrue(testee.retainFeature(sf, accId)); |
230 |
|
|
231 |
|
|
232 |
0 |
sf.setValue("Parent", accId); |
233 |
0 |
assertTrue(testee.retainFeature(sf, accId)); |
234 |
|
|
235 |
|
|
236 |
0 |
assertTrue(testee.retainFeature(sf, accId.toLowerCase(Locale.ROOT))); |
237 |
|
|
238 |
|
|
239 |
0 |
sf.setValue("Parent", "XYZ"); |
240 |
0 |
assertFalse(testee.retainFeature(sf, accId)); |
241 |
|
} |
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 1 |
Complexity Density: 0.04 |
4-
|
|
247 |
0 |
@Test(groups = "Functional")... |
248 |
|
public void testGetIdentifyingFeatures() |
249 |
|
{ |
250 |
0 |
String accId = "ABC123"; |
251 |
0 |
SequenceI seq = new Sequence(accId, "MKLNFRQIE"); |
252 |
|
|
253 |
|
|
254 |
0 |
SequenceFeature sf1 = new SequenceFeature("exon", "", 1, 2, 0f, null); |
255 |
0 |
seq.addSequenceFeature(sf1); |
256 |
|
|
257 |
|
|
258 |
0 |
SequenceFeature sf2 = new SequenceFeature("exon", "", 1, 2, 0f, null); |
259 |
0 |
sf2.setValue("Parent", "XYZ"); |
260 |
0 |
seq.addSequenceFeature(sf2); |
261 |
|
|
262 |
|
|
263 |
0 |
SequenceFeature sf3 = new SequenceFeature("exon", "", 1, 2, 0f, null); |
264 |
0 |
sf3.setValue("Parent", accId); |
265 |
0 |
seq.addSequenceFeature(sf3); |
266 |
|
|
267 |
|
|
268 |
0 |
SequenceFeature sf4 = new SequenceFeature("coding_exon", "", 1, 2, 0f, |
269 |
|
null); |
270 |
0 |
sf4.setValue("Parent", accId); |
271 |
0 |
seq.addSequenceFeature(sf4); |
272 |
|
|
273 |
|
|
274 |
0 |
SequenceFeature sf5 = new SequenceFeature("transcript", "", 1, 2, 0f, |
275 |
|
null); |
276 |
0 |
sf5.setValue("Parent", accId); |
277 |
0 |
seq.addSequenceFeature(sf5); |
278 |
|
|
279 |
|
|
280 |
0 |
SequenceFeature sf6 = new SequenceFeature("transcript", "", 1, 2, 0f, |
281 |
|
null); |
282 |
0 |
sf6.setValue("Parent", accId); |
283 |
0 |
seq.addSequenceFeature(sf6); |
284 |
|
|
285 |
0 |
List<SequenceFeature> sfs = new EnsemblCdna() |
286 |
|
.getIdentifyingFeatures(seq, accId); |
287 |
0 |
assertFalse(sfs.contains(sf1)); |
288 |
0 |
assertFalse(sfs.contains(sf2)); |
289 |
0 |
assertTrue(sfs.contains(sf3)); |
290 |
0 |
assertTrue(sfs.contains(sf4)); |
291 |
0 |
assertFalse(sfs.contains(sf5)); |
292 |
0 |
assertFalse(sfs.contains(sf6)); |
293 |
|
} |
294 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
4-
|
|
295 |
0 |
@Test(groups = "Functional")... |
296 |
|
public void testIsValidReference() throws Exception |
297 |
|
{ |
298 |
0 |
EnsemblSequenceFetcher esq = new EnsemblCdna(); |
299 |
0 |
Assert.assertTrue(esq.isValidReference("CCDS5863.1")); |
300 |
0 |
Assert.assertTrue(esq.isValidReference("ENST00000288602")); |
301 |
0 |
Assert.assertTrue(esq.isValidReference("ENSG00000288602")); |
302 |
0 |
Assert.assertFalse(esq.isValidReference("ENSP00000288602")); |
303 |
0 |
Assert.assertFalse(esq.isValidReference("ENST0000288602")); |
304 |
|
|
305 |
0 |
Assert.assertTrue(esq.isValidReference("ENSMUSG00000099398")); |
306 |
|
} |
307 |
|
} |