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