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.annotations.AfterClass; |
39 |
|
import org.testng.annotations.BeforeClass; |
40 |
|
import org.testng.annotations.Test; |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (89) |
Complexity: 6 |
Complexity Density: 0.07 |
|
42 |
|
public class EnsemblGenomeTest |
43 |
|
{ |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
45 |
1 |
@BeforeClass(alwaysRun = true)... |
46 |
|
public void setUpJvOptionPane() |
47 |
|
{ |
48 |
1 |
JvOptionPane.setInteractiveMode(false); |
49 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
50 |
|
} |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
52 |
1 |
@BeforeClass(alwaysRun = true)... |
53 |
|
public void setUp() |
54 |
|
{ |
55 |
1 |
SequenceOntologyFactory.setInstance(new SequenceOntologyLite()); |
56 |
|
} |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
58 |
1 |
@AfterClass(alwaysRun = true)... |
59 |
|
public void tearDown() |
60 |
|
{ |
61 |
1 |
SequenceOntologyFactory.setInstance(null); |
62 |
|
} |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (35) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
68 |
1 |
@Test(groups = "Functional")... |
69 |
|
public void testGetGenomicRangesFromFeatures() |
70 |
|
{ |
71 |
1 |
EnsemblGenome testee = new EnsemblGenome(); |
72 |
1 |
SequenceI genomic = new SequenceDummy("chr7"); |
73 |
1 |
genomic.setStart(10000); |
74 |
1 |
genomic.setEnd(50000); |
75 |
1 |
String transcriptId = "ABC123"; |
76 |
|
|
77 |
|
|
78 |
1 |
SequenceFeature sf = new SequenceFeature("transcript", "", 20000, 20500, |
79 |
|
0f, null); |
80 |
1 |
sf.setValue("id", transcriptId); |
81 |
1 |
sf.setStrand("+"); |
82 |
1 |
genomic.addSequenceFeature(sf); |
83 |
|
|
84 |
|
|
85 |
1 |
sf = new SequenceFeature("ncRNA", "", 10500, 10600, 0f, null); |
86 |
1 |
sf.setValue("id", transcriptId); |
87 |
1 |
sf.setStrand("+"); |
88 |
1 |
genomic.addSequenceFeature(sf); |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
1 |
sf = new SequenceFeature("NMD_transcript_variant", "", 11000, 12000, 0f, |
93 |
|
null); |
94 |
1 |
sf.setValue("id", transcriptId); |
95 |
1 |
sf.setStrand("+"); |
96 |
1 |
genomic.addSequenceFeature(sf); |
97 |
|
|
98 |
|
|
99 |
1 |
sf = new SequenceFeature("transcript", "", 11500, 12600, 0f, null); |
100 |
1 |
sf.setValue("id", "anotherOne"); |
101 |
1 |
genomic.addSequenceFeature(sf); |
102 |
|
|
103 |
|
|
104 |
1 |
sf = new SequenceFeature("gene_member_region", "", 10000, 50000, 0f, |
105 |
|
null); |
106 |
1 |
genomic.addSequenceFeature(sf); |
107 |
|
|
108 |
1 |
MapList ranges = testee.getGenomicRangesFromFeatures(genomic, |
109 |
|
transcriptId, 23); |
110 |
1 |
List<int[]> fromRanges = ranges.getFromRanges(); |
111 |
1 |
assertEquals(3, fromRanges.size()); |
112 |
|
|
113 |
1 |
assertEquals(10500, fromRanges.get(0)[0]); |
114 |
1 |
assertEquals(10600, fromRanges.get(0)[1]); |
115 |
1 |
assertEquals(11000, fromRanges.get(1)[0]); |
116 |
1 |
assertEquals(12000, fromRanges.get(1)[1]); |
117 |
1 |
assertEquals(20000, fromRanges.get(2)[0]); |
118 |
1 |
assertEquals(20500, fromRanges.get(2)[1]); |
119 |
|
|
120 |
1 |
List<int[]> toRanges = ranges.getToRanges(); |
121 |
1 |
assertEquals(1, toRanges.size()); |
122 |
1 |
assertEquals(23, toRanges.get(0)[0]); |
123 |
1 |
assertEquals(1625, toRanges.get(0)[1]); |
124 |
|
} |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
130 |
1 |
@Test(groups = "Functional")... |
131 |
|
public void testRetainFeature() |
132 |
|
{ |
133 |
1 |
String accId = "ABC123"; |
134 |
1 |
EnsemblGenome testee = new EnsemblGenome(); |
135 |
|
|
136 |
1 |
SequenceFeature sf = new SequenceFeature("transcript", "", 20000, 20500, |
137 |
|
0f, null); |
138 |
1 |
assertFalse(testee.retainFeature(sf, accId)); |
139 |
|
|
140 |
1 |
sf = new SequenceFeature("mature_transcript", "", 20000, 20500, 0f, |
141 |
|
null); |
142 |
1 |
assertFalse(testee.retainFeature(sf, accId)); |
143 |
|
|
144 |
1 |
sf = new SequenceFeature("NMD_transcript_variant", "", 20000, 20500, 0f, |
145 |
|
null); |
146 |
1 |
assertFalse(testee.retainFeature(sf, accId)); |
147 |
|
|
148 |
|
|
149 |
1 |
sf = new SequenceFeature("anything", "", 20000, 20500, 0f, null); |
150 |
1 |
assertTrue(testee.retainFeature(sf, accId)); |
151 |
|
|
152 |
|
|
153 |
1 |
sf.setValue("Parent", accId); |
154 |
1 |
assertTrue(testee.retainFeature(sf, accId)); |
155 |
|
|
156 |
|
|
157 |
1 |
sf.setValue("Parent", "XYZ"); |
158 |
1 |
assertFalse(testee.retainFeature(sf, accId)); |
159 |
|
} |
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (30) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
165 |
1 |
@Test(groups = "Functional")... |
166 |
|
public void testGetIdentifyingFeatures() |
167 |
|
{ |
168 |
1 |
String accId = "ABC123"; |
169 |
1 |
SequenceI seq = new Sequence(accId, "HEARTS"); |
170 |
|
|
171 |
|
|
172 |
1 |
SequenceFeature sf1 = new SequenceFeature("transcript", "", 1, 2, 0f, |
173 |
|
null); |
174 |
1 |
seq.addSequenceFeature(sf1); |
175 |
|
|
176 |
|
|
177 |
|
|
178 |
1 |
SequenceFeature sf2 = new SequenceFeature("transcript", "a", 1, 2, 0f, |
179 |
|
null); |
180 |
1 |
sf2.setValue("id", "transcript"); |
181 |
1 |
seq.addSequenceFeature(sf2); |
182 |
|
|
183 |
|
|
184 |
1 |
SequenceFeature sf3 = new SequenceFeature("transcript", "b", 1, 2, 0f, |
185 |
|
null); |
186 |
1 |
sf3.setValue("id", accId); |
187 |
1 |
seq.addSequenceFeature(sf3); |
188 |
|
|
189 |
|
|
190 |
1 |
SequenceFeature sf4 = new SequenceFeature("ncRNA", "", 1, 2, 0f, null); |
191 |
1 |
sf4.setValue("id", accId); |
192 |
1 |
seq.addSequenceFeature(sf4); |
193 |
|
|
194 |
|
|
195 |
1 |
SequenceFeature sf5 = new SequenceFeature("NMD_transcript_variant", "", |
196 |
|
1, 2, 0f, null); |
197 |
1 |
sf5.setValue("id", accId); |
198 |
1 |
seq.addSequenceFeature(sf5); |
199 |
|
|
200 |
|
|
201 |
1 |
SequenceFeature sf6 = new SequenceFeature("gene", "", 1, 2, 0f, null); |
202 |
1 |
sf6.setValue("id", accId); |
203 |
1 |
seq.addSequenceFeature(sf6); |
204 |
|
|
205 |
|
|
206 |
1 |
SequenceFeature sf7 = new SequenceFeature("exon", "", 1, 2, 0f, null); |
207 |
1 |
sf7.setValue("id", accId); |
208 |
1 |
seq.addSequenceFeature(sf7); |
209 |
|
|
210 |
1 |
List<SequenceFeature> sfs = new EnsemblGenome() |
211 |
|
.getIdentifyingFeatures(seq, accId); |
212 |
1 |
assertFalse(sfs.contains(sf1)); |
213 |
1 |
assertFalse(sfs.contains(sf2)); |
214 |
1 |
assertTrue(sfs.contains(sf3)); |
215 |
1 |
assertTrue(sfs.contains(sf4)); |
216 |
1 |
assertTrue(sfs.contains(sf5)); |
217 |
1 |
assertFalse(sfs.contains(sf6)); |
218 |
1 |
assertFalse(sfs.contains(sf7)); |
219 |
|
} |
220 |
|
|
221 |
|
} |