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