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.assertTrue; |
28 |
|
|
29 |
|
import jalview.api.FeatureSettingsModelI; |
30 |
|
import jalview.bin.Cache; |
31 |
|
import jalview.datamodel.Sequence; |
32 |
|
import jalview.datamodel.SequenceDummy; |
33 |
|
import jalview.datamodel.SequenceFeature; |
34 |
|
import jalview.datamodel.SequenceI; |
35 |
|
import jalview.gui.JvOptionPane; |
36 |
|
import jalview.io.gff.SequenceOntologyFactory; |
37 |
|
import jalview.io.gff.SequenceOntologyLite; |
38 |
|
import jalview.util.MapList; |
39 |
|
|
40 |
|
import java.awt.Color; |
41 |
|
import java.util.List; |
42 |
|
|
43 |
|
import org.testng.annotations.AfterClass; |
44 |
|
import org.testng.annotations.BeforeClass; |
45 |
|
import org.testng.annotations.Test; |
46 |
|
|
|
|
| 91.5% |
Uncovered Elements: 13 (153) |
Complexity: 10 |
Complexity Density: 0.07 |
|
47 |
|
public class EnsemblGeneTest |
48 |
|
{ |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
50 |
1 |
@BeforeClass(alwaysRun = true)... |
51 |
|
public void setUpJvOptionPane() |
52 |
|
{ |
53 |
1 |
JvOptionPane.setInteractiveMode(false); |
54 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
55 |
|
} |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
57 |
1 |
@BeforeClass(alwaysRun = true)... |
58 |
|
public void setUp() |
59 |
|
{ |
60 |
1 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
61 |
1 |
SequenceOntologyFactory.setInstance(new SequenceOntologyLite()); |
62 |
|
} |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
1 |
@AfterClass(alwaysRun = true)... |
65 |
|
public void tearDown() |
66 |
|
{ |
67 |
1 |
SequenceOntologyFactory.setInstance(null); |
68 |
|
} |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
74 |
1 |
@Test(groups = "Functional")... |
75 |
|
public void testGetGenomicRangesFromFeatures() |
76 |
|
{ |
77 |
1 |
EnsemblGene testee = new EnsemblGene(); |
78 |
1 |
SequenceI genomic = new SequenceDummy("chr7"); |
79 |
1 |
genomic.setStart(10000); |
80 |
1 |
genomic.setEnd(50000); |
81 |
1 |
String geneId = "ABC123"; |
82 |
|
|
83 |
|
|
84 |
1 |
SequenceFeature sf = new SequenceFeature("gene", "", 10500, 10600, 0f, |
85 |
|
null); |
86 |
1 |
sf.setValue("id", geneId); |
87 |
1 |
sf.setStrand("+"); |
88 |
1 |
genomic.addSequenceFeature(sf); |
89 |
|
|
90 |
1 |
MapList ranges = testee.getGenomicRangesFromFeatures(genomic, geneId, |
91 |
|
23); |
92 |
1 |
List<int[]> fromRanges = ranges.getFromRanges(); |
93 |
1 |
assertEquals(1, fromRanges.size()); |
94 |
1 |
assertEquals(10500, fromRanges.get(0)[0]); |
95 |
1 |
assertEquals(10600, fromRanges.get(0)[1]); |
96 |
|
|
97 |
1 |
List<int[]> toRanges = ranges.getToRanges(); |
98 |
1 |
assertEquals(1, toRanges.size()); |
99 |
1 |
assertEquals(23, toRanges.get(0)[0]); |
100 |
1 |
assertEquals(123, toRanges.get(0)[1]); |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
106 |
1 |
@Test(groups = "Functional")... |
107 |
|
public void testGetGenomicRangesFromFeatures_ncRNA_gene_reverseStrand() |
108 |
|
{ |
109 |
1 |
EnsemblGene testee = new EnsemblGene(); |
110 |
1 |
SequenceI genomic = new SequenceDummy("chr7"); |
111 |
1 |
genomic.setStart(10000); |
112 |
1 |
genomic.setEnd(50000); |
113 |
1 |
String geneId = "ABC123"; |
114 |
|
|
115 |
|
|
116 |
1 |
SequenceFeature sf = new SequenceFeature("gene", "", 10500, 10600, 0f, |
117 |
|
null); |
118 |
1 |
sf.setValue("id", geneId); |
119 |
1 |
sf.setStrand("+"); |
120 |
1 |
genomic.addSequenceFeature(sf); |
121 |
|
|
122 |
1 |
MapList ranges = testee.getGenomicRangesFromFeatures(genomic, geneId, |
123 |
|
23); |
124 |
1 |
List<int[]> fromRanges = ranges.getFromRanges(); |
125 |
1 |
assertEquals(1, fromRanges.size()); |
126 |
|
|
127 |
1 |
assertEquals(10500, fromRanges.get(0)[0]); |
128 |
1 |
assertEquals(10600, fromRanges.get(0)[1]); |
129 |
|
|
130 |
1 |
List<int[]> toRanges = ranges.getToRanges(); |
131 |
1 |
assertEquals(1, toRanges.size()); |
132 |
1 |
assertEquals(23, toRanges.get(0)[0]); |
133 |
1 |
assertEquals(123, toRanges.get(0)[1]); |
134 |
|
} |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
140 |
1 |
@Test(groups = "Functional")... |
141 |
|
public void testGetTranscriptFeatures() |
142 |
|
{ |
143 |
1 |
SequenceI genomic = new SequenceDummy("chr7"); |
144 |
1 |
genomic.setStart(10000); |
145 |
1 |
genomic.setEnd(50000); |
146 |
1 |
String geneId = "ABC123"; |
147 |
|
|
148 |
|
|
149 |
1 |
SequenceFeature sf1 = new SequenceFeature("transcript", "", 20000, |
150 |
|
20500, 0f, null); |
151 |
1 |
sf1.setValue("Parent", geneId); |
152 |
1 |
sf1.setValue("id", "transcript1"); |
153 |
1 |
genomic.addSequenceFeature(sf1); |
154 |
|
|
155 |
|
|
156 |
1 |
SequenceFeature sf2 = new SequenceFeature("snRNA", "", 21000, 21500, 0f, |
157 |
|
null); |
158 |
1 |
sf2.setValue("Parent", geneId); |
159 |
1 |
sf2.setValue("id", "transcript2"); |
160 |
1 |
genomic.addSequenceFeature(sf2); |
161 |
|
|
162 |
|
|
163 |
1 |
SequenceFeature sf3 = new SequenceFeature("NMD_transcript_variant", "", |
164 |
|
22000, 22500, 0f, null); |
165 |
|
|
166 |
1 |
sf3.setValue("Parent", geneId.toLowerCase(Locale.ROOT)); |
167 |
1 |
sf3.setValue("id", "transcript3"); |
168 |
1 |
genomic.addSequenceFeature(sf3); |
169 |
|
|
170 |
|
|
171 |
1 |
SequenceFeature sf4 = new SequenceFeature("snRNA", "", 23000, 23500, 0f, |
172 |
|
null); |
173 |
1 |
sf4.setValue("Parent", "XYZ"); |
174 |
1 |
sf4.setValue("id", "transcript4"); |
175 |
1 |
genomic.addSequenceFeature(sf4); |
176 |
|
|
177 |
1 |
EnsemblGene testee = new EnsemblGene(); |
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
1 |
List<SequenceFeature> features = testee.getTranscriptFeatures(geneId, |
183 |
|
genomic); |
184 |
1 |
assertEquals(3, features.size()); |
185 |
1 |
assertTrue(features.contains(sf1)); |
186 |
1 |
assertTrue(features.contains(sf2)); |
187 |
1 |
assertTrue(features.contains(sf3)); |
188 |
|
} |
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
194 |
1 |
@Test(groups = "Functional")... |
195 |
|
public void testRetainFeature() |
196 |
|
{ |
197 |
1 |
String geneId = "ABC123"; |
198 |
1 |
EnsemblGene testee = new EnsemblGene(); |
199 |
1 |
SequenceFeature sf = new SequenceFeature("gene", "", 20000, 20500, 0f, |
200 |
|
null); |
201 |
1 |
sf.setValue("id", geneId); |
202 |
1 |
assertFalse(testee.retainFeature(sf, geneId)); |
203 |
|
|
204 |
1 |
sf = new SequenceFeature("transcript", "", 20000, 20500, 0f, null); |
205 |
1 |
sf.setValue("Parent", geneId); |
206 |
1 |
assertTrue(testee.retainFeature(sf, geneId)); |
207 |
|
|
208 |
1 |
sf = new SequenceFeature("mature_transcript", "", 20000, 20500, 0f, |
209 |
|
null); |
210 |
1 |
sf.setValue("Parent", geneId); |
211 |
1 |
assertTrue(testee.retainFeature(sf, geneId)); |
212 |
|
|
213 |
1 |
sf = new SequenceFeature("NMD_transcript_variant", "", 20000, 20500, 0f, |
214 |
|
null); |
215 |
1 |
sf.setValue("Parent", geneId); |
216 |
1 |
assertTrue(testee.retainFeature(sf, geneId)); |
217 |
|
|
218 |
1 |
sf.setValue("Parent", "ßXYZ"); |
219 |
1 |
assertFalse(testee.retainFeature(sf, geneId)); |
220 |
|
|
221 |
1 |
sf = new SequenceFeature("anything", "", 20000, 20500, 0f, null); |
222 |
1 |
assertTrue(testee.retainFeature(sf, geneId)); |
223 |
|
} |
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
229 |
1 |
@Test(groups = "Functional")... |
230 |
|
public void testGetIdentifyingFeatures() |
231 |
|
{ |
232 |
1 |
String accId = "ABC123"; |
233 |
1 |
SequenceI seq = new Sequence(accId, "HIBEES"); |
234 |
|
|
235 |
|
|
236 |
1 |
SequenceFeature sf1 = new SequenceFeature("gene", "", 1, 2, 0f, null); |
237 |
1 |
seq.addSequenceFeature(sf1); |
238 |
|
|
239 |
|
|
240 |
1 |
SequenceFeature sf2 = new SequenceFeature("gene", "a", 1, 2, 0f, null); |
241 |
1 |
sf2.setValue("id", "XYZ"); |
242 |
1 |
seq.addSequenceFeature(sf2); |
243 |
|
|
244 |
|
|
245 |
1 |
SequenceFeature sf3 = new SequenceFeature("gene", "b", 1, 2, 0f, null); |
246 |
1 |
sf3.setValue("id", accId); |
247 |
1 |
seq.addSequenceFeature(sf3); |
248 |
|
|
249 |
|
|
250 |
1 |
SequenceFeature sf4 = new SequenceFeature("snRNA_gene", "", 1, 2, 0f, |
251 |
|
null); |
252 |
1 |
sf4.setValue("id", accId); |
253 |
1 |
seq.addSequenceFeature(sf4); |
254 |
|
|
255 |
|
|
256 |
1 |
SequenceFeature sf5 = new SequenceFeature("transcript", "", 1, 2, 0f, |
257 |
|
null); |
258 |
1 |
sf5.setValue("id", accId); |
259 |
1 |
seq.addSequenceFeature(sf5); |
260 |
|
|
261 |
|
|
262 |
1 |
SequenceFeature sf6 = new SequenceFeature("exon", "", 1, 2, 0f, null); |
263 |
1 |
sf6.setValue("id", accId); |
264 |
1 |
seq.addSequenceFeature(sf6); |
265 |
|
|
266 |
1 |
List<SequenceFeature> sfs = new EnsemblGene() |
267 |
|
.getIdentifyingFeatures(seq, accId); |
268 |
1 |
assertFalse(sfs.contains(sf1)); |
269 |
1 |
assertFalse(sfs.contains(sf2)); |
270 |
1 |
assertTrue(sfs.contains(sf3)); |
271 |
1 |
assertTrue(sfs.contains(sf4)); |
272 |
1 |
assertFalse(sfs.contains(sf5)); |
273 |
1 |
assertFalse(sfs.contains(sf6)); |
274 |
|
} |
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
279 |
|
|
280 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
281 |
1 |
@Test(groups = "Functional")... |
282 |
|
public void testGetFeatureColourScheme() |
283 |
|
{ |
284 |
1 |
FeatureSettingsModelI fc = new EnsemblGene().getFeatureColourScheme(); |
285 |
1 |
assertFalse(fc.isFeatureDisplayed("exon")); |
286 |
1 |
assertFalse(fc.isFeatureHidden("exon")); |
287 |
1 |
assertFalse(fc.isFeatureDisplayed("coding_exon")); |
288 |
1 |
assertFalse(fc.isFeatureHidden("coding_exon")); |
289 |
1 |
assertFalse(fc.isFeatureDisplayed("sequence_variant")); |
290 |
1 |
assertFalse(fc.isFeatureHidden("sequence_variant")); |
291 |
1 |
assertFalse(fc.isFeatureDisplayed("feature_variant")); |
292 |
1 |
assertFalse(fc.isFeatureHidden("feature_variant")); |
293 |
1 |
assertTrue(fc.isFeatureHidden("transcript")); |
294 |
1 |
assertTrue(fc.isFeatureHidden("CDS")); |
295 |
|
|
296 |
1 |
assertEquals(Color.RED, |
297 |
|
fc.getFeatureColour("sequence_variant").getColour()); |
298 |
1 |
assertEquals(Color.RED, |
299 |
|
fc.getFeatureColour("feature_variant").getColour()); |
300 |
1 |
assertTrue(fc.getFeatureColour("exon").isColourByLabel()); |
301 |
1 |
assertTrue(fc.getFeatureColour("coding_exon").isColourByLabel()); |
302 |
1 |
assertEquals(1, fc.compare("sequence_variant", "exon")); |
303 |
1 |
assertEquals(-1, fc.compare("exon", "sequence_variant")); |
304 |
1 |
assertEquals(1, fc.compare("feature_variant", "coding_exon")); |
305 |
1 |
assertEquals(-1, fc.compare("coding_exon", "feature_variant")); |
306 |
1 |
assertEquals(1f, fc.getTransparency()); |
307 |
|
} |
308 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
309 |
0 |
@Test(groups = "Network")... |
310 |
|
public void testGetGeneIds() |
311 |
|
{ |
312 |
|
|
313 |
|
|
314 |
|
|
315 |
|
|
316 |
|
|
317 |
|
|
318 |
|
|
319 |
0 |
String ids = "ENSG00000158828 ENST00000321556 P30419 ENST00000592782 BRAF"; |
320 |
0 |
EnsemblGene testee = new EnsemblGene(); |
321 |
0 |
List<String> geneIds = testee.getGeneIds(ids); |
322 |
0 |
assertTrue(geneIds.contains("ENSG00000158828")); |
323 |
0 |
assertTrue(geneIds.contains("ENSG00000136448")); |
324 |
0 |
assertTrue(geneIds.contains("ENSG00000157764")); |
325 |
0 |
assertTrue(geneIds.contains("ENSMUSG00000002413")); |
326 |
0 |
assertTrue(geneIds.contains("ENSRNOG00000010957")); |
327 |
0 |
assertTrue(geneIds.contains("ENSXETG00000004845")); |
328 |
0 |
assertTrue(geneIds.contains("ENSDARG00000017661")); |
329 |
|
|
330 |
|
|
331 |
0 |
assertTrue(geneIds.contains("ENSGALG00010013466")); |
332 |
|
|
333 |
0 |
assertEquals(8, geneIds.size()); |
334 |
|
|
335 |
|
} |
336 |
|
} |