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