1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.datamodel; |
22 |
|
|
23 |
|
import java.util.Locale; |
24 |
|
|
25 |
|
import jalview.api.DBRefEntryI; |
26 |
|
import jalview.util.DBRefUtils; |
27 |
|
import jalview.util.MapList; |
28 |
|
|
29 |
|
import java.util.List; |
30 |
|
|
|
|
| 0% |
Uncovered Elements: 146 (146) |
Complexity: 70 |
Complexity Density: 1 |
|
31 |
|
public class DBRefEntry implements DBRefEntryI |
32 |
|
{ |
33 |
|
String source = ""; |
34 |
|
|
35 |
|
private String version = ""; |
36 |
|
|
37 |
|
private String ucversion; |
38 |
|
|
39 |
|
private String accessionId = ""; |
40 |
|
|
41 |
|
int sourceKey = Integer.MIN_VALUE; |
42 |
|
|
43 |
|
String canonicalSourceName; |
44 |
|
|
45 |
|
boolean isCanonicalAccession = false; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
Mapping map = null; |
51 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
52 |
0 |
public DBRefEntry()... |
53 |
|
{ |
54 |
|
|
55 |
|
} |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
@param |
60 |
|
|
61 |
|
@param |
62 |
|
|
63 |
|
@param |
64 |
|
|
65 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
0 |
public DBRefEntry(String source, String version, String accessionId)... |
67 |
|
{ |
68 |
0 |
this(source, version, accessionId, null, false); |
69 |
|
} |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
@param |
74 |
|
|
75 |
|
@param |
76 |
|
|
77 |
|
@param |
78 |
|
|
79 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
0 |
public DBRefEntry(String source, String version, String accessionId,... |
81 |
|
Mapping map) |
82 |
|
{ |
83 |
0 |
this(source, version, accessionId, map, false); |
84 |
|
} |
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
@param |
89 |
|
|
90 |
|
@param |
91 |
|
|
92 |
|
@param |
93 |
|
|
94 |
|
@param |
95 |
|
|
96 |
|
|
97 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
98 |
0 |
public DBRefEntry(String source, String version, String accessionId,... |
99 |
|
Mapping map, boolean isCanonical) |
100 |
|
{ |
101 |
|
|
102 |
0 |
this.source = source.toUpperCase(Locale.ROOT); |
103 |
0 |
setVersion(version); |
104 |
0 |
this.accessionId = accessionId; |
105 |
0 |
this.map = map; |
106 |
0 |
this.isCanonicalAccession = isCanonical; |
107 |
|
} |
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 5 |
Complexity Density: 5 |
|
113 |
0 |
public DBRefEntry(DBRefEntryI entry)... |
114 |
|
{ |
115 |
0 |
this((entry.getSource() == null ? "" : new String(entry.getSource())), |
116 |
0 |
(entry.getVersion() == null ? "" |
117 |
|
: new String(entry.getVersion())), |
118 |
0 |
(entry.getAccessionId() == null ? "" |
119 |
|
: new String(entry.getAccessionId())), |
120 |
0 |
(entry.getMap() == null ? null : new Mapping(entry.getMap())), |
121 |
|
entry.isCanonical()); |
122 |
|
} |
123 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
124 |
0 |
@Override... |
125 |
|
public boolean equals(Object o) |
126 |
|
{ |
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
0 |
Mapping em; |
140 |
0 |
return (o != null && o instanceof DBRefEntry && (o == this || equalRef( |
141 |
|
(DBRefEntry) o) |
142 |
|
&& (map == null) == ((em = ((DBRefEntry) o).map) == null) |
143 |
|
&& (map == null || map.equals(em)))); |
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
} |
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
@param |
164 |
|
@return |
165 |
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 27 |
Complexity Density: 1.12 |
|
166 |
0 |
@Override... |
167 |
|
public boolean updateFrom(DBRefEntryI other) |
168 |
|
{ |
169 |
0 |
if (other == null) |
170 |
|
{ |
171 |
0 |
return false; |
172 |
|
} |
173 |
0 |
if (other == this) |
174 |
|
{ |
175 |
0 |
return true; |
176 |
|
} |
177 |
|
|
178 |
0 |
boolean improved = false; |
179 |
|
|
180 |
|
|
181 |
|
|
182 |
0 |
String otherSource = other.getSource(); |
183 |
0 |
if ((source == null && otherSource != null) |
184 |
|
|| (source != null && otherSource == null) |
185 |
|
|| (source != null && !source.equalsIgnoreCase(otherSource))) |
186 |
|
{ |
187 |
0 |
return false; |
188 |
|
} |
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
0 |
String otherAccession = other.getAccessionId(); |
194 |
0 |
if ((accessionId == null && otherAccession != null) |
195 |
|
|| (accessionId != null && otherAccession == null) |
196 |
|
|| (accessionId != null |
197 |
|
&& !accessionId.equalsIgnoreCase(otherAccession))) |
198 |
|
{ |
199 |
0 |
return false; |
200 |
|
} |
201 |
|
|
202 |
0 |
if (!isCanonicalAccession && other.isCanonical()) |
203 |
|
{ |
204 |
0 |
isCanonicalAccession = true; |
205 |
0 |
improved = true; |
206 |
|
} |
207 |
|
else |
208 |
|
{ |
209 |
0 |
if (isCanonicalAccession && !other.isCanonical()) |
210 |
|
{ |
211 |
|
|
212 |
0 |
return false; |
213 |
|
} |
214 |
|
} |
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
0 |
String otherVersion = other.getVersion(); |
220 |
|
|
221 |
0 |
if ((version == null || version.equals("0") || version.endsWith(":0")) |
222 |
|
&& otherVersion != null) |
223 |
|
{ |
224 |
0 |
setVersion(otherVersion); |
225 |
|
} |
226 |
|
else |
227 |
|
{ |
228 |
0 |
if (version != null && (otherVersion == null |
229 |
|
|| !version.equalsIgnoreCase(otherVersion))) |
230 |
|
{ |
231 |
|
|
232 |
|
|
233 |
0 |
return improved; |
234 |
|
} |
235 |
|
} |
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
0 |
if (map == null) |
242 |
|
{ |
243 |
0 |
setMap(other.getMap()); |
244 |
|
} |
245 |
0 |
return true; |
246 |
|
} |
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
|
@param |
252 |
|
@return |
253 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
254 |
0 |
@Override... |
255 |
|
public boolean equalRef(DBRefEntryI entry) |
256 |
|
{ |
257 |
|
|
258 |
0 |
if (entry == null) |
259 |
|
{ |
260 |
0 |
return false; |
261 |
|
} |
262 |
0 |
if (entry == this) |
263 |
|
{ |
264 |
0 |
return true; |
265 |
|
} |
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
0 |
return (entry != null |
271 |
|
&& (source != null && entry.getSource() != null |
272 |
|
&& source.equalsIgnoreCase(entry.getSource())) |
273 |
|
&& (accessionId != null && entry.getAccessionId() != null |
274 |
|
&& accessionId.equalsIgnoreCase(entry.getAccessionId())) |
275 |
|
&& (version != null && entry.getVersion() != null |
276 |
|
&& version.equalsIgnoreCase(entry.getVersion()))); |
277 |
|
} |
278 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
279 |
0 |
@Override... |
280 |
|
public String getSource() |
281 |
|
{ |
282 |
0 |
return source; |
283 |
|
} |
284 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
285 |
0 |
public int getSourceKey()... |
286 |
|
{ |
287 |
0 |
return (sourceKey == Integer.MIN_VALUE |
288 |
|
? (sourceKey = DBRefSource |
289 |
|
.getSourceKey(getCanonicalSourceName())) |
290 |
|
: sourceKey); |
291 |
|
} |
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
296 |
0 |
@Override... |
297 |
|
public String getVersion() |
298 |
|
{ |
299 |
0 |
return version; |
300 |
|
} |
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
305 |
0 |
@Override... |
306 |
|
public String getAccessionId() |
307 |
|
{ |
308 |
0 |
return accessionId; |
309 |
|
} |
310 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
311 |
0 |
@Override... |
312 |
|
public void setAccessionId(String accessionId) |
313 |
|
{ |
314 |
0 |
this.accessionId = accessionId; |
315 |
|
|
316 |
|
|
317 |
|
} |
318 |
|
|
319 |
|
|
320 |
|
|
321 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
322 |
0 |
@Override... |
323 |
|
public void setSource(String source) |
324 |
|
{ |
325 |
0 |
this.source = source; |
326 |
|
|
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
} |
331 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
332 |
0 |
@Override... |
333 |
|
public void setVersion(String version) |
334 |
|
{ |
335 |
0 |
this.version = version; |
336 |
0 |
this.ucversion = (version == null ? null |
337 |
|
: version.toUpperCase(Locale.ROOT)); |
338 |
|
} |
339 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
340 |
0 |
@Override... |
341 |
|
public Mapping getMap() |
342 |
|
{ |
343 |
0 |
return map; |
344 |
|
} |
345 |
|
|
346 |
|
|
347 |
|
@param |
348 |
|
|
349 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
350 |
0 |
public void setMap(Mapping map)... |
351 |
|
{ |
352 |
0 |
this.map = map; |
353 |
|
} |
354 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
355 |
0 |
public boolean hasMap()... |
356 |
|
{ |
357 |
0 |
return map != null; |
358 |
|
} |
359 |
|
|
360 |
|
|
361 |
|
|
362 |
|
@return |
363 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 3 |
|
364 |
0 |
public String getSrcAccString()... |
365 |
|
{ |
366 |
0 |
return ((source != null) ? source : "") + ":" |
367 |
0 |
+ ((accessionId != null) ? accessionId : ""); |
368 |
|
} |
369 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
370 |
0 |
@Override... |
371 |
|
public String toString() |
372 |
|
{ |
373 |
0 |
return getSrcAccString(); |
374 |
|
} |
375 |
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 10 |
Complexity Density: 0.67 |
|
376 |
0 |
@Override... |
377 |
|
public boolean isPrimaryCandidate() |
378 |
|
{ |
379 |
|
|
380 |
|
|
381 |
|
|
382 |
0 |
if (map != null) |
383 |
|
{ |
384 |
0 |
SequenceI mto = map.getTo(); |
385 |
0 |
if (mto != null) |
386 |
|
{ |
387 |
0 |
return false; |
388 |
|
} |
389 |
0 |
MapList ml = map.getMap(); |
390 |
0 |
if (ml.getFromRatio() != ml.getToRatio() || ml.getFromRatio() != 1) |
391 |
|
{ |
392 |
0 |
return false; |
393 |
|
} |
394 |
|
|
395 |
0 |
List<int[]> fromRanges, toRanges; |
396 |
0 |
if ((fromRanges = ml.getFromRanges()).size() != 1 |
397 |
|
|| (toRanges = ml.getToRanges()).size() != 1) |
398 |
|
{ |
399 |
0 |
return false; |
400 |
|
} |
401 |
0 |
if (fromRanges.get(0)[0] != toRanges.get(0)[0] |
402 |
|
|| fromRanges.get(0)[1] != toRanges.get(0)[1]) |
403 |
|
{ |
404 |
0 |
return false; |
405 |
|
} |
406 |
|
} |
407 |
0 |
if (version == null) |
408 |
|
{ |
409 |
|
|
410 |
0 |
return false; |
411 |
|
} |
412 |
|
|
413 |
0 |
return DBRefSource.isPrimaryCandidate(ucversion); |
414 |
|
} |
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
@author |
421 |
|
|
422 |
|
@return |
423 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
424 |
0 |
public String getCanonicalSourceName()... |
425 |
|
{ |
426 |
0 |
return (canonicalSourceName == null |
427 |
|
? (canonicalSourceName = DBRefUtils |
428 |
|
.getCanonicalName(this.source)) |
429 |
|
: canonicalSourceName); |
430 |
|
} |
431 |
|
|
432 |
|
|
433 |
|
|
434 |
|
@param |
435 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
436 |
0 |
public void setCanonical(boolean canonical)... |
437 |
|
{ |
438 |
0 |
isCanonicalAccession = canonical; |
439 |
|
} |
440 |
|
|
441 |
|
|
442 |
|
|
443 |
|
@return |
444 |
|
|
445 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
446 |
0 |
public boolean isCanonical()... |
447 |
|
{ |
448 |
|
|
449 |
0 |
return isCanonicalAccession; |
450 |
|
} |
451 |
|
} |