1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.analysis; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertFalse; |
25 |
|
import static org.testng.AssertJUnit.assertNotNull; |
26 |
|
import static org.testng.AssertJUnit.assertNotSame; |
27 |
|
import static org.testng.AssertJUnit.assertNull; |
28 |
|
import static org.testng.AssertJUnit.assertSame; |
29 |
|
import static org.testng.AssertJUnit.assertTrue; |
30 |
|
|
31 |
|
import java.util.ArrayList; |
32 |
|
import java.util.Arrays; |
33 |
|
import java.util.List; |
34 |
|
|
35 |
|
import org.testng.annotations.AfterClass; |
36 |
|
import org.testng.annotations.BeforeClass; |
37 |
|
import org.testng.annotations.BeforeMethod; |
38 |
|
import org.testng.annotations.Test; |
39 |
|
|
40 |
|
import jalview.bin.Cache; |
41 |
|
import jalview.datamodel.AlignedCodonFrame; |
42 |
|
import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping; |
43 |
|
import jalview.datamodel.Alignment; |
44 |
|
import jalview.datamodel.AlignmentI; |
45 |
|
import jalview.datamodel.DBRefEntry; |
46 |
|
import jalview.datamodel.Mapping; |
47 |
|
import jalview.datamodel.Sequence; |
48 |
|
import jalview.datamodel.SequenceFeature; |
49 |
|
import jalview.datamodel.SequenceI; |
50 |
|
import jalview.gui.JvOptionPane; |
51 |
|
import jalview.util.DBRefUtils; |
52 |
|
import jalview.util.MapList; |
53 |
|
import jalview.ws.SequenceFetcher; |
54 |
|
import jalview.ws.SequenceFetcherFactory; |
55 |
|
|
|
|
| 57.5% |
Uncovered Elements: 127 (299) |
Complexity: 22 |
Complexity Density: 0.08 |
|
56 |
|
public class CrossRefTest |
57 |
|
{ |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
59 |
1 |
@BeforeClass(alwaysRun = true)... |
60 |
|
public void setUpJvOptionPane() |
61 |
|
{ |
62 |
1 |
JvOptionPane.setInteractiveMode(false); |
63 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
64 |
|
} |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
8 |
@BeforeMethod(alwaysRun = true)... |
67 |
|
public void loadProperties() |
68 |
|
{ |
69 |
8 |
Cache.loadProperties("test/jalview/util/comparisonTestProps.jvprops"); |
70 |
|
} |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
72 |
1 |
@Test(groups = { "Functional" })... |
73 |
|
public void testFindXDbRefs() |
74 |
|
{ |
75 |
1 |
DBRefEntry ref1 = new DBRefEntry("UNIPROT", "1", "A123"); |
76 |
1 |
DBRefEntry ref2 = new DBRefEntry("UNIPROTKB/TREMBL", "1", "A123"); |
77 |
1 |
DBRefEntry ref3 = new DBRefEntry("pdb", "1", "A123"); |
78 |
1 |
DBRefEntry ref4 = new DBRefEntry("EMBLCDSPROTEIN", "1", "A123"); |
79 |
1 |
DBRefEntry ref5 = new DBRefEntry("embl", "1", "A123"); |
80 |
1 |
DBRefEntry ref6 = new DBRefEntry("emblCDS", "1", "A123"); |
81 |
1 |
DBRefEntry ref7 = new DBRefEntry("GeneDB", "1", "A123"); |
82 |
1 |
DBRefEntry ref8 = new DBRefEntry("PFAM", "1", "A123"); |
83 |
|
|
84 |
1 |
DBRefEntry ref9 = new DBRefEntry("ENSEMBL", "1", "A123"); |
85 |
1 |
List<DBRefEntry> refs = Arrays |
86 |
|
.asList(new DBRefEntry[] |
87 |
|
{ ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9 }); |
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
1 |
List<DBRefEntry> found = DBRefUtils.selectDbRefs(true, refs); |
93 |
1 |
assertEquals(4, found.size()); |
94 |
1 |
assertSame(ref5, found.get(0)); |
95 |
1 |
assertSame(ref6, found.get(1)); |
96 |
1 |
assertSame(ref7, found.get(2)); |
97 |
1 |
assertSame(ref9, found.get(3)); |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
1 |
found = DBRefUtils.selectDbRefs(false, refs); |
103 |
1 |
assertEquals(4, found.size()); |
104 |
1 |
assertSame(ref1, found.get(0)); |
105 |
1 |
assertSame(ref2, found.get(1)); |
106 |
1 |
assertSame(ref4, found.get(2)); |
107 |
1 |
assertSame(ref9, found.get(3)); |
108 |
|
} |
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (27) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
115 |
1 |
@Test(groups = { "Functional" }, enabled = true)... |
116 |
|
public void testFindXrefSourcesForSequence_proteinToDna() |
117 |
|
{ |
118 |
1 |
SequenceI seq = new Sequence("Seq1", "MGKYQARLSS"); |
119 |
1 |
List<String> sources = new ArrayList<>(); |
120 |
1 |
AlignmentI al = new Alignment(new SequenceI[] {}); |
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
1 |
sources = new CrossRef(new SequenceI[] { seq }, al) |
126 |
|
.findXrefSourcesForSequences(false); |
127 |
1 |
assertTrue(sources.isEmpty()); |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
1 |
seq.addDBRef(new DBRefEntry("UNIPROT", "0", "A1234")); |
134 |
|
|
135 |
1 |
seq.addDBRef(new DBRefEntry("EMBL", "0", "E2345")); |
136 |
|
|
137 |
1 |
seq.addDBRef(new DBRefEntry("EMBL", "0", "E2346")); |
138 |
1 |
seq.addDBRef(new DBRefEntry("EMBLCDS", "0", "E2347")); |
139 |
1 |
seq.addDBRef(new DBRefEntry("GENEDB", "0", "E2348")); |
140 |
1 |
seq.addDBRef(new DBRefEntry("ENSEMBL", "0", "E2349")); |
141 |
1 |
seq.addDBRef(new DBRefEntry("ENSEMBLGENOMES", "0", "E2350")); |
142 |
1 |
sources = new CrossRef(new SequenceI[] { seq }, al) |
143 |
|
.findXrefSourcesForSequences(false); |
144 |
|
|
145 |
1 |
assertEquals(4, sources.size()); |
146 |
1 |
assertEquals("[EMBLCDS, GENEDB, ENSEMBL, ENSEMBLGENOMES]", |
147 |
|
sources.toString()); |
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
1 |
sources.clear(); |
154 |
1 |
seq.setDBRefs(null); |
155 |
1 |
seq.addDBRef(new DBRefEntry("UNIPROT", "0", "A1234")); |
156 |
1 |
seq.addDBRef(new DBRefEntry("EMBLCDS", "0", "E2347")); |
157 |
1 |
SequenceI seq2 = new Sequence("Seq2", "MGKYQARLSS"); |
158 |
1 |
seq2.addDBRef(new DBRefEntry("UNIPROT", "0", "A1234")); |
159 |
1 |
seq2.addDBRef(new DBRefEntry("EMBL", "0", "E2345")); |
160 |
1 |
seq2.addDBRef(new DBRefEntry("GENEDB", "0", "E2348")); |
161 |
|
|
162 |
1 |
al.addSequence(seq2); |
163 |
1 |
sources = new CrossRef(new SequenceI[] { seq, seq2 }, al) |
164 |
|
.findXrefSourcesForSequences(false); |
165 |
|
|
166 |
1 |
assertEquals(2, sources.size()); |
167 |
1 |
assertEquals("[EMBLCDS, GENEDB]", sources.toString()); |
168 |
|
} |
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
175 |
1 |
@Test(groups = { "Functional" }, enabled = true)... |
176 |
|
public void testFindXrefSequences_indirectDbrefToProtein() |
177 |
|
{ |
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
|
183 |
1 |
SequenceI emblSeq = new Sequence("AF039662", "GGGGCAGCACAAGAAC"); |
184 |
1 |
emblSeq.addDBRef(new DBRefEntry("EMBL", "0", "AF039662")); |
185 |
1 |
SequenceI uniprotSeq = new Sequence("Q9ZTS2", "MASVSATMISTS"); |
186 |
1 |
uniprotSeq.addDBRef(new DBRefEntry("EMBL", "0", "AF039662")); |
187 |
1 |
uniprotSeq.addDBRef(new DBRefEntry("UNIPROT", "0", "Q9ZTS2")); |
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
|
194 |
1 |
AlignmentI al = new Alignment(new SequenceI[] { emblSeq, uniprotSeq }); |
195 |
1 |
Alignment xrefs = new CrossRef(new SequenceI[] { emblSeq }, al) |
196 |
|
.findXrefSequences("UNIPROT", true); |
197 |
1 |
System.err.println("xrefs=" + xrefs); |
198 |
1 |
assertEquals(1, xrefs.getHeight()); |
199 |
1 |
assertSame(uniprotSeq, xrefs.getSequenceAt(0)); |
200 |
|
} |
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
|
206 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
207 |
1 |
@Test(groups = { "Functional" }, enabled = true)... |
208 |
|
public void testFindXrefSequences_indirectDbrefToNucleotide() |
209 |
|
{ |
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
215 |
1 |
SequenceI uniprotSeq = new Sequence("Q9ZTS2", "MASVSATMISTS"); |
216 |
1 |
uniprotSeq.addDBRef(new DBRefEntry("UNIPROT", "0", "Q9ZTS2")); |
217 |
1 |
SequenceI emblSeq = new Sequence("AF039662", "GGGGCAGCACAAGAAC"); |
218 |
1 |
emblSeq.addDBRef(new DBRefEntry("EMBL", "0", "AF039662")); |
219 |
1 |
emblSeq.addDBRef(new DBRefEntry("UNIPROT", "0", "Q9ZTS2")); |
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
|
229 |
|
|
230 |
1 |
AlignmentI al = new Alignment(new SequenceI[] { emblSeq, uniprotSeq }); |
231 |
1 |
Alignment xrefs = new CrossRef(new SequenceI[] { uniprotSeq }, al) |
232 |
|
.findXrefSequences("EMBL", false); |
233 |
1 |
assertEquals(1, xrefs.getHeight()); |
234 |
1 |
assertSame(emblSeq, xrefs.getSequenceAt(0)); |
235 |
|
} |
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
242 |
1 |
@Test(groups = { "Functional" })... |
243 |
|
public void testFindXrefSequences_noDbrefs() |
244 |
|
{ |
245 |
|
|
246 |
|
|
247 |
|
|
248 |
1 |
SequenceI dna1 = new Sequence("AF039662", "GGGGCAGCACAAGAAC"); |
249 |
1 |
dna1.addDBRef(new DBRefEntry("UNIPROT", "0", "Q9ZTS2")); |
250 |
1 |
SequenceI dna2 = new Sequence("AJ307031", "AAACCCTTT"); |
251 |
|
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
1 |
AlignmentI al = new Alignment(new SequenceI[] { dna1, dna2 }); |
258 |
1 |
Alignment xrefs = new CrossRef(new SequenceI[] { dna2 }, al) |
259 |
|
.findXrefSequences("UNIPROT", true); |
260 |
1 |
assertNull(xrefs); |
261 |
|
} |
262 |
|
|
263 |
|
|
264 |
|
|
265 |
|
|
266 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (45) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
267 |
1 |
@Test(groups = { "Functional" }, enabled = true)... |
268 |
|
public void testSearchDataset() |
269 |
|
{ |
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
1 |
SequenceI dna1 = new Sequence("AF039662", "GGGGCAGCACAAGAAC"); |
275 |
1 |
Mapping map = new Mapping(new Sequence("pep2", "MLAVSRG"), |
276 |
|
new MapList(new int[] |
277 |
|
{ 1, 21 }, new int[] { 1, 7 }, 3, 1)); |
278 |
1 |
DBRefEntry dbref = new DBRefEntry("UNIPROT", "0", "Q9ZTS2", map); |
279 |
1 |
dna1.addDBRef(dbref); |
280 |
1 |
dna1.addDBRef(new DBRefEntry("EMBL", "0", "AF039662")); |
281 |
1 |
SequenceI pep1 = new Sequence("Q9ZTS2", "MLAVSRGQ"); |
282 |
1 |
dbref = new DBRefEntry("UNIPROT", "0", "Q9ZTS2"); |
283 |
1 |
pep1.addDBRef(new DBRefEntry("UNIPROT", "0", "Q9ZTS2")); |
284 |
1 |
AlignmentI al = new Alignment(new SequenceI[] { dna1, pep1 }); |
285 |
|
|
286 |
1 |
List<SequenceI> result = new ArrayList<>(); |
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
1 |
dbref = new DBRefEntry("UNIPROT", "0", "P30419"); |
292 |
1 |
CrossRef testee = new CrossRef(al.getSequencesArray(), al); |
293 |
1 |
AlignedCodonFrame acf = new AlignedCodonFrame(); |
294 |
1 |
boolean found = testee.searchDataset(true, dna1, dbref, result, acf, |
295 |
|
true, DBRefUtils.SEARCH_MODE_FULL); |
296 |
1 |
assertFalse(found); |
297 |
1 |
assertTrue(result.isEmpty()); |
298 |
1 |
assertTrue(acf.isEmpty()); |
299 |
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 |
1 |
acf = new AlignedCodonFrame(); |
304 |
1 |
dbref = new DBRefEntry("UNIPROT", "0", "Q9ZTS2"); |
305 |
1 |
found = testee.searchDataset(!dna1.isProtein(), dna1, dbref, result, |
306 |
|
acf, false, DBRefUtils.SEARCH_MODE_FULL); |
307 |
|
|
308 |
|
|
309 |
1 |
assertTrue(found); |
310 |
1 |
assertEquals(1, result.size()); |
311 |
1 |
assertSame(pep1, result.get(0)); |
312 |
1 |
assertTrue(acf.isEmpty()); |
313 |
|
|
314 |
|
|
315 |
|
|
316 |
|
|
317 |
1 |
result.clear(); |
318 |
1 |
acf = new AlignedCodonFrame(); |
319 |
1 |
dbref = new DBRefEntry("UNIPROT", "0", "Q9ZTS2"); |
320 |
1 |
found = testee.searchDataset(!pep1.isProtein(), pep1, dbref, result, |
321 |
|
acf, false, DBRefUtils.SEARCH_MODE_FULL); |
322 |
|
|
323 |
|
|
324 |
|
|
325 |
1 |
assertTrue(found); |
326 |
1 |
assertEquals(1, result.size()); |
327 |
1 |
assertSame(dna1, result.get(0)); |
328 |
|
|
329 |
1 |
List<SequenceToSequenceMapping> mappings = acf.getMappings(); |
330 |
1 |
assertEquals(1, mappings.size()); |
331 |
1 |
SequenceToSequenceMapping mapping = mappings.get(0); |
332 |
1 |
assertSame(dna1, mapping.getFromSeq()); |
333 |
1 |
assertSame(pep1, mapping.getMapping().getTo()); |
334 |
1 |
MapList mapList = mapping.getMapping().getMap(); |
335 |
1 |
assertEquals(1, mapList.getToRatio()); |
336 |
1 |
assertEquals(3, mapList.getFromRatio()); |
337 |
1 |
assertEquals(1, mapList.getFromRanges().size()); |
338 |
1 |
assertEquals(1, mapList.getFromRanges().get(0)[0]); |
339 |
1 |
assertEquals(21, mapList.getFromRanges().get(0)[1]); |
340 |
1 |
assertEquals(1, mapList.getToRanges().size()); |
341 |
1 |
assertEquals(1, mapList.getToRanges().get(0)[0]); |
342 |
1 |
assertEquals(7, mapList.getToRanges().get(0)[1]); |
343 |
|
} |
344 |
|
|
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
|
349 |
|
|
350 |
|
|
351 |
|
|
352 |
|
|
353 |
|
|
354 |
|
|
355 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
356 |
1 |
@Test(groups = { "Functional" })... |
357 |
|
public void testFindXrefSequences_fromDbRefMap() |
358 |
|
{ |
359 |
|
|
360 |
|
|
361 |
|
|
362 |
|
|
363 |
|
|
364 |
1 |
SequenceI dna1 = new Sequence("AF039662", "GGGGCAGCACAAGAAC"); |
365 |
1 |
SequenceI pep1 = new Sequence("Q9ZTS2", "MALFQRSV"); |
366 |
1 |
SequenceI pep2 = new Sequence("P30419", "MTRRSQIF"); |
367 |
1 |
dna1.createDatasetSequence(); |
368 |
1 |
pep1.createDatasetSequence(); |
369 |
1 |
pep2.createDatasetSequence(); |
370 |
|
|
371 |
1 |
pep1.getDatasetSequence() |
372 |
|
.addDBRef(new DBRefEntry("Pfam", "0", "PF00111")); |
373 |
1 |
pep1.addSequenceFeature( |
374 |
|
new SequenceFeature("type", "desc", 12, 14, 1f, "group")); |
375 |
1 |
pep2.getDatasetSequence().addDBRef(new DBRefEntry("PDB", "0", "3JTK")); |
376 |
1 |
pep2.addSequenceFeature( |
377 |
|
new SequenceFeature("type2", "desc2", 13, 15, 12f, "group2")); |
378 |
|
|
379 |
1 |
MapList mapList = new MapList(new int[] { 1, 24 }, new int[] { 1, 3 }, |
380 |
|
3, 1); |
381 |
1 |
Mapping map = new Mapping(pep1, mapList); |
382 |
1 |
DBRefEntry dbRef1 = new DBRefEntry("UNIPROT", "0", "Q9ZTS2", map); |
383 |
1 |
dna1.getDatasetSequence().addDBRef(dbRef1); |
384 |
1 |
mapList = new MapList(new int[] { 1, 24 }, new int[] { 1, 3 }, 3, 1); |
385 |
1 |
map = new Mapping(pep2, mapList); |
386 |
1 |
DBRefEntry dbRef2 = new DBRefEntry("UNIPROT", "0", "P30419", map); |
387 |
1 |
dna1.getDatasetSequence().addDBRef(dbRef2); |
388 |
|
|
389 |
|
|
390 |
|
|
391 |
|
|
392 |
|
|
393 |
1 |
AlignmentI al = new Alignment(new SequenceI[] { dna1 }); |
394 |
1 |
Alignment xrefs = new CrossRef(new SequenceI[] { dna1 }, al) |
395 |
|
.findXrefSequences("UNIPROT", true); |
396 |
1 |
assertEquals(2, xrefs.getHeight()); |
397 |
|
|
398 |
|
|
399 |
|
|
400 |
|
|
401 |
|
|
402 |
1 |
checkCopySequence(pep1, xrefs.getSequenceAt(0)); |
403 |
1 |
checkCopySequence(pep2, xrefs.getSequenceAt(1)); |
404 |
|
} |
405 |
|
|
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
@param |
412 |
|
@param |
413 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
414 |
2 |
private void checkCopySequence(SequenceI copy, SequenceI original)... |
415 |
|
{ |
416 |
2 |
assertNotSame(copy, original); |
417 |
2 |
assertSame(copy.getDatasetSequence(), original.getDatasetSequence()); |
418 |
2 |
assertEquals(copy.getName(), original.getName()); |
419 |
2 |
assertEquals(copy.getStart(), original.getStart()); |
420 |
2 |
assertEquals(copy.getEnd(), original.getEnd()); |
421 |
2 |
assertEquals(copy.getSequenceAsString(), |
422 |
|
original.getSequenceAsString()); |
423 |
|
} |
424 |
|
|
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
429 |
0 |
@Test(groups = { "Functional_Failing" })... |
430 |
|
public void testFindXrefSequences_withFetch() |
431 |
|
{ |
432 |
|
|
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
|
438 |
0 |
SequenceI dna1 = new Sequence("AF039662", "GGGGCAGCACAAGAAC"); |
439 |
0 |
dna1.addDBRef(new DBRefEntry("UNIPROT", "ENA:0", "Q9ZTS2")); |
440 |
0 |
dna1.addDBRef(new DBRefEntry("UNIPROT", "ENA:0", "P30419")); |
441 |
0 |
dna1.addDBRef(new DBRefEntry("UNIPROT", "ENA:0", "P00314")); |
442 |
0 |
final SequenceI pep1 = new Sequence("Q9ZTS2", "MYQLIRSSW"); |
443 |
0 |
pep1.addDBRef(new DBRefEntry("UNIPROT", "0", "Q9ZTS2", null, true)); |
444 |
|
|
445 |
0 |
final SequenceI pep2 = new Sequence("P00314", "MRKLLAASG"); |
446 |
0 |
pep2.addDBRef(new DBRefEntry("UNIPROT", "0", "P00314", null, true)); |
447 |
|
|
448 |
|
|
449 |
|
|
450 |
|
|
451 |
|
|
452 |
0 |
SequenceFetcher mockFetcher = new SequenceFetcher() |
453 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
454 |
0 |
@Override... |
455 |
|
public boolean isFetchable(String source) |
456 |
|
{ |
457 |
0 |
return true; |
458 |
|
} |
459 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
460 |
0 |
@Override... |
461 |
|
public SequenceI[] getSequences(List<DBRefEntry> refs, boolean dna) |
462 |
|
{ |
463 |
0 |
return new SequenceI[] { pep1, pep2 }; |
464 |
|
} |
465 |
|
}; |
466 |
0 |
SequenceFetcherFactory.setSequenceFetcher(mockFetcher); |
467 |
|
|
468 |
|
|
469 |
|
|
470 |
|
|
471 |
0 |
AlignmentI al = new Alignment(new SequenceI[] { dna1 }); |
472 |
0 |
Alignment xrefs = new CrossRef(new SequenceI[] { dna1 }, al) |
473 |
|
.findXrefSequences("UNIPROT", true); |
474 |
0 |
assertEquals(2, xrefs.getHeight()); |
475 |
0 |
assertSame(pep1, xrefs.getSequenceAt(0)); |
476 |
0 |
assertSame(pep2, xrefs.getSequenceAt(1)); |
477 |
|
} |
478 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
479 |
1 |
@AfterClass(alwaysRun = true)... |
480 |
|
public void tearDown() |
481 |
|
{ |
482 |
1 |
SequenceFetcherFactory.setSequenceFetcher(null); |
483 |
|
} |
484 |
|
|
485 |
|
|
486 |
|
|
487 |
|
|
488 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
489 |
0 |
@Test(groups = { "Functional_Failing" })... |
490 |
|
public void testFindXrefSequences_forGeneAndTranscripts() |
491 |
|
{ |
492 |
|
|
493 |
|
|
494 |
|
|
495 |
0 |
SequenceI gene = new Sequence("ENSG00000157764", "CGCCTCCCTTCCCC"); |
496 |
0 |
gene.addDBRef(new DBRefEntry("UNIPROT", "0", "P15056")); |
497 |
0 |
gene.addDBRef(new DBRefEntry("UNIPROT", "0", "H7C5K3")); |
498 |
|
|
499 |
|
|
500 |
|
|
501 |
|
|
502 |
0 |
SequenceI braf001 = new Sequence("ENST00000288602", |
503 |
|
"taagATGGCGGCGCTGa"); |
504 |
0 |
braf001.addDBRef(new DBRefEntry("UNIPROT", "0", "P15056")); |
505 |
0 |
braf001.addSequenceFeature( |
506 |
|
new SequenceFeature("CDS", "", 5, 16, 0f, null)); |
507 |
|
|
508 |
|
|
509 |
|
|
510 |
|
|
511 |
0 |
SequenceI braf002 = new Sequence("ENST00000497784", |
512 |
|
"gCAGGCtaTCTGTTCaa"); |
513 |
0 |
braf002.addDBRef(new DBRefEntry("UNIPROT", "ENSEMBL|0", "H7C5K3")); |
514 |
0 |
braf002.addSequenceFeature( |
515 |
|
new SequenceFeature("CDS", "", 2, 6, 0f, null)); |
516 |
0 |
braf002.addSequenceFeature( |
517 |
|
new SequenceFeature("CDS", "", 9, 15, 0f, null)); |
518 |
|
|
519 |
|
|
520 |
|
|
521 |
|
|
522 |
|
|
523 |
|
|
524 |
0 |
final SequenceI pep1 = new Sequence("UNIPROT|P15056", "MAAL"); |
525 |
0 |
pep1.addDBRef(new DBRefEntry("UNIPROT", "0", "P15056")); |
526 |
0 |
final SequenceI pep2 = new Sequence("UNIPROT|H7C5K3", "QALF"); |
527 |
0 |
pep2.addDBRef(new DBRefEntry("UNIPROT", "0", "H7C5K3")); |
528 |
|
|
529 |
|
|
530 |
|
|
531 |
|
|
532 |
0 |
SequenceFetcher mockFetcher = new SequenceFetcher() |
533 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
534 |
0 |
@Override... |
535 |
|
public boolean isFetchable(String source) |
536 |
|
{ |
537 |
0 |
return true; |
538 |
|
} |
539 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
540 |
0 |
@Override... |
541 |
|
public SequenceI[] getSequences(List<DBRefEntry> refs, boolean dna) |
542 |
|
{ |
543 |
0 |
return new SequenceI[] { pep1, pep2 }; |
544 |
|
} |
545 |
|
}; |
546 |
0 |
SequenceFetcherFactory.setSequenceFetcher(mockFetcher); |
547 |
|
|
548 |
|
|
549 |
|
|
550 |
|
|
551 |
|
|
552 |
|
|
553 |
|
|
554 |
|
|
555 |
0 |
SequenceI[] seqs = new SequenceI[] { gene, braf001, braf002 }; |
556 |
0 |
AlignmentI al = new Alignment(seqs); |
557 |
0 |
Alignment xrefs = new CrossRef(seqs, al).findXrefSequences("UNIPROT", |
558 |
|
true); |
559 |
0 |
assertEquals(2, xrefs.getHeight()); |
560 |
0 |
assertSame(pep1, xrefs.getSequenceAt(0)); |
561 |
0 |
assertSame(pep2, xrefs.getSequenceAt(1)); |
562 |
|
} |
563 |
|
|
564 |
|
|
565 |
|
|
566 |
|
|
567 |
|
|
568 |
|
|
569 |
|
|
570 |
|
|
571 |
|
|
572 |
|
|
573 |
|
|
574 |
|
|
575 |
|
|
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
|
581 |
|
|
582 |
|
|
583 |
|
|
584 |
|
|
585 |
|
|
586 |
|
|
587 |
|
|
|
|
| 0% |
Uncovered Elements: 68 (68) |
Complexity: 1 |
Complexity Density: 0.01 |
1PASS
|
|
588 |
0 |
@Test(groups = { "Functional_Failing" })... |
589 |
|
public void testFindXrefSequences_uniprotEmblManyToMany() |
590 |
|
{ |
591 |
|
|
592 |
|
|
593 |
|
|
594 |
|
|
595 |
0 |
SequenceI p0ce19 = new Sequence("UNIPROT|P0CE19", "KPFG"); |
596 |
0 |
p0ce19.addDBRef(new DBRefEntry("EMBL", "0", "J03321")); |
597 |
0 |
p0ce19.addDBRef(new DBRefEntry("EMBL", "0", "X06707")); |
598 |
0 |
p0ce19.addDBRef(new DBRefEntry("EMBL", "0", "M19487")); |
599 |
0 |
SequenceI p0ce20 = new Sequence("UNIPROT|P0CE20", "PFGK"); |
600 |
0 |
p0ce20.addDBRef(new DBRefEntry("EMBL", "0", "J03321")); |
601 |
0 |
p0ce20.addDBRef(new DBRefEntry("EMBL", "0", "X06707")); |
602 |
0 |
p0ce20.addDBRef(new DBRefEntry("EMBL", "0", "X07547")); |
603 |
|
|
604 |
|
|
605 |
|
|
606 |
|
|
607 |
|
|
608 |
|
|
609 |
|
|
610 |
|
|
611 |
|
|
612 |
|
|
613 |
|
|
614 |
0 |
final SequenceI j03321 = new Sequence("EMBL|J03321", |
615 |
|
"AAACCCTTTGGGAAAA"); |
616 |
0 |
DBRefEntry dbref1 = new DBRefEntry("UNIPROT", "0", "P0CE19"); |
617 |
0 |
MapList mapList = new MapList(new int[] { 1, 12 }, new int[] { 1, 4 }, |
618 |
|
3, 1); |
619 |
0 |
Mapping map = new Mapping(new Sequence("UNIPROT|P0CE19", "KPFG"), |
620 |
|
mapList); |
621 |
|
|
622 |
0 |
map.getTo().addDBRef(new DBRefEntry("PIR", "0", "S01875")); |
623 |
0 |
dbref1.setMap(map); |
624 |
0 |
j03321.addDBRef(dbref1); |
625 |
0 |
DBRefEntry dbref2 = new DBRefEntry("UNIPROT", "0", "P0CE20"); |
626 |
0 |
mapList = new MapList(new int[] { 4, 15 }, new int[] { 2, 5 }, 3, 1); |
627 |
0 |
dbref2.setMap(new Mapping(new Sequence("UNIPROT|P0CE20", "PFGK"), |
628 |
|
new MapList(mapList))); |
629 |
0 |
j03321.addDBRef(dbref2); |
630 |
|
|
631 |
|
|
632 |
|
|
633 |
|
|
634 |
0 |
final SequenceI x06707 = new Sequence("EMBL|X06707", "atgAAACCCTTTGGG"); |
635 |
0 |
DBRefEntry dbref3 = new DBRefEntry("UNIPROT", "0", "P0CE19"); |
636 |
0 |
MapList map2 = new MapList(new int[] { 4, 15 }, new int[] { 1, 4 }, 3, |
637 |
|
1); |
638 |
0 |
dbref3.setMap( |
639 |
|
new Mapping(new Sequence("UNIPROT|P0CE19", "KPFG"), map2)); |
640 |
0 |
x06707.addDBRef(dbref3); |
641 |
0 |
DBRefEntry dbref4 = new DBRefEntry("UNIPROT", "0", "P0CE20"); |
642 |
0 |
MapList map3 = new MapList(new int[] { 4, 15 }, new int[] { 1, 4 }, 3, |
643 |
|
1); |
644 |
0 |
dbref4.setMap( |
645 |
|
new Mapping(new Sequence("UNIPROT|P0CE20", "PFGK"), map3)); |
646 |
0 |
x06707.addDBRef(dbref4); |
647 |
|
|
648 |
|
|
649 |
|
|
650 |
|
|
651 |
0 |
final SequenceI m19487 = new Sequence("EMBL|M19487", "AAACCCTTTGGG"); |
652 |
0 |
DBRefEntry dbref5 = new DBRefEntry("UNIPROT", "0", "P0CE19"); |
653 |
0 |
dbref5.setMap(new Mapping(new Sequence("UNIPROT|P0CE19", "KPFG"), |
654 |
|
new MapList(mapList))); |
655 |
0 |
m19487.addDBRef(dbref5); |
656 |
0 |
DBRefEntry dbref6 = new DBRefEntry("UNIPROT", "0", "Q46432"); |
657 |
0 |
dbref6.setMap(new Mapping(new Sequence("UNIPROT|Q46432", "KPFG"), |
658 |
|
new MapList(mapList))); |
659 |
0 |
m19487.addDBRef(dbref6); |
660 |
|
|
661 |
|
|
662 |
|
|
663 |
|
|
664 |
0 |
final SequenceI x07547 = new Sequence("EMBL|X07547", "cccAAACCCTTTGGG"); |
665 |
0 |
DBRefEntry dbref7 = new DBRefEntry("UNIPROT", "0", "P0CE20"); |
666 |
0 |
dbref7.setMap(new Mapping(new Sequence("UNIPROT|P0CE20", "PFGK"), |
667 |
|
new MapList(map2))); |
668 |
0 |
x07547.addDBRef(dbref7); |
669 |
0 |
DBRefEntry dbref8 = new DBRefEntry("UNIPROT", "0", "B0BCM4"); |
670 |
0 |
dbref8.setMap(new Mapping(new Sequence("UNIPROT|B0BCM4", "KPFG"), |
671 |
|
new MapList(map2))); |
672 |
0 |
x07547.addDBRef(dbref8); |
673 |
|
|
674 |
|
|
675 |
|
|
676 |
|
|
677 |
|
|
678 |
|
|
679 |
|
|
680 |
|
|
681 |
0 |
SequenceFetcher mockFetcher = new SequenceFetcher() |
682 |
|
{ |
683 |
|
int call = 0; |
684 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
685 |
0 |
@Override... |
686 |
|
public boolean isFetchable(String source) |
687 |
|
{ |
688 |
0 |
return true; |
689 |
|
} |
690 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
691 |
0 |
@Override... |
692 |
|
public SequenceI[] getSequences(List<DBRefEntry> refs, boolean dna) |
693 |
|
{ |
694 |
0 |
call++; |
695 |
0 |
if (call == 1) |
696 |
|
{ |
697 |
0 |
assertEquals("Expected 3 embl seqs in first fetch", 3, |
698 |
|
refs.size()); |
699 |
0 |
return new SequenceI[] { j03321, x06707, m19487 }; |
700 |
|
} |
701 |
|
else |
702 |
|
{ |
703 |
0 |
assertEquals("Expected 1 embl seq in second fetch", 1, |
704 |
|
refs.size()); |
705 |
0 |
return new SequenceI[] { x07547 }; |
706 |
|
} |
707 |
|
} |
708 |
|
}; |
709 |
0 |
SequenceFetcherFactory.setSequenceFetcher(mockFetcher); |
710 |
|
|
711 |
|
|
712 |
|
|
713 |
|
|
714 |
|
|
715 |
|
|
716 |
|
|
717 |
|
|
718 |
|
|
719 |
0 |
SequenceI[] seqs = new SequenceI[] { p0ce19, p0ce20 }; |
720 |
0 |
AlignmentI al = new Alignment(seqs); |
721 |
0 |
Alignment xrefs = new CrossRef(seqs, al).findXrefSequences("EMBL", |
722 |
|
false); |
723 |
|
|
724 |
|
|
725 |
|
|
726 |
|
|
727 |
0 |
assertNotNull(xrefs); |
728 |
0 |
assertEquals(4, xrefs.getHeight()); |
729 |
0 |
assertSame(j03321, xrefs.getSequenceAt(0)); |
730 |
0 |
assertSame(x06707, xrefs.getSequenceAt(1)); |
731 |
0 |
assertSame(m19487, xrefs.getSequenceAt(2)); |
732 |
0 |
assertSame(x07547, xrefs.getSequenceAt(3)); |
733 |
|
|
734 |
|
|
735 |
|
|
736 |
|
|
737 |
0 |
Mapping mapping = p0ce19.getDBRefs().get(0).getMap(); |
738 |
0 |
assertSame(j03321, mapping.getTo()); |
739 |
0 |
mapping = p0ce19.getDBRefs().get(1).getMap(); |
740 |
0 |
assertSame(x06707, mapping.getTo()); |
741 |
0 |
mapping = p0ce20.getDBRefs().get(0).getMap(); |
742 |
0 |
assertSame(j03321, mapping.getTo()); |
743 |
0 |
mapping = p0ce20.getDBRefs().get(1).getMap(); |
744 |
0 |
assertSame(x06707, mapping.getTo()); |
745 |
|
|
746 |
|
|
747 |
|
|
748 |
|
|
749 |
|
|
750 |
0 |
assertSame(p0ce19, j03321.getDBRefs().get(0).getMap().getTo()); |
751 |
0 |
assertSame(p0ce20, j03321.getDBRefs().get(1).getMap().getTo()); |
752 |
0 |
assertSame(p0ce19, x06707.getDBRefs().get(0).getMap().getTo()); |
753 |
0 |
assertSame(p0ce20, x06707.getDBRefs().get(1).getMap().getTo()); |
754 |
|
|
755 |
|
|
756 |
|
|
757 |
|
|
758 |
|
|
759 |
0 |
assertEquals(4, p0ce19.getDBRefs().size()); |
760 |
0 |
assertEquals("PIR", p0ce19.getDBRefs().get(3).getSource()); |
761 |
0 |
assertEquals("S01875", p0ce19.getDBRefs().get(3).getAccessionId()); |
762 |
|
} |
763 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
764 |
1 |
@Test(groups = "Functional")... |
765 |
|
public void testSameSequence() |
766 |
|
{ |
767 |
1 |
assertTrue(CrossRef.sameSequence(null, null)); |
768 |
1 |
SequenceI seq1 = new Sequence("seq1", "ABCDEF"); |
769 |
1 |
assertFalse(CrossRef.sameSequence(seq1, null)); |
770 |
1 |
assertFalse(CrossRef.sameSequence(null, seq1)); |
771 |
1 |
assertTrue(CrossRef.sameSequence(seq1, new Sequence("seq2", "ABCDEF"))); |
772 |
1 |
assertTrue(CrossRef.sameSequence(seq1, new Sequence("seq2", "abcdef"))); |
773 |
1 |
assertFalse( |
774 |
|
CrossRef.sameSequence(seq1, new Sequence("seq2", "ABCDE-F"))); |
775 |
1 |
assertFalse(CrossRef.sameSequence(seq1, new Sequence("seq2", "BCDEF"))); |
776 |
|
} |
777 |
|
} |