| 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 static jalview.util.UrlConstants.DB_ACCESSION; |
| 24 |
|
import static jalview.util.UrlConstants.DELIM; |
| 25 |
|
import static jalview.util.UrlConstants.SEP; |
| 26 |
|
import static jalview.util.UrlConstants.SEQUENCE_ID; |
| 27 |
|
|
| 28 |
|
import jalview.datamodel.DBRefEntry; |
| 29 |
|
import jalview.datamodel.SequenceI; |
| 30 |
|
|
| 31 |
|
import java.util.Arrays; |
| 32 |
|
import java.util.Collections; |
| 33 |
|
import java.util.Comparator; |
| 34 |
|
import java.util.List; |
| 35 |
|
import java.util.Map; |
| 36 |
|
import java.util.Vector; |
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| |
|
| 86.4% |
Uncovered Elements: 36 (264) |
Complexity: 85 |
Complexity Density: 0.57 |
|
| 47 |
|
public class UrlLink |
| 48 |
|
{ |
| 49 |
|
private static final String SEQUENCEID_PLACEHOLDER = DELIM + SEQUENCE_ID |
| 50 |
|
+ DELIM; |
| 51 |
|
|
| 52 |
|
private static final String ACCESSION_PLACEHOLDER = DELIM + DB_ACCESSION |
| 53 |
|
+ DELIM; |
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
public static final Comparator<String> LINK_COMPARATOR = new Comparator<String>() |
| 62 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 7 |
Complexity Density: 1 |
|
| 63 |
118 |
@Override... |
| 64 |
|
public int compare(String link1, String link2) |
| 65 |
|
{ |
| 66 |
118 |
if (link1 == null || link2 == null) |
| 67 |
|
{ |
| 68 |
3 |
return 0; |
| 69 |
|
} |
| 70 |
115 |
if (link1.contains(SEQUENCEID_PLACEHOLDER) |
| 71 |
|
&& link2.contains(ACCESSION_PLACEHOLDER)) |
| 72 |
|
{ |
| 73 |
24 |
return -1; |
| 74 |
|
} |
| 75 |
91 |
if (link2.contains(SEQUENCEID_PLACEHOLDER) |
| 76 |
|
&& link1.contains(ACCESSION_PLACEHOLDER)) |
| 77 |
|
{ |
| 78 |
45 |
return 1; |
| 79 |
|
} |
| 80 |
46 |
return String.CASE_INSENSITIVE_ORDER.compare(link1, link2); |
| 81 |
|
} |
| 82 |
|
}; |
| 83 |
|
|
| 84 |
|
private static final String EQUALS = "="; |
| 85 |
|
|
| 86 |
|
private static final String SPACE = " "; |
| 87 |
|
|
| 88 |
|
private String urlSuffix; |
| 89 |
|
|
| 90 |
|
private String urlPrefix; |
| 91 |
|
|
| 92 |
|
private String target; |
| 93 |
|
|
| 94 |
|
private String label; |
| 95 |
|
|
| 96 |
|
private String dbname; |
| 97 |
|
|
| 98 |
|
private String regexReplace; |
| 99 |
|
|
| 100 |
|
private boolean dynamic = false; |
| 101 |
|
|
| 102 |
|
private boolean usesDBaccession = false; |
| 103 |
|
|
| 104 |
|
private String invalidMessage = null; |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
@param |
| 112 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 4 |
Complexity Density: 0.16 |
|
| 113 |
16623 |
public UrlLink(String link)... |
| 114 |
|
{ |
| 115 |
16623 |
int sep = link.indexOf(SEP); |
| 116 |
16623 |
int psqid = link.indexOf(DELIM + DB_ACCESSION); |
| 117 |
16623 |
int nsqid = link.indexOf(DELIM + SEQUENCE_ID); |
| 118 |
16623 |
if (psqid > -1) |
| 119 |
|
{ |
| 120 |
16440 |
dynamic = true; |
| 121 |
16440 |
usesDBaccession = true; |
| 122 |
|
|
| 123 |
16440 |
sep = parseLabel(sep, psqid, link); |
| 124 |
|
|
| 125 |
16440 |
int endOfRegex = parseUrl(link, DB_ACCESSION, psqid, sep); |
| 126 |
16440 |
parseTarget(link, sep, endOfRegex); |
| 127 |
|
} |
| 128 |
183 |
else if (nsqid > -1) |
| 129 |
|
{ |
| 130 |
172 |
dynamic = true; |
| 131 |
172 |
sep = parseLabel(sep, nsqid, link); |
| 132 |
|
|
| 133 |
172 |
int endOfRegex = parseUrl(link, SEQUENCE_ID, nsqid, sep); |
| 134 |
|
|
| 135 |
172 |
parseTarget(link, sep, endOfRegex); |
| 136 |
|
} |
| 137 |
|
else |
| 138 |
|
{ |
| 139 |
11 |
label = link.substring(0, sep).trim(); |
| 140 |
|
|
| 141 |
|
|
| 142 |
|
|
| 143 |
11 |
int lastsep = link.lastIndexOf(SEP); |
| 144 |
11 |
if (lastsep != sep) |
| 145 |
|
{ |
| 146 |
8 |
urlPrefix = link.substring(sep + 1, lastsep).trim(); |
| 147 |
8 |
target = link.substring(lastsep + 1).trim(); |
| 148 |
|
} |
| 149 |
|
else |
| 150 |
|
{ |
| 151 |
3 |
urlPrefix = link.substring(sep + 1).trim(); |
| 152 |
3 |
target = label; |
| 153 |
|
} |
| 154 |
|
|
| 155 |
11 |
regexReplace = null; |
| 156 |
11 |
urlSuffix = null; |
| 157 |
|
} |
| 158 |
|
|
| 159 |
16623 |
label = label.trim(); |
| 160 |
16623 |
target = target.trim(); |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
@param |
| 167 |
|
|
| 168 |
|
@param |
| 169 |
|
|
| 170 |
|
@param |
| 171 |
|
|
| 172 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 173 |
16476 |
public UrlLink(String name, String url, String desc)... |
| 174 |
|
{ |
| 175 |
16476 |
this(name + SEP + url + SEP + desc); |
| 176 |
|
} |
| 177 |
|
|
| 178 |
|
|
| 179 |
|
@return |
| 180 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 181 |
5 |
public String getUrlSuffix()... |
| 182 |
|
{ |
| 183 |
5 |
return urlSuffix; |
| 184 |
|
} |
| 185 |
|
|
| 186 |
|
|
| 187 |
|
@return |
| 188 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 189 |
15 |
public String getUrlPrefix()... |
| 190 |
|
{ |
| 191 |
15 |
return urlPrefix; |
| 192 |
|
} |
| 193 |
|
|
| 194 |
|
|
| 195 |
|
@return |
| 196 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 197 |
32 |
public String getTarget()... |
| 198 |
|
{ |
| 199 |
32 |
return target; |
| 200 |
|
} |
| 201 |
|
|
| 202 |
|
|
| 203 |
|
@return |
| 204 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 205 |
135 |
public String getLabel()... |
| 206 |
|
{ |
| 207 |
135 |
return label; |
| 208 |
|
} |
| 209 |
|
|
| |
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 5 |
Complexity Density: 2.5 |
|
| 210 |
374 |
public String getUrlWithToken()... |
| 211 |
|
{ |
| 212 |
374 |
String var = (usesDBaccession ? DB_ACCESSION : SEQUENCE_ID); |
| 213 |
|
|
| 214 |
374 |
return urlPrefix |
| 215 |
374 |
+ (dynamic |
| 216 |
|
? (DELIM + var |
| 217 |
363 |
+ ((regexReplace != null) |
| 218 |
|
? EQUALS + regexReplace + EQUALS + DELIM |
| 219 |
|
: DELIM)) |
| 220 |
|
: "") |
| 221 |
374 |
+ ((urlSuffix == null) ? "" : urlSuffix); |
| 222 |
|
} |
| 223 |
|
|
| 224 |
|
|
| 225 |
|
@return |
| 226 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 227 |
80 |
public String getRegexReplace()... |
| 228 |
|
{ |
| 229 |
80 |
return regexReplace; |
| 230 |
|
} |
| 231 |
|
|
| 232 |
|
|
| 233 |
|
@return |
| 234 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 235 |
13 |
public String getInvalidMessage()... |
| 236 |
|
{ |
| 237 |
13 |
return invalidMessage; |
| 238 |
|
} |
| 239 |
|
|
| 240 |
|
|
| 241 |
|
|
| 242 |
|
|
| 243 |
|
@return |
| 244 |
|
|
| 245 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 246 |
104 |
public boolean isValid()... |
| 247 |
|
{ |
| 248 |
104 |
return invalidMessage == null; |
| 249 |
|
} |
| 250 |
|
|
| 251 |
|
|
| 252 |
|
|
| 253 |
|
@return |
| 254 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 255 |
6 |
public boolean isDynamic()... |
| 256 |
|
{ |
| 257 |
6 |
return dynamic; |
| 258 |
|
} |
| 259 |
|
|
| 260 |
|
|
| 261 |
|
|
| 262 |
|
@return |
| 263 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 264 |
136 |
public boolean usesDBAccession()... |
| 265 |
|
{ |
| 266 |
136 |
return usesDBaccession; |
| 267 |
|
} |
| 268 |
|
|
| 269 |
|
|
| 270 |
|
|
| 271 |
|
|
| 272 |
|
@param |
| 273 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 274 |
44 |
public void setLabel(String newlabel)... |
| 275 |
|
{ |
| 276 |
44 |
this.label = newlabel; |
| 277 |
|
} |
| 278 |
|
|
| 279 |
|
|
| 280 |
|
|
| 281 |
|
|
| 282 |
|
@param |
| 283 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 284 |
6 |
public void setTarget(String desc)... |
| 285 |
|
{ |
| 286 |
6 |
target = desc; |
| 287 |
|
} |
| 288 |
|
|
| 289 |
|
|
| 290 |
|
|
| 291 |
|
|
| 292 |
|
@param |
| 293 |
|
@param |
| 294 |
|
|
| 295 |
|
|
| 296 |
|
@return |
| 297 |
|
|
| 298 |
|
|
| |
|
| 65.2% |
Uncovered Elements: 23 (66) |
Complexity: 19 |
Complexity Density: 0.5 |
|
| 299 |
55 |
public String[] makeUrls(String idstring, boolean onlyIfMatches)... |
| 300 |
|
{ |
| 301 |
55 |
if (dynamic) |
| 302 |
|
{ |
| 303 |
55 |
if (regexReplace != null) |
| 304 |
|
{ |
| 305 |
8 |
com.stevesoft.pat.Regex rg = com.stevesoft.pat.Regex |
| 306 |
|
.perlCode("/" + regexReplace + "/"); |
| 307 |
8 |
if (rg.search(idstring)) |
| 308 |
|
{ |
| 309 |
6 |
int ns = rg.numSubs(); |
| 310 |
6 |
if (ns == 0) |
| 311 |
|
{ |
| 312 |
|
|
| 313 |
0 |
return new String[] { rg.stringMatched(), |
| 314 |
|
urlPrefix + rg.stringMatched() + urlSuffix }; |
| 315 |
|
} |
| 316 |
|
|
| 317 |
|
|
| 318 |
|
|
| 319 |
|
|
| 320 |
|
else |
| 321 |
|
{ |
| 322 |
|
|
| 323 |
24 |
for (int s = 0; s <= rg.numSubs(); s++) |
| 324 |
|
{ |
| 325 |
18 |
jalview.bin.Console.errPrintln("Sub " + s + " : " |
| 326 |
|
+ rg.matchedFrom(s) + " : " + rg.matchedTo(s) + " : '" |
| 327 |
|
+ rg.stringMatched(s) + "'"); |
| 328 |
|
} |
| 329 |
|
|
| 330 |
6 |
Vector<String> subs = new Vector<>(); |
| 331 |
|
|
| 332 |
|
|
| 333 |
6 |
int s = 0; |
| 334 |
24 |
while (s <= ns) |
| 335 |
|
{ |
| 336 |
18 |
if (s + 1 <= ns && rg.matchedTo(s) > -1 |
| 337 |
|
&& rg.matchedTo(s + 1) > -1 |
| 338 |
|
&& rg.matchedTo(s + 1) < rg.matchedTo(s)) |
| 339 |
|
{ |
| 340 |
|
|
| 341 |
|
|
| 342 |
0 |
int r = s + 1; |
| 343 |
0 |
String mtch = ""; |
| 344 |
0 |
while (r <= ns && rg.matchedTo(r) <= rg.matchedTo(s)) |
| 345 |
|
{ |
| 346 |
0 |
if (rg.matchedFrom(r) > -1) |
| 347 |
|
{ |
| 348 |
0 |
mtch += rg.stringMatched(r); |
| 349 |
|
} |
| 350 |
0 |
r++; |
| 351 |
|
} |
| 352 |
0 |
if (mtch.length() > 0) |
| 353 |
|
{ |
| 354 |
0 |
subs.addElement(mtch); |
| 355 |
0 |
subs.addElement(urlPrefix + mtch + urlSuffix); |
| 356 |
|
} |
| 357 |
0 |
s = r; |
| 358 |
|
} |
| 359 |
|
else |
| 360 |
|
{ |
| 361 |
18 |
if (rg.matchedFrom(s) > -1) |
| 362 |
|
{ |
| 363 |
6 |
subs.addElement(rg.stringMatched(s)); |
| 364 |
6 |
subs.addElement( |
| 365 |
|
urlPrefix + rg.stringMatched(s) + urlSuffix); |
| 366 |
|
} |
| 367 |
18 |
s++; |
| 368 |
|
} |
| 369 |
|
} |
| 370 |
|
|
| 371 |
6 |
String[] res = new String[subs.size()]; |
| 372 |
18 |
for (int r = 0, rs = subs.size(); r < rs; r++) |
| 373 |
|
{ |
| 374 |
12 |
res[r] = subs.elementAt(r); |
| 375 |
|
} |
| 376 |
6 |
subs.removeAllElements(); |
| 377 |
6 |
return res; |
| 378 |
|
} |
| 379 |
|
} |
| 380 |
2 |
if (onlyIfMatches) |
| 381 |
|
{ |
| 382 |
1 |
return null; |
| 383 |
|
} |
| 384 |
|
} |
| 385 |
|
|
| 386 |
48 |
if (idstring.indexOf(SEP) > -1) |
| 387 |
|
{ |
| 388 |
0 |
idstring = idstring.substring(idstring.lastIndexOf(SEP) + 1); |
| 389 |
|
} |
| 390 |
|
|
| 391 |
|
|
| 392 |
48 |
return new String[] { idstring, urlPrefix + idstring + urlSuffix }; |
| 393 |
|
} |
| 394 |
|
else |
| 395 |
|
{ |
| 396 |
0 |
return new String[] { "", urlPrefix }; |
| 397 |
|
} |
| 398 |
|
} |
| 399 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 400 |
288 |
@Override... |
| 401 |
|
public String toString() |
| 402 |
|
{ |
| 403 |
288 |
return label + SEP + getUrlWithToken(); |
| 404 |
|
} |
| 405 |
|
|
| 406 |
|
|
| 407 |
|
@return |
| 408 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 409 |
17 |
public String toStringWithTarget()... |
| 410 |
|
{ |
| 411 |
17 |
return label + SEP + getUrlWithToken() + SEP + target; |
| 412 |
|
} |
| 413 |
|
|
| 414 |
|
|
| 415 |
|
|
| 416 |
|
|
| 417 |
|
@param |
| 418 |
|
|
| 419 |
|
@param |
| 420 |
|
|
| 421 |
|
@param |
| 422 |
|
|
| 423 |
|
@return |
| 424 |
|
|
| |
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 425 |
16612 |
protected int parseLabel(int firstSep, int psqid, String link)... |
| 426 |
|
{ |
| 427 |
16612 |
int p = firstSep; |
| 428 |
16612 |
int sep = firstSep; |
| 429 |
16612 |
do |
| 430 |
|
{ |
| 431 |
16612 |
sep = p; |
| 432 |
16612 |
p = link.indexOf(SEP, sep + 1); |
| 433 |
16612 |
} while (p > sep && p < psqid); |
| 434 |
|
|
| 435 |
|
|
| 436 |
16612 |
label = link.substring(0, sep); |
| 437 |
|
|
| 438 |
16612 |
return sep; |
| 439 |
|
} |
| 440 |
|
|
| 441 |
|
|
| 442 |
|
|
| 443 |
|
|
| 444 |
|
@param |
| 445 |
|
|
| 446 |
|
@param |
| 447 |
|
|
| 448 |
|
@param |
| 449 |
|
|
| 450 |
|
|
| |
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 5 |
Complexity Density: 0.62 |
|
| 451 |
16612 |
protected void parseTarget(String link, int sep, int endOfRegex)... |
| 452 |
|
{ |
| 453 |
16612 |
int lastsep = link.lastIndexOf(SEP); |
| 454 |
|
|
| 455 |
16612 |
if ((lastsep != sep) && (lastsep > endOfRegex)) |
| 456 |
|
{ |
| 457 |
|
|
| 458 |
16469 |
target = link.substring(lastsep + 1).trim(); |
| 459 |
|
} |
| 460 |
|
else |
| 461 |
|
{ |
| 462 |
143 |
target = label; |
| 463 |
|
} |
| 464 |
|
|
| 465 |
16612 |
if (target.indexOf(SEP) > -1) |
| 466 |
|
{ |
| 467 |
|
|
| 468 |
0 |
target = target.substring(0, target.indexOf(SEP)); |
| 469 |
|
} |
| 470 |
16612 |
else if (target.indexOf(SPACE) > 2) |
| 471 |
|
{ |
| 472 |
|
|
| 473 |
94 |
target = target.substring(0, target.indexOf(SPACE)); |
| 474 |
|
} |
| 475 |
|
} |
| 476 |
|
|
| 477 |
|
|
| 478 |
|
|
| 479 |
|
|
| 480 |
|
@param |
| 481 |
|
|
| 482 |
|
@param |
| 483 |
|
|
| 484 |
|
@param |
| 485 |
|
|
| 486 |
|
@param |
| 487 |
|
|
| 488 |
|
@return |
| 489 |
|
|
| |
|
| 96.7% |
Uncovered Elements: 1 (30) |
Complexity: 7 |
Complexity Density: 0.32 |
|
| 490 |
16612 |
protected int parseUrl(String link, String varName, int sqidPos, int sep)... |
| 491 |
|
{ |
| 492 |
16612 |
urlPrefix = link.substring(sep + 1, sqidPos).trim(); |
| 493 |
|
|
| 494 |
|
|
| 495 |
16612 |
String startDelimiter = DELIM + varName + "=/"; |
| 496 |
|
|
| 497 |
|
|
| 498 |
16612 |
String endDelimiter = "/=" + DELIM; |
| 499 |
|
|
| 500 |
16612 |
int startLength = startDelimiter.length(); |
| 501 |
|
|
| 502 |
|
|
| 503 |
16612 |
int p = link.indexOf(endDelimiter, sqidPos + startLength); |
| 504 |
|
|
| 505 |
16612 |
if (link.indexOf(startDelimiter) == sqidPos |
| 506 |
|
&& (p > sqidPos + startLength)) |
| 507 |
|
{ |
| 508 |
|
|
| 509 |
4 |
urlSuffix = link.substring(p + endDelimiter.length()); |
| 510 |
4 |
regexReplace = link.substring(sqidPos + startLength, p); |
| 511 |
4 |
try |
| 512 |
|
{ |
| 513 |
4 |
com.stevesoft.pat.Regex rg = com.stevesoft.pat.Regex |
| 514 |
|
.perlCode("/" + regexReplace + "/"); |
| 515 |
4 |
if (rg == null) |
| 516 |
|
{ |
| 517 |
1 |
invalidMessage = "Invalid Regular Expression : '" + regexReplace |
| 518 |
|
+ "'\n"; |
| 519 |
|
} |
| 520 |
|
} catch (Exception e) |
| 521 |
|
{ |
| 522 |
0 |
invalidMessage = "Invalid Regular Expression : '" + regexReplace |
| 523 |
|
+ "'\n"; |
| 524 |
|
} |
| 525 |
|
} |
| 526 |
|
else |
| 527 |
|
{ |
| 528 |
|
|
| 529 |
16608 |
regexReplace = null; |
| 530 |
|
|
| 531 |
16608 |
if (link.indexOf(DELIM + varName + DELIM) == sqidPos) |
| 532 |
|
{ |
| 533 |
16605 |
int lastsep = link.lastIndexOf(SEP); |
| 534 |
16605 |
if (lastsep < sqidPos + startLength - 1) |
| 535 |
|
{ |
| 536 |
|
|
| 537 |
139 |
lastsep = link.length(); |
| 538 |
|
} |
| 539 |
16605 |
urlSuffix = link.substring(sqidPos + startLength - 1, lastsep) |
| 540 |
|
.trim(); |
| 541 |
16605 |
regexReplace = null; |
| 542 |
|
} |
| 543 |
|
else |
| 544 |
|
{ |
| 545 |
3 |
invalidMessage = "Warning: invalid regex structure for URL link : " |
| 546 |
|
+ link; |
| 547 |
|
} |
| 548 |
|
} |
| 549 |
|
|
| 550 |
16612 |
return p; |
| 551 |
|
} |
| 552 |
|
|
| 553 |
|
|
| 554 |
|
|
| 555 |
|
|
| 556 |
|
@param |
| 557 |
|
|
| 558 |
|
@param |
| 559 |
|
|
| 560 |
|
|
| 561 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 562 |
97 |
public void createLinksFromSeq(final SequenceI seq,... |
| 563 |
|
Map<String, List<String>> linkset) |
| 564 |
|
{ |
| 565 |
97 |
if (seq != null && dynamic) |
| 566 |
|
{ |
| 567 |
94 |
createDynamicLinks(seq, linkset); |
| 568 |
|
} |
| 569 |
|
else |
| 570 |
|
{ |
| 571 |
3 |
createStaticLink(linkset); |
| 572 |
|
} |
| 573 |
|
} |
| 574 |
|
|
| 575 |
|
|
| 576 |
|
|
| 577 |
|
|
| 578 |
|
@param |
| 579 |
|
|
| 580 |
|
|
| 581 |
|
|
| |
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 582 |
3 |
protected void createStaticLink(Map<String, List<String>> linkset)... |
| 583 |
|
{ |
| 584 |
3 |
if (!linkset.containsKey(label + SEP + getUrlPrefix())) |
| 585 |
|
{ |
| 586 |
|
|
| 587 |
3 |
linkset.put(label + SEP + getUrlPrefix(), |
| 588 |
|
Arrays.asList(target, label, null, getUrlPrefix())); |
| 589 |
|
} |
| 590 |
|
} |
| 591 |
|
|
| 592 |
|
|
| 593 |
|
|
| 594 |
|
|
| 595 |
|
@param |
| 596 |
|
|
| 597 |
|
@param |
| 598 |
|
|
| 599 |
|
|
| 600 |
|
|
| |
|
| 80% |
Uncovered Elements: 5 (25) |
Complexity: 10 |
Complexity Density: 0.77 |
|
| 601 |
94 |
protected void createDynamicLinks(final SequenceI seq,... |
| 602 |
|
Map<String, List<String>> linkset) |
| 603 |
|
{ |
| 604 |
|
|
| 605 |
94 |
String id = seq.getName(); |
| 606 |
94 |
String descr = seq.getDescription(); |
| 607 |
94 |
if (descr != null && descr.length() < 1) |
| 608 |
|
{ |
| 609 |
0 |
descr = null; |
| 610 |
|
} |
| 611 |
|
|
| 612 |
94 |
if (usesDBAccession()) |
| 613 |
|
{ |
| 614 |
|
|
| 615 |
70 |
List<DBRefEntry> dbr = DBRefUtils.selectRefs(seq.getDBRefs(), |
| 616 |
|
new String[] |
| 617 |
|
{ target }); |
| 618 |
|
|
| 619 |
|
|
| 620 |
70 |
if (dbr != null) |
| 621 |
|
{ |
| 622 |
16 |
for (int r = 0, nd = dbr.size(); r < nd; r++) |
| 623 |
|
{ |
| 624 |
|
|
| 625 |
10 |
createBareURLLink(dbr.get(r).getAccessionId(), true, linkset); |
| 626 |
|
} |
| 627 |
|
} |
| 628 |
|
} |
| 629 |
24 |
else if (!usesDBAccession() && id != null) |
| 630 |
|
{ |
| 631 |
|
|
| 632 |
24 |
createBareURLLink(id, false, linkset); |
| 633 |
|
} |
| 634 |
|
|
| 635 |
|
|
| 636 |
|
|
| 637 |
94 |
if (descr != null && getRegexReplace() != null) |
| 638 |
|
{ |
| 639 |
|
|
| 640 |
0 |
createBareURLLink(descr, false, linkset); |
| 641 |
|
} |
| 642 |
|
} |
| 643 |
|
|
| 644 |
|
|
| 645 |
|
|
| 646 |
|
|
| 647 |
|
|
| |
|
| 87.5% |
Uncovered Elements: 2 (16) |
Complexity: 5 |
Complexity Density: 0.62 |
|
| 648 |
34 |
protected void createBareURLLink(String id, Boolean combineLabel,... |
| 649 |
|
Map<String, List<String>> linkset) |
| 650 |
|
{ |
| 651 |
34 |
String[] urls = makeUrls(id, true); |
| 652 |
34 |
if (urls != null) |
| 653 |
|
{ |
| 654 |
68 |
for (int u = 0; u < urls.length; u += 2) |
| 655 |
|
{ |
| 656 |
34 |
if (!linkset.containsKey(urls[u] + SEP + urls[u + 1])) |
| 657 |
|
{ |
| 658 |
34 |
String thisLabel = label; |
| 659 |
34 |
if (combineLabel) |
| 660 |
|
{ |
| 661 |
|
|
| 662 |
10 |
thisLabel = label + SEP + urls[u]; |
| 663 |
|
} |
| 664 |
|
|
| 665 |
34 |
linkset.put(urls[u] + SEP + urls[u + 1], |
| 666 |
|
Arrays.asList(target, thisLabel, urls[u], urls[u + 1])); |
| 667 |
|
} |
| 668 |
|
} |
| 669 |
|
} |
| 670 |
|
} |
| 671 |
|
|
| 672 |
|
|
| 673 |
|
|
| 674 |
|
|
| 675 |
|
|
| 676 |
|
|
| 677 |
|
|
| 678 |
|
|
| 679 |
|
|
| 680 |
|
|
| 681 |
|
@param |
| 682 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 683 |
23 |
public static void sort(List<String> nlinks)... |
| 684 |
|
{ |
| 685 |
23 |
Collections.sort(nlinks, LINK_COMPARATOR); |
| 686 |
|
} |
| 687 |
|
} |