1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.util; |
22 |
|
|
23 |
|
import jalview.datamodel.DBRefEntry; |
24 |
|
import jalview.datamodel.DBRefSource; |
25 |
|
import jalview.datamodel.PDBEntry; |
26 |
|
import jalview.datamodel.SequenceI; |
27 |
|
|
28 |
|
import java.util.ArrayList; |
29 |
|
import java.util.Arrays; |
30 |
|
import java.util.HashMap; |
31 |
|
import java.util.HashSet; |
32 |
|
import java.util.List; |
33 |
|
import java.util.Map; |
34 |
|
import java.util.Set; |
35 |
|
|
36 |
|
import com.stevesoft.pat.Regex; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
|
|
| 63.6% |
Uncovered Elements: 100 (275) |
Complexity: 132 |
Complexity Density: 0.86 |
|
41 |
|
public class DBRefUtils |
42 |
|
{ |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
private static Map<String, String> canonicalSourceNameLookup = new HashMap<String, String>(); |
47 |
|
|
48 |
|
private static Map<String, String> dasCoordinateSystemsLookup = new HashMap<String, String>(); |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
|
50 |
1 |
static... |
51 |
|
{ |
52 |
|
|
53 |
1 |
canonicalSourceNameLookup.put("uniprotkb/swiss-prot", |
54 |
|
DBRefSource.UNIPROT); |
55 |
1 |
canonicalSourceNameLookup.put("uniprotkb/trembl", DBRefSource.UNIPROT); |
56 |
|
|
57 |
|
|
58 |
1 |
canonicalSourceNameLookup.put("uniprot/sptrembl", DBRefSource.UNIPROT); |
59 |
1 |
canonicalSourceNameLookup.put("uniprot/swissprot", DBRefSource.UNIPROT); |
60 |
|
|
61 |
1 |
canonicalSourceNameLookup.put("pdb", DBRefSource.PDB); |
62 |
1 |
canonicalSourceNameLookup.put("ensembl", DBRefSource.ENSEMBL); |
63 |
|
|
64 |
|
|
65 |
1 |
canonicalSourceNameLookup.put("ensembl-tr", DBRefSource.ENSEMBL); |
66 |
1 |
canonicalSourceNameLookup.put("ensembl-gn", DBRefSource.ENSEMBL); |
67 |
|
|
68 |
|
|
69 |
1 |
Set<String> keys = canonicalSourceNameLookup.keySet(); |
70 |
1 |
for (String k : keys) |
71 |
|
{ |
72 |
8 |
canonicalSourceNameLookup.put(k.toLowerCase(), |
73 |
|
canonicalSourceNameLookup.get(k)); |
74 |
|
} |
75 |
|
|
76 |
1 |
dasCoordinateSystemsLookup.put("pdbresnum", DBRefSource.PDB); |
77 |
1 |
dasCoordinateSystemsLookup.put("uniprot", DBRefSource.UNIPROT); |
78 |
1 |
dasCoordinateSystemsLookup.put("embl", DBRefSource.EMBL); |
79 |
|
|
80 |
|
} |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
@param |
88 |
|
|
89 |
|
@param |
90 |
|
|
91 |
|
@return |
92 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 5 |
Complexity Density: 0.36 |
|
93 |
11167 |
public static DBRefEntry[] selectRefs(DBRefEntry[] dbrefs,... |
94 |
|
String[] sources) |
95 |
|
{ |
96 |
11167 |
if (dbrefs == null || sources == null) |
97 |
|
{ |
98 |
3635 |
return dbrefs; |
99 |
|
} |
100 |
7532 |
HashSet<String> srcs = new HashSet<String>(); |
101 |
7532 |
for (String src : sources) |
102 |
|
{ |
103 |
31583 |
srcs.add(src.toUpperCase()); |
104 |
|
} |
105 |
|
|
106 |
7532 |
List<DBRefEntry> res = new ArrayList<DBRefEntry>(); |
107 |
7532 |
for (DBRefEntry dbr : dbrefs) |
108 |
|
{ |
109 |
8668 |
String source = getCanonicalName(dbr.getSource()); |
110 |
8668 |
if (srcs.contains(source.toUpperCase())) |
111 |
|
{ |
112 |
3295 |
res.add(dbr); |
113 |
|
} |
114 |
|
} |
115 |
|
|
116 |
7532 |
if (res.size() > 0) |
117 |
|
{ |
118 |
3194 |
DBRefEntry[] reply = new DBRefEntry[res.size()]; |
119 |
3194 |
return res.toArray(reply); |
120 |
|
} |
121 |
4338 |
return null; |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
@param |
128 |
|
|
129 |
|
@param |
130 |
|
|
131 |
|
@return |
132 |
|
|
133 |
|
|
134 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 4 |
Complexity Density: 1 |
|
135 |
12 |
public static boolean isDasCoordinateSystem(String string,... |
136 |
|
DBRefEntry dBRefEntry) |
137 |
|
{ |
138 |
12 |
if (string == null || dBRefEntry == null) |
139 |
|
{ |
140 |
3 |
return false; |
141 |
|
} |
142 |
9 |
String coordsys = dasCoordinateSystemsLookup.get(string.toLowerCase()); |
143 |
9 |
return coordsys == null ? false |
144 |
|
: coordsys.equals(dBRefEntry.getSource()); |
145 |
|
} |
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
@param |
153 |
|
@return |
154 |
|
|
155 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
156 |
34440 |
public static String getCanonicalName(String source)... |
157 |
|
{ |
158 |
34440 |
if (source == null) |
159 |
|
{ |
160 |
1 |
return null; |
161 |
|
} |
162 |
34439 |
String canonical = canonicalSourceNameLookup.get(source.toLowerCase()); |
163 |
34439 |
return canonical == null ? source : canonical; |
164 |
|
} |
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
@param |
176 |
|
|
177 |
|
@param |
178 |
|
|
179 |
|
@return |
180 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
181 |
42 |
public static List<DBRefEntry> searchRefs(DBRefEntry[] ref,... |
182 |
|
DBRefEntry entry) |
183 |
|
{ |
184 |
42 |
return searchRefs(ref, entry, |
185 |
|
matchDbAndIdAndEitherMapOrEquivalentMapList); |
186 |
|
} |
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
@param |
197 |
|
|
198 |
|
@param |
199 |
|
|
200 |
|
@return |
201 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
202 |
3 |
public static List<DBRefEntry> searchRefs(DBRefEntry[] refs, String accId)... |
203 |
|
{ |
204 |
3 |
return searchRefs(refs, new DBRefEntry("", "", accId), matchId); |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
@param |
212 |
|
|
213 |
|
@param |
214 |
|
|
215 |
|
@param |
216 |
|
@return |
217 |
|
|
|
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 5 |
Complexity Density: 0.71 |
|
218 |
45 |
static List<DBRefEntry> searchRefs(DBRefEntry[] refs, DBRefEntry entry,... |
219 |
|
DbRefComp comparator) |
220 |
|
{ |
221 |
45 |
List<DBRefEntry> rfs = new ArrayList<DBRefEntry>(); |
222 |
45 |
if (refs == null || entry == null) |
223 |
|
{ |
224 |
0 |
return rfs; |
225 |
|
} |
226 |
78 |
for (int i = 0; i < refs.length; i++) |
227 |
|
{ |
228 |
33 |
if (comparator.matches(entry, refs[i])) |
229 |
|
{ |
230 |
18 |
rfs.add(refs[i]); |
231 |
|
} |
232 |
|
} |
233 |
45 |
return rfs; |
234 |
|
} |
235 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
236 |
|
interface DbRefComp |
237 |
|
{ |
238 |
|
public boolean matches(DBRefEntry refa, DBRefEntry refb); |
239 |
|
} |
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
public static DbRefComp matchNonNullonA = new DbRefComp() |
246 |
|
{ |
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 10 |
Complexity Density: 1.67 |
|
247 |
0 |
@Override... |
248 |
|
public boolean matches(DBRefEntry refa, DBRefEntry refb) |
249 |
|
{ |
250 |
0 |
if (refa.getSource() == null |
251 |
|
|| DBRefUtils.getCanonicalName(refb.getSource()).equals( |
252 |
|
DBRefUtils.getCanonicalName(refa.getSource()))) |
253 |
|
{ |
254 |
0 |
if (refa.getVersion() == null |
255 |
|
|| refb.getVersion().equals(refa.getVersion())) |
256 |
|
{ |
257 |
0 |
if (refa.getAccessionId() == null |
258 |
|
|| refb.getAccessionId().equals(refa.getAccessionId())) |
259 |
|
{ |
260 |
0 |
if (refa.getMap() == null || (refb.getMap() != null |
261 |
|
&& refb.getMap().equals(refa.getMap()))) |
262 |
|
{ |
263 |
0 |
return true; |
264 |
|
} |
265 |
|
} |
266 |
|
} |
267 |
|
} |
268 |
0 |
return false; |
269 |
|
} |
270 |
|
}; |
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
public static DbRefComp matchEitherNonNull = new DbRefComp() |
278 |
|
{ |
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 5 |
Complexity Density: 1.67 |
|
279 |
0 |
@Override... |
280 |
|
public boolean matches(DBRefEntry refa, DBRefEntry refb) |
281 |
|
{ |
282 |
0 |
if (nullOrEqualSource(refa.getSource(), refb.getSource()) |
283 |
|
&& nullOrEqual(refa.getVersion(), refb.getVersion()) |
284 |
|
&& nullOrEqual(refa.getAccessionId(), refb.getAccessionId()) |
285 |
|
&& nullOrEqual(refa.getMap(), refb.getMap())) |
286 |
|
{ |
287 |
0 |
return true; |
288 |
|
} |
289 |
0 |
return false; |
290 |
|
} |
291 |
|
}; |
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
public static DbRefComp matchDbAndIdAndEitherMap = new DbRefComp() |
299 |
|
{ |
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 12 |
Complexity Density: 2.4 |
|
300 |
0 |
@Override... |
301 |
|
public boolean matches(DBRefEntry refa, DBRefEntry refb) |
302 |
|
{ |
303 |
0 |
if (refa.getSource() != null && refb.getSource() != null |
304 |
|
&& DBRefUtils.getCanonicalName(refb.getSource()).equals( |
305 |
|
DBRefUtils.getCanonicalName(refa.getSource()))) |
306 |
|
{ |
307 |
|
|
308 |
0 |
if (refa.getAccessionId() != null && refb.getAccessionId() != null |
309 |
|
|
310 |
|
|| refb.getAccessionId().equals(refa.getAccessionId())) |
311 |
|
{ |
312 |
0 |
if ((refa.getMap() == null || refb.getMap() == null) |
313 |
|
|| (refa.getMap() != null && refb.getMap() != null |
314 |
|
&& refb.getMap().equals(refa.getMap()))) |
315 |
|
{ |
316 |
0 |
return true; |
317 |
|
} |
318 |
|
} |
319 |
|
} |
320 |
0 |
return false; |
321 |
|
} |
322 |
|
}; |
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
|
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
public static DbRefComp matchDbAndIdAndComplementaryMapList = new DbRefComp() |
331 |
|
{ |
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 16 |
Complexity Density: 2.67 |
|
332 |
0 |
@Override... |
333 |
|
public boolean matches(DBRefEntry refa, DBRefEntry refb) |
334 |
|
{ |
335 |
0 |
if (refa.getSource() != null && refb.getSource() != null |
336 |
|
&& DBRefUtils.getCanonicalName(refb.getSource()).equals( |
337 |
|
DBRefUtils.getCanonicalName(refa.getSource()))) |
338 |
|
{ |
339 |
|
|
340 |
0 |
if (refa.getAccessionId() != null && refb.getAccessionId() != null |
341 |
|
|| refb.getAccessionId().equals(refa.getAccessionId())) |
342 |
|
{ |
343 |
0 |
if ((refa.getMap() == null && refb.getMap() == null) |
344 |
|
|| (refa.getMap() != null && refb.getMap() != null)) |
345 |
|
{ |
346 |
0 |
if ((refb.getMap().getMap() == null |
347 |
|
&& refa.getMap().getMap() == null) |
348 |
|
|| (refb.getMap().getMap() != null |
349 |
|
&& refa.getMap().getMap() != null |
350 |
|
&& refb.getMap().getMap().getInverse() |
351 |
|
.equals(refa.getMap().getMap()))) |
352 |
|
{ |
353 |
0 |
return true; |
354 |
|
} |
355 |
|
} |
356 |
|
} |
357 |
|
} |
358 |
0 |
return false; |
359 |
|
} |
360 |
|
}; |
361 |
|
|
362 |
|
|
363 |
|
|
364 |
|
|
365 |
|
|
366 |
|
|
367 |
|
|
368 |
|
public static DbRefComp matchDbAndIdAndEquivalentMapList = new DbRefComp() |
369 |
|
{ |
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 16 |
Complexity Density: 2.29 |
|
370 |
0 |
@Override... |
371 |
|
public boolean matches(DBRefEntry refa, DBRefEntry refb) |
372 |
|
{ |
373 |
0 |
if (refa.getSource() != null && refb.getSource() != null |
374 |
|
&& DBRefUtils.getCanonicalName(refb.getSource()).equals( |
375 |
|
DBRefUtils.getCanonicalName(refa.getSource()))) |
376 |
|
{ |
377 |
|
|
378 |
|
|
379 |
|
|
380 |
|
|
381 |
0 |
if (refa.getAccessionId() != null && refb.getAccessionId() != null |
382 |
|
|| refb.getAccessionId().equals(refa.getAccessionId())) |
383 |
|
{ |
384 |
0 |
if (refa.getMap() == null && refb.getMap() == null) |
385 |
|
{ |
386 |
0 |
return true; |
387 |
|
} |
388 |
0 |
if (refa.getMap() != null && refb.getMap() != null |
389 |
|
&& ((refb.getMap().getMap() == null |
390 |
|
&& refa.getMap().getMap() == null) |
391 |
|
|| (refb.getMap().getMap() != null |
392 |
|
&& refa.getMap().getMap() != null |
393 |
|
&& refb.getMap().getMap() |
394 |
|
.equals(refa.getMap().getMap())))) |
395 |
|
{ |
396 |
0 |
return true; |
397 |
|
} |
398 |
|
} |
399 |
|
} |
400 |
0 |
return false; |
401 |
|
} |
402 |
|
}; |
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
public static DbRefComp matchDbAndIdAndEitherMapOrEquivalentMapList = new DbRefComp() |
410 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 15 |
Complexity Density: 2.14 |
|
411 |
26 |
@Override... |
412 |
|
public boolean matches(DBRefEntry refa, DBRefEntry refb) |
413 |
|
{ |
414 |
26 |
if (refa.getSource() != null && refb.getSource() != null |
415 |
|
&& DBRefUtils.getCanonicalName(refb.getSource()).equals( |
416 |
|
DBRefUtils.getCanonicalName(refa.getSource()))) |
417 |
|
{ |
418 |
|
|
419 |
|
|
420 |
15 |
if (refa.getAccessionId() == null |
421 |
|
|| refa.getAccessionId().equals(refb.getAccessionId())) |
422 |
|
{ |
423 |
14 |
if (refa.getMap() == null || refb.getMap() == null) |
424 |
|
{ |
425 |
12 |
return true; |
426 |
|
} |
427 |
2 |
if ((refa.getMap() != null && refb.getMap() != null) |
428 |
|
&& (refb.getMap().getMap() == null |
429 |
|
&& refa.getMap().getMap() == null) |
430 |
|
|| (refb.getMap().getMap() != null |
431 |
|
&& refa.getMap().getMap() != null |
432 |
|
&& (refb.getMap().getMap() |
433 |
|
.equals(refa.getMap().getMap())))) |
434 |
|
{ |
435 |
1 |
return true; |
436 |
|
} |
437 |
|
} |
438 |
|
} |
439 |
13 |
return false; |
440 |
|
} |
441 |
|
}; |
442 |
|
|
443 |
|
|
444 |
|
|
445 |
|
|
446 |
|
public static DbRefComp matchId = new DbRefComp() |
447 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 4 |
Complexity Density: 1.33 |
|
448 |
7 |
@Override... |
449 |
|
public boolean matches(DBRefEntry refa, DBRefEntry refb) |
450 |
|
{ |
451 |
7 |
if (refa.getAccessionId() != null && refb.getAccessionId() != null |
452 |
|
&& refb.getAccessionId().equals(refa.getAccessionId())) |
453 |
|
{ |
454 |
5 |
return true; |
455 |
|
} |
456 |
2 |
return false; |
457 |
|
} |
458 |
|
}; |
459 |
|
|
460 |
|
|
461 |
|
|
462 |
|
|
463 |
|
|
464 |
|
|
465 |
|
|
466 |
|
|
467 |
|
@param |
468 |
|
@param |
469 |
|
@param |
470 |
|
@param |
471 |
|
|
472 |
|
@return |
473 |
|
|
|
|
| 77.1% |
Uncovered Elements: 8 (35) |
Complexity: 7 |
Complexity Density: 0.3 |
|
474 |
1630 |
public static DBRefEntry parseToDbRef(SequenceI seq, String dbname,... |
475 |
|
String version, String acn) |
476 |
|
{ |
477 |
1630 |
DBRefEntry ref = null; |
478 |
1630 |
if (dbname != null) |
479 |
|
{ |
480 |
1630 |
String locsrc = DBRefUtils.getCanonicalName(dbname); |
481 |
1630 |
if (locsrc.equals(DBRefSource.PDB)) |
482 |
|
{ |
483 |
|
|
484 |
|
|
485 |
|
|
486 |
|
|
487 |
27 |
Regex r = new com.stevesoft.pat.Regex( |
488 |
|
"([0-9][0-9A-Za-z]{3})\\s*(.?)\\s*;\\s*([0-9]+)-([0-9]+)"); |
489 |
27 |
if (r.search(acn.trim())) |
490 |
|
{ |
491 |
27 |
String pdbid = r.stringMatched(1); |
492 |
27 |
String chaincode = r.stringMatched(2); |
493 |
27 |
if (chaincode == null) |
494 |
|
{ |
495 |
0 |
chaincode = " "; |
496 |
|
} |
497 |
|
|
498 |
|
|
499 |
27 |
if (chaincode.equals(" ")) |
500 |
|
{ |
501 |
0 |
chaincode = "_"; |
502 |
|
} |
503 |
|
|
504 |
27 |
ref = new DBRefEntry(locsrc, version, pdbid + chaincode); |
505 |
27 |
PDBEntry pdbr = new PDBEntry(); |
506 |
27 |
pdbr.setId(pdbid); |
507 |
27 |
pdbr.setType(PDBEntry.Type.PDB); |
508 |
27 |
pdbr.setChainCode(chaincode); |
509 |
27 |
seq.addPDBId(pdbr); |
510 |
|
} |
511 |
|
else |
512 |
|
{ |
513 |
0 |
System.err.println("Malformed PDB DR line:" + acn); |
514 |
|
} |
515 |
|
} |
516 |
|
else |
517 |
|
{ |
518 |
|
|
519 |
1603 |
ref = new DBRefEntry(locsrc, version, acn); |
520 |
|
} |
521 |
|
} |
522 |
1630 |
if (ref != null) |
523 |
|
{ |
524 |
1630 |
seq.addDBRef(ref); |
525 |
|
} |
526 |
1630 |
return ref; |
527 |
|
} |
528 |
|
|
529 |
|
|
530 |
|
|
531 |
|
|
532 |
|
@param |
533 |
|
@param |
534 |
|
@return |
535 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
536 |
0 |
public static boolean nullOrEqual(Object o1, Object o2)... |
537 |
|
{ |
538 |
0 |
if (o1 == null || o2 == null) |
539 |
|
{ |
540 |
0 |
return true; |
541 |
|
} |
542 |
0 |
return o1.equals(o2); |
543 |
|
} |
544 |
|
|
545 |
|
|
546 |
|
|
547 |
|
|
548 |
|
@param |
549 |
|
|
550 |
|
@param |
551 |
|
|
552 |
|
@return |
553 |
|
|
554 |
|
|
555 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
556 |
0 |
public static boolean nullOrEqualSource(String o1, String o2)... |
557 |
|
{ |
558 |
0 |
if (o1 == null || o2 == null) |
559 |
|
{ |
560 |
0 |
return true; |
561 |
|
} |
562 |
0 |
return DBRefUtils.getCanonicalName(o1) |
563 |
|
.equals(DBRefUtils.getCanonicalName(o2)); |
564 |
|
} |
565 |
|
|
566 |
|
|
567 |
|
|
568 |
|
|
569 |
|
@param |
570 |
|
|
571 |
|
|
572 |
|
@param |
573 |
|
|
574 |
|
@return |
575 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
576 |
10565 |
public static DBRefEntry[] selectDbRefs(boolean selectDna,... |
577 |
|
DBRefEntry[] refs) |
578 |
|
{ |
579 |
10565 |
return selectRefs(refs, |
580 |
10565 |
selectDna ? DBRefSource.DNACODINGDBS : DBRefSource.PROTEINDBS); |
581 |
|
|
582 |
|
|
583 |
|
|
584 |
|
} |
585 |
|
|
586 |
|
|
587 |
|
|
588 |
|
|
589 |
|
|
590 |
|
@param |
591 |
|
@param |
592 |
|
@return |
593 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
594 |
9 |
public static List<DBRefEntry> searchRefsForSource(DBRefEntry[] dbRefs,... |
595 |
|
String source) |
596 |
|
{ |
597 |
9 |
List<DBRefEntry> matches = new ArrayList<DBRefEntry>(); |
598 |
9 |
if (dbRefs != null && source != null) |
599 |
|
{ |
600 |
7 |
for (DBRefEntry dbref : dbRefs) |
601 |
|
{ |
602 |
15 |
if (source.equalsIgnoreCase(dbref.getSource())) |
603 |
|
{ |
604 |
15 |
matches.add(dbref); |
605 |
|
} |
606 |
|
} |
607 |
|
} |
608 |
9 |
return matches; |
609 |
|
} |
610 |
|
|
611 |
|
|
612 |
|
|
613 |
|
|
614 |
|
|
615 |
|
|
616 |
|
|
617 |
|
|
618 |
|
|
619 |
|
|
620 |
|
|
621 |
|
|
622 |
|
|
623 |
|
|
624 |
|
|
625 |
|
|
626 |
|
|
627 |
|
|
628 |
|
|
629 |
|
|
630 |
|
|
631 |
|
|
632 |
|
|
633 |
|
|
634 |
|
|
635 |
|
|
636 |
|
|
637 |
|
@param |
638 |
|
|
|
|
| 75.5% |
Uncovered Elements: 13 (53) |
Complexity: 15 |
Complexity Density: 0.43 |
|
639 |
2381 |
public static void ensurePrimaries(SequenceI sequence)... |
640 |
|
{ |
641 |
2381 |
List<DBRefEntry> pr = sequence.getPrimaryDBRefs(); |
642 |
2381 |
if (pr.size() == 0) |
643 |
|
{ |
644 |
|
|
645 |
1909 |
return; |
646 |
|
} |
647 |
472 |
List<DBRefEntry> selfs = new ArrayList<DBRefEntry>(); |
648 |
|
{ |
649 |
472 |
DBRefEntry[] selfArray = selectDbRefs(!sequence.isProtein(), |
650 |
|
sequence.getDBRefs()); |
651 |
472 |
if (selfArray == null || selfArray.length == 0) |
652 |
|
{ |
653 |
|
|
654 |
164 |
return; |
655 |
|
} |
656 |
308 |
selfs.addAll(Arrays.asList(selfArray)); |
657 |
|
} |
658 |
|
|
659 |
|
|
660 |
308 |
for (DBRefEntry p : pr) |
661 |
|
{ |
662 |
708 |
while (selfs.contains(p)) |
663 |
|
{ |
664 |
353 |
selfs.remove(p); |
665 |
|
} |
666 |
|
} |
667 |
308 |
List<DBRefEntry> toPromote = new ArrayList<DBRefEntry>(); |
668 |
|
|
669 |
308 |
for (DBRefEntry p : pr) |
670 |
|
{ |
671 |
355 |
List<String> promType = new ArrayList<String>(); |
672 |
355 |
if (sequence.isProtein()) |
673 |
|
{ |
674 |
337 |
switch (getCanonicalName(p.getSource())) |
675 |
|
{ |
676 |
322 |
case DBRefSource.UNIPROT: |
677 |
|
|
678 |
|
|
679 |
|
|
680 |
322 |
promType.add(DBRefSource.ENSEMBL); |
681 |
322 |
break; |
682 |
7 |
case DBRefSource.ENSEMBL: |
683 |
|
|
684 |
7 |
promType.add(DBRefSource.UNIPROT); |
685 |
7 |
break; |
686 |
|
} |
687 |
|
} |
688 |
|
else |
689 |
|
{ |
690 |
|
|
691 |
|
} |
692 |
|
|
693 |
|
|
694 |
355 |
DBRefEntry[] candidates = selectRefs(selfs.toArray(new DBRefEntry[0]), |
695 |
|
promType.toArray(new String[0])); |
696 |
355 |
if (candidates != null) |
697 |
|
{ |
698 |
2 |
for (DBRefEntry cand : candidates) |
699 |
|
{ |
700 |
2 |
if (cand.hasMap()) |
701 |
|
{ |
702 |
2 |
if (cand.getMap().getTo() != null |
703 |
|
&& cand.getMap().getTo() != sequence) |
704 |
|
{ |
705 |
|
|
706 |
2 |
continue; |
707 |
|
} |
708 |
0 |
if (cand.getMap().getMap().getFromLowest() != sequence |
709 |
|
.getStart() |
710 |
|
&& cand.getMap().getMap().getFromHighest() != sequence |
711 |
|
.getEnd()) |
712 |
|
{ |
713 |
|
|
714 |
|
|
715 |
0 |
continue; |
716 |
|
} |
717 |
|
} |
718 |
|
|
719 |
0 |
cand.setVersion(p.getVersion() + " (promoted)"); |
720 |
0 |
selfs.remove(cand); |
721 |
0 |
toPromote.add(cand); |
722 |
0 |
if (!cand.isPrimaryCandidate()) |
723 |
|
{ |
724 |
0 |
System.out.println( |
725 |
|
"Warning: Couldn't promote dbref " + cand.toString() |
726 |
|
+ " for sequence " + sequence.toString()); |
727 |
|
} |
728 |
|
} |
729 |
|
} |
730 |
|
} |
731 |
|
} |
732 |
|
|
733 |
|
} |