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