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