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 static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertFalse; |
25 |
|
import static org.testng.AssertJUnit.assertTrue; |
26 |
|
|
27 |
|
import jalview.datamodel.Sequence; |
28 |
|
import jalview.datamodel.SequenceDummy; |
29 |
|
import jalview.datamodel.SequenceFeature; |
30 |
|
import jalview.datamodel.SequenceI; |
31 |
|
import jalview.gui.JvOptionPane; |
32 |
|
import jalview.io.gff.SequenceOntologyFactory; |
33 |
|
import jalview.io.gff.SequenceOntologyLite; |
34 |
|
import jalview.util.MapList; |
35 |
|
|
36 |
|
import java.util.List; |
37 |
|
|
38 |
|
import org.testng.Assert; |
39 |
|
import org.testng.annotations.AfterClass; |
40 |
|
import org.testng.annotations.BeforeClass; |
41 |
|
import org.testng.annotations.Test; |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (87) |
Complexity: 7 |
Complexity Density: 0.09 |
|
43 |
|
public class EnsemblCdsTest |
44 |
|
{ |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
46 |
1 |
@BeforeClass(alwaysRun = true)... |
47 |
|
public void setUpJvOptionPane() |
48 |
|
{ |
49 |
1 |
JvOptionPane.setInteractiveMode(false); |
50 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
51 |
|
} |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
53 |
1 |
@BeforeClass(alwaysRun = true)... |
54 |
|
public void setUp() |
55 |
|
{ |
56 |
1 |
SequenceOntologyFactory.setInstance(new SequenceOntologyLite()); |
57 |
|
} |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
1 |
@AfterClass(alwaysRun = true)... |
60 |
|
public void tearDown() |
61 |
|
{ |
62 |
1 |
SequenceOntologyFactory.setInstance(null); |
63 |
|
} |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
69 |
1 |
@Test(groups = "Functional")... |
70 |
|
public void testGetGenomicRangesFromFeatures() |
71 |
|
{ |
72 |
1 |
EnsemblCds testee = new EnsemblCds(); |
73 |
1 |
SequenceI genomic = new SequenceDummy("chr7"); |
74 |
1 |
genomic.setStart(10000); |
75 |
1 |
genomic.setEnd(50000); |
76 |
1 |
String transcriptId = "ABC123"; |
77 |
|
|
78 |
|
|
79 |
1 |
SequenceFeature sf = new SequenceFeature("CDS", "", 20000, 20500, 0f, |
80 |
|
null); |
81 |
1 |
sf.setValue("Parent", transcriptId); |
82 |
1 |
sf.setStrand("+"); |
83 |
1 |
genomic.addSequenceFeature(sf); |
84 |
|
|
85 |
|
|
86 |
1 |
sf = new SequenceFeature("CDS_predicted", "", 10500, 10600, 0f, null); |
87 |
1 |
sf.setValue("Parent", transcriptId); |
88 |
1 |
sf.setStrand("+"); |
89 |
1 |
genomic.addSequenceFeature(sf); |
90 |
|
|
91 |
|
|
92 |
1 |
sf = new SequenceFeature("CDS", "", 11500, 12600, 0f, null); |
93 |
1 |
sf.setValue("Parent", "anotherOne"); |
94 |
1 |
genomic.addSequenceFeature(sf); |
95 |
|
|
96 |
|
|
97 |
1 |
sf = new SequenceFeature("exon", "", 10000, 50000, 0f, null); |
98 |
1 |
genomic.addSequenceFeature(sf); |
99 |
|
|
100 |
|
|
101 |
1 |
sf = new SequenceFeature("mRNA_region", "", 10000, 50000, 0f, null); |
102 |
1 |
genomic.addSequenceFeature(sf); |
103 |
|
|
104 |
1 |
MapList ranges = testee.getGenomicRangesFromFeatures(genomic, |
105 |
|
transcriptId, 23); |
106 |
1 |
List<int[]> fromRanges = ranges.getFromRanges(); |
107 |
1 |
assertEquals(2, fromRanges.size()); |
108 |
|
|
109 |
1 |
assertEquals(10500, fromRanges.get(0)[0]); |
110 |
1 |
assertEquals(10600, fromRanges.get(0)[1]); |
111 |
1 |
assertEquals(20000, fromRanges.get(1)[0]); |
112 |
1 |
assertEquals(20500, fromRanges.get(1)[1]); |
113 |
|
|
114 |
1 |
List<int[]> toRanges = ranges.getToRanges(); |
115 |
1 |
assertEquals(1, toRanges.size()); |
116 |
1 |
assertEquals(23, toRanges.get(0)[0]); |
117 |
1 |
assertEquals(624, toRanges.get(0)[1]); |
118 |
|
} |
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
124 |
1 |
@Test(groups = "Functional")... |
125 |
|
public void testRetainFeature() |
126 |
|
{ |
127 |
1 |
String accId = "ABC123"; |
128 |
1 |
EnsemblCds testee = new EnsemblCds(); |
129 |
|
|
130 |
1 |
SequenceFeature sf = new SequenceFeature("CDS", "", 20000, 20500, 0f, |
131 |
|
null); |
132 |
1 |
assertFalse(testee.retainFeature(sf, accId)); |
133 |
|
|
134 |
1 |
sf = new SequenceFeature("CDS_predicted", "", 20000, 20500, 0f, null); |
135 |
1 |
assertFalse(testee.retainFeature(sf, accId)); |
136 |
|
|
137 |
|
|
138 |
1 |
sf = new SequenceFeature("anotherType", "", 20000, 20500, 0f, null); |
139 |
1 |
assertTrue(testee.retainFeature(sf, accId)); |
140 |
|
|
141 |
|
|
142 |
1 |
sf.setValue("Parent", accId); |
143 |
1 |
assertTrue(testee.retainFeature(sf, accId)); |
144 |
|
|
145 |
|
|
146 |
1 |
sf.setValue("Parent", "XYZ"); |
147 |
1 |
assertFalse(testee.retainFeature(sf, accId)); |
148 |
|
} |
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
154 |
1 |
@Test(groups = "Functional")... |
155 |
|
public void testGetIdentifyingFeatures() |
156 |
|
{ |
157 |
1 |
String accId = "ABC123"; |
158 |
1 |
SequenceI seq = new Sequence(accId, "MKDONS"); |
159 |
|
|
160 |
|
|
161 |
1 |
SequenceFeature sf1 = new SequenceFeature("CDS", "", 1, 2, 0f, null); |
162 |
1 |
seq.addSequenceFeature(sf1); |
163 |
|
|
164 |
|
|
165 |
1 |
SequenceFeature sf2 = new SequenceFeature("CDS", "", 1, 2, 0f, null); |
166 |
1 |
sf2.setValue("Parent", "XYZ"); |
167 |
1 |
seq.addSequenceFeature(sf2); |
168 |
|
|
169 |
|
|
170 |
1 |
SequenceFeature sf3 = new SequenceFeature("CDS", "", 1, 2, 0f, null); |
171 |
1 |
sf3.setValue("Parent", accId); |
172 |
1 |
seq.addSequenceFeature(sf3); |
173 |
|
|
174 |
|
|
175 |
1 |
SequenceFeature sf4 = new SequenceFeature("CDS_predicted", "", 1, 2, 0f, |
176 |
|
null); |
177 |
1 |
sf4.setValue("Parent", accId); |
178 |
1 |
seq.addSequenceFeature(sf4); |
179 |
|
|
180 |
|
|
181 |
1 |
SequenceFeature sf5 = new SequenceFeature("transcript", "", 1, 2, 0f, |
182 |
|
null); |
183 |
1 |
sf5.setValue("Parent", accId); |
184 |
1 |
seq.addSequenceFeature(sf5); |
185 |
|
|
186 |
|
|
187 |
1 |
SequenceFeature sf6 = new SequenceFeature("exon", "", 1, 2, 0f, null); |
188 |
1 |
sf6.setValue("Parent", accId); |
189 |
1 |
seq.addSequenceFeature(sf6); |
190 |
|
|
191 |
1 |
List<SequenceFeature> sfs = new EnsemblCds().getIdentifyingFeatures(seq, |
192 |
|
accId); |
193 |
1 |
assertFalse(sfs.contains(sf1)); |
194 |
1 |
assertFalse(sfs.contains(sf2)); |
195 |
1 |
assertTrue(sfs.contains(sf3)); |
196 |
1 |
assertTrue(sfs.contains(sf4)); |
197 |
1 |
assertFalse(sfs.contains(sf5)); |
198 |
1 |
assertFalse(sfs.contains(sf6)); |
199 |
|
} |
200 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
201 |
1 |
@Test(groups = "Functional")... |
202 |
|
public void testIsValidReference() throws Exception |
203 |
|
{ |
204 |
1 |
EnsemblSequenceFetcher esq = new EnsemblCds(); |
205 |
1 |
Assert.assertTrue(esq.isValidReference("CCDS5863.1")); |
206 |
1 |
Assert.assertTrue(esq.isValidReference("ENST00000288602")); |
207 |
1 |
Assert.assertTrue(esq.isValidReference("ENSG00000288602")); |
208 |
1 |
Assert.assertTrue(esq.isValidReference("ENSP00000288602")); |
209 |
1 |
Assert.assertFalse(esq.isValidReference("ENST0000288602")); |
210 |
|
|
211 |
1 |
Assert.assertTrue(esq.isValidReference("ENSMUSG00000099398")); |
212 |
|
} |
213 |
|
|
214 |
|
} |