| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.analysis; |
| 22 |
|
|
| 23 |
|
import java.util.ArrayList; |
| 24 |
|
import java.util.Arrays; |
| 25 |
|
import java.util.Iterator; |
| 26 |
|
import java.util.List; |
| 27 |
|
import java.util.Locale; |
| 28 |
|
|
| 29 |
|
import com.stevesoft.pat.Regex; |
| 30 |
|
|
| 31 |
|
import jalview.api.AlignViewportI; |
| 32 |
|
import jalview.api.FeatureRenderer; |
| 33 |
|
import jalview.api.FinderI; |
| 34 |
|
import jalview.datamodel.AlignmentI; |
| 35 |
|
import jalview.datamodel.SearchResultMatchI; |
| 36 |
|
import jalview.datamodel.SearchResults; |
| 37 |
|
import jalview.datamodel.SearchResultsI; |
| 38 |
|
import jalview.datamodel.SequenceFeature; |
| 39 |
|
import jalview.datamodel.SequenceGroup; |
| 40 |
|
import jalview.datamodel.SequenceI; |
| 41 |
|
import jalview.datamodel.features.SequenceFeaturesI; |
| 42 |
|
import jalview.util.Comparison; |
| 43 |
|
import jalview.util.Platform; |
| 44 |
|
import jalview.util.MapList; |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| |
|
| 96.4% |
Uncovered Elements: 10 (275) |
Complexity: 73 |
Complexity Density: 0.41 |
|
| 49 |
|
public class Finder implements FinderI |
| 50 |
|
{ |
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
private SearchResultsI searchResults; |
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
private List<SequenceI> idMatches; |
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
|
| 64 |
|
private AlignViewportI viewport; |
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
FeatureRenderer frm = null; |
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
private int sequenceIndex; |
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
private int residueIndex; |
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
private SequenceFeature lastFeature; |
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
private int lastFeatureSequenceIndex; |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
private int searchedSequenceStartPosition; |
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
private MapList searchedSequenceMap; |
| 103 |
|
|
| 104 |
|
private String seqToSearch; |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
@param |
| 110 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 111 |
38 |
public Finder(AlignViewportI av)... |
| 112 |
|
{ |
| 113 |
38 |
this.viewport = av; |
| 114 |
38 |
this.sequenceIndex = 0; |
| 115 |
38 |
this.residueIndex = -1; |
| 116 |
|
} |
| 117 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
| 118 |
32 |
@Override... |
| 119 |
|
public void findAll(String theSearchString, boolean matchCase, |
| 120 |
|
boolean searchDescription, boolean searchFeatureDesc, |
| 121 |
|
boolean ignoreHidden) |
| 122 |
|
{ |
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
32 |
lastFeature = null; |
| 127 |
32 |
lastFeatureSequenceIndex = 0; |
| 128 |
32 |
sequenceIndex = 0; |
| 129 |
32 |
residueIndex = -1; |
| 130 |
|
|
| 131 |
32 |
doFind(theSearchString, matchCase, searchDescription, searchFeatureDesc, |
| 132 |
|
true, ignoreHidden); |
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
32 |
sequenceIndex = 0; |
| 138 |
32 |
residueIndex = -1; |
| 139 |
32 |
lastFeature = null; |
| 140 |
32 |
lastFeatureSequenceIndex = 0; |
| 141 |
|
} |
| 142 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 143 |
23 |
@Override... |
| 144 |
|
public void findNext(String theSearchString, boolean matchCase, |
| 145 |
|
boolean searchDescription, boolean searchFeatureDesc, |
| 146 |
|
boolean ignoreHidden) |
| 147 |
|
{ |
| 148 |
23 |
doFind(theSearchString, matchCase, searchDescription, searchFeatureDesc, |
| 149 |
|
false, ignoreHidden); |
| 150 |
|
|
| 151 |
23 |
if (searchResults.isEmpty() && idMatches.isEmpty()) |
| 152 |
|
{ |
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
| 156 |
3 |
sequenceIndex = 0; |
| 157 |
3 |
residueIndex = -1; |
| 158 |
3 |
lastFeature = null; |
| 159 |
3 |
lastFeatureSequenceIndex = 0; |
| 160 |
|
} |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
@param |
| 167 |
|
@param |
| 168 |
|
@param |
| 169 |
|
@param |
| 170 |
|
@param |
| 171 |
|
|
| |
|
| 90% |
Uncovered Elements: 2 (20) |
Complexity: 7 |
Complexity Density: 0.5 |
|
| 172 |
55 |
protected void doFind(String theSearchString, boolean matchCase,... |
| 173 |
|
boolean searchDescription, boolean searchFeatureDesc, |
| 174 |
|
boolean findAll, boolean ignoreHidden) |
| 175 |
|
{ |
| 176 |
55 |
searchResults = new SearchResults(); |
| 177 |
55 |
idMatches = new ArrayList<>(); |
| 178 |
|
|
| 179 |
55 |
String searchString = matchCase ? theSearchString |
| 180 |
|
: theSearchString.toUpperCase(Locale.ROOT); |
| 181 |
55 |
Regex searchPattern = Platform.newRegex(searchString); |
| 182 |
55 |
searchPattern.setIgnoreCase(!matchCase); |
| 183 |
|
|
| 184 |
55 |
SequenceGroup selection = viewport.getSelectionGroup(); |
| 185 |
55 |
if (selection != null && selection.getSize() < 1) |
| 186 |
|
{ |
| 187 |
0 |
selection = null; |
| 188 |
|
} |
| 189 |
|
|
| 190 |
55 |
AlignmentI alignment = viewport.getAlignment(); |
| 191 |
55 |
int end = alignment.getHeight(); |
| 192 |
|
|
| 193 |
55 |
getSequence(ignoreHidden); |
| 194 |
|
|
| 195 |
55 |
boolean found = false; |
| 196 |
272 |
while ((!found || findAll) && sequenceIndex < end) |
| 197 |
|
{ |
| 198 |
217 |
found = findNextMatch(searchString, searchPattern, searchDescription, |
| 199 |
|
searchFeatureDesc, ignoreHidden); |
| 200 |
|
} |
| 201 |
|
} |
| 202 |
|
|
| 203 |
|
|
| 204 |
|
|
| 205 |
|
|
| 206 |
|
|
| 207 |
|
|
| 208 |
|
|
| 209 |
|
|
| 210 |
|
|
| 211 |
|
|
| 212 |
|
|
| 213 |
|
|
| 214 |
|
|
| 215 |
|
|
| 216 |
|
|
| 217 |
|
|
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
|
|
| 222 |
|
|
| 223 |
|
|
| 224 |
|
|
| 225 |
|
@param |
| 226 |
|
@return |
| 227 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (35) |
Complexity: 7 |
Complexity Density: 0.28 |
|
| 228 |
207 |
private boolean getSequence(boolean ignoreHidden)... |
| 229 |
|
{ |
| 230 |
207 |
AlignmentI alignment = viewport.getAlignment(); |
| 231 |
207 |
if (sequenceIndex >= alignment.getHeight()) |
| 232 |
|
{ |
| 233 |
35 |
seqToSearch = ""; |
| 234 |
35 |
return false; |
| 235 |
|
} |
| 236 |
172 |
SequenceI seq = alignment.getSequenceAt(sequenceIndex); |
| 237 |
172 |
SequenceGroup selection = viewport.getSelectionGroup(); |
| 238 |
172 |
if (selection != null && !selection.contains(seq)) |
| 239 |
|
{ |
| 240 |
9 |
if (!nextSequence(ignoreHidden)) |
| 241 |
|
{ |
| 242 |
4 |
return false; |
| 243 |
|
} |
| 244 |
5 |
seq = alignment.getSequenceAt(sequenceIndex); |
| 245 |
|
} |
| 246 |
|
|
| 247 |
168 |
String seqString = null; |
| 248 |
168 |
if (ignoreHidden) |
| 249 |
|
{ |
| 250 |
33 |
seqString = getVisibleSequence(seq); |
| 251 |
33 |
this.searchedSequenceStartPosition = 1; |
| 252 |
|
} |
| 253 |
|
else |
| 254 |
|
{ |
| 255 |
135 |
int startCol = 0; |
| 256 |
135 |
int endCol = seq.getLength() - 1; |
| 257 |
135 |
this.searchedSequenceStartPosition = seq.getStart(); |
| 258 |
135 |
if (selection != null) |
| 259 |
|
{ |
| 260 |
21 |
startCol = selection.getStartRes(); |
| 261 |
21 |
endCol = Math.min(endCol, selection.getEndRes()); |
| 262 |
21 |
this.searchedSequenceStartPosition = seq.findPosition(startCol); |
| 263 |
|
} |
| 264 |
135 |
seqString = seq.getSequenceAsString(startCol, endCol + 1); |
| 265 |
|
} |
| 266 |
|
|
| 267 |
|
|
| 268 |
|
|
| 269 |
|
|
| 270 |
|
|
| 271 |
168 |
String ungapped = AlignSeq.extractGaps(Comparison.GapChars, seqString); |
| 272 |
168 |
this.seqToSearch = ungapped; |
| 273 |
|
|
| 274 |
168 |
return true; |
| 275 |
|
} |
| 276 |
|
|
| 277 |
|
|
| 278 |
|
|
| 279 |
|
|
| 280 |
|
|
| 281 |
|
|
| 282 |
|
|
| 283 |
|
|
| 284 |
|
|
| 285 |
|
|
| 286 |
|
|
| 287 |
|
@param |
| 288 |
|
@return |
| 289 |
|
|
| |
|
| 96.6% |
Uncovered Elements: 1 (29) |
Complexity: 5 |
Complexity Density: 0.24 |
|
| 290 |
33 |
private String getVisibleSequence(SequenceI seq)... |
| 291 |
|
{ |
| 292 |
|
|
| 293 |
|
|
| 294 |
|
|
| 295 |
|
|
| 296 |
33 |
int seqStartCol = seq.findIndex(seq.getStart()) - 1; |
| 297 |
33 |
int seqEndCol = seq.findIndex(seq.getStart() + seq.getLength() - 1) - 1; |
| 298 |
33 |
Iterator<int[]> visibleColumns = viewport.getViewAsVisibleContigs(true); |
| 299 |
33 |
StringBuilder visibleSeq = new StringBuilder(seqEndCol - seqStartCol); |
| 300 |
33 |
List<int[]> fromRanges = new ArrayList<>(); |
| 301 |
|
|
| 302 |
93 |
while (visibleColumns.hasNext()) |
| 303 |
|
{ |
| 304 |
63 |
int[] range = visibleColumns.next(); |
| 305 |
63 |
if (range[0] > seqEndCol) |
| 306 |
|
{ |
| 307 |
|
|
| 308 |
3 |
break; |
| 309 |
|
} |
| 310 |
60 |
if (range[1] < seqStartCol) |
| 311 |
|
{ |
| 312 |
|
|
| 313 |
3 |
continue; |
| 314 |
|
} |
| 315 |
57 |
String subseq = seq.getSequenceAsString(range[0], range[1] + 1); |
| 316 |
57 |
String ungapped = AlignSeq.extractGaps(Comparison.GapChars, subseq); |
| 317 |
57 |
visibleSeq.append(ungapped); |
| 318 |
57 |
if (!ungapped.isEmpty()) |
| 319 |
|
{ |
| 320 |
|
|
| 321 |
|
|
| 322 |
|
|
| 323 |
|
|
| 324 |
57 |
int seqResFrom = seq.findPosition(range[0]); |
| 325 |
57 |
int seqResTo = seqResFrom + ungapped.length() - 1; |
| 326 |
57 |
fromRanges.add(new int[] { seqResFrom, seqResTo }); |
| 327 |
|
} |
| 328 |
|
} |
| 329 |
|
|
| 330 |
|
|
| 331 |
|
|
| 332 |
|
|
| 333 |
|
|
| 334 |
|
|
| 335 |
33 |
List<int[]> toRange = Arrays |
| 336 |
|
.asList(new int[] |
| 337 |
|
{ 1, visibleSeq.length() }); |
| 338 |
33 |
searchedSequenceMap = new MapList(fromRanges, toRange, 1, 1); |
| 339 |
|
|
| 340 |
33 |
return visibleSeq.toString(); |
| 341 |
|
} |
| 342 |
|
|
| 343 |
|
|
| 344 |
|
|
| 345 |
|
|
| 346 |
|
|
| 347 |
|
|
| 348 |
|
|
| 349 |
|
|
| 350 |
|
|
| 351 |
|
|
| 352 |
|
@param |
| 353 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 354 |
152 |
private boolean nextSequence(boolean ignoreHidden)... |
| 355 |
|
{ |
| 356 |
152 |
sequenceIndex++; |
| 357 |
152 |
residueIndex = -1; |
| 358 |
|
|
| 359 |
152 |
return getSequence(ignoreHidden); |
| 360 |
|
} |
| 361 |
|
|
| 362 |
|
|
| 363 |
|
|
| 364 |
|
|
| 365 |
|
|
| 366 |
|
|
| 367 |
|
|
| 368 |
|
|
| 369 |
|
|
| 370 |
|
|
| 371 |
|
|
| 372 |
|
@param |
| 373 |
|
@param |
| 374 |
|
@param |
| 375 |
|
@param |
| 376 |
|
@param |
| 377 |
|
@return |
| 378 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 8 |
Complexity Density: 0.47 |
|
| 379 |
217 |
protected boolean findNextMatch(String searchString, Regex searchPattern,... |
| 380 |
|
boolean matchDescription, boolean matchFeatureDesc, |
| 381 |
|
boolean ignoreHidden) |
| 382 |
|
{ |
| 383 |
217 |
if (residueIndex < 0) |
| 384 |
|
{ |
| 385 |
|
|
| 386 |
|
|
| 387 |
|
|
| 388 |
|
|
| 389 |
153 |
if (doNonMotifSearches(searchString, searchPattern, matchDescription)) |
| 390 |
|
{ |
| 391 |
17 |
return true; |
| 392 |
|
} |
| 393 |
|
} |
| 394 |
|
|
| 395 |
|
|
| 396 |
|
|
| 397 |
|
|
| 398 |
200 |
int end = seqToSearch.length(); |
| 399 |
354 |
while (residueIndex < end) |
| 400 |
|
{ |
| 401 |
211 |
boolean matched = searchPattern.searchFrom(seqToSearch, residueIndex); |
| 402 |
211 |
if (matched) |
| 403 |
|
{ |
| 404 |
72 |
if (recordMatch(searchPattern, ignoreHidden)) |
| 405 |
|
{ |
| 406 |
51 |
return true; |
| 407 |
|
} |
| 408 |
|
} |
| 409 |
|
else |
| 410 |
|
{ |
| 411 |
139 |
if (matchFeatureDesc) |
| 412 |
|
{ |
| 413 |
17 |
matched = searchSequenceFeatures(residueIndex, searchPattern); |
| 414 |
17 |
if (matched) |
| 415 |
|
{ |
| 416 |
6 |
return true; |
| 417 |
|
} |
| 418 |
11 |
lastFeature = null; |
| 419 |
|
} |
| 420 |
133 |
residueIndex = Integer.MAX_VALUE; |
| 421 |
|
} |
| 422 |
|
} |
| 423 |
|
|
| 424 |
143 |
nextSequence(ignoreHidden); |
| 425 |
143 |
return false; |
| 426 |
|
} |
| 427 |
|
|
| 428 |
|
|
| 429 |
|
|
| 430 |
|
|
| 431 |
|
|
| 432 |
|
|
| 433 |
|
|
| 434 |
|
|
| 435 |
|
|
| 436 |
|
|
| 437 |
|
|
| 438 |
|
@param |
| 439 |
|
@param |
| 440 |
|
@return |
| 441 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 5 |
Complexity Density: 0.38 |
|
| 442 |
72 |
protected boolean recordMatch(Regex searchPattern, boolean ignoreHidden)... |
| 443 |
|
{ |
| 444 |
72 |
SequenceI seq = viewport.getAlignment().getSequenceAt(sequenceIndex); |
| 445 |
|
|
| 446 |
|
|
| 447 |
|
|
| 448 |
|
|
| 449 |
72 |
int offset = searchPattern.matchedFrom(); |
| 450 |
72 |
int matchStartPosition = this.searchedSequenceStartPosition + offset; |
| 451 |
72 |
int matchEndPosition = matchStartPosition + searchPattern.charsMatched() |
| 452 |
|
- 1; |
| 453 |
|
|
| 454 |
|
|
| 455 |
|
|
| 456 |
|
|
| 457 |
|
|
| 458 |
72 |
residueIndex = searchPattern.matchedFrom() + 1; |
| 459 |
|
|
| 460 |
|
|
| 461 |
|
|
| 462 |
|
|
| 463 |
72 |
if (allHidden(seq, matchStartPosition, matchEndPosition)) |
| 464 |
|
{ |
| 465 |
5 |
return false; |
| 466 |
|
} |
| 467 |
|
|
| 468 |
|
|
| 469 |
|
|
| 470 |
|
|
| 471 |
67 |
List<SearchResultMatchI> matches = searchResults.getResults(); |
| 472 |
67 |
SearchResultMatchI lastMatch = matches.isEmpty() ? null |
| 473 |
|
: matches.get(matches.size() - 1); |
| 474 |
|
|
| 475 |
67 |
if (lastMatch == null || !lastMatch.contains(seq, matchStartPosition, |
| 476 |
|
matchEndPosition)) |
| 477 |
|
{ |
| 478 |
51 |
addMatch(seq, matchStartPosition, matchEndPosition, ignoreHidden); |
| 479 |
51 |
return true; |
| 480 |
|
} |
| 481 |
|
|
| 482 |
16 |
return false; |
| 483 |
|
} |
| 484 |
|
|
| 485 |
|
|
| 486 |
|
|
| 487 |
|
|
| 488 |
|
|
| 489 |
|
|
| 490 |
|
@param |
| 491 |
|
@param |
| 492 |
|
@param |
| 493 |
|
@param |
| 494 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 495 |
51 |
private void addMatch(SequenceI seq, int matchStartPosition,... |
| 496 |
|
int matchEndPosition, boolean ignoreHidden) |
| 497 |
|
{ |
| 498 |
51 |
if (!ignoreHidden) |
| 499 |
|
{ |
| 500 |
|
|
| 501 |
|
|
| 502 |
|
|
| 503 |
46 |
searchResults.addResult(seq, matchStartPosition, matchEndPosition); |
| 504 |
46 |
return; |
| 505 |
|
} |
| 506 |
|
|
| 507 |
|
|
| 508 |
|
|
| 509 |
|
|
| 510 |
5 |
int[] truePositions = searchedSequenceMap |
| 511 |
|
.locateInFrom(matchStartPosition, matchEndPosition); |
| 512 |
5 |
searchResults.addResult(seq, truePositions); |
| 513 |
|
} |
| 514 |
|
|
| 515 |
|
|
| 516 |
|
|
| 517 |
|
|
| 518 |
|
@param |
| 519 |
|
@param |
| 520 |
|
@param |
| 521 |
|
@return |
| 522 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 523 |
72 |
private boolean allHidden(SequenceI seq, int fromPos, int toPos)... |
| 524 |
|
{ |
| 525 |
72 |
if (!viewport.hasHiddenColumns()) |
| 526 |
|
{ |
| 527 |
49 |
return false; |
| 528 |
|
} |
| 529 |
28 |
for (int res = fromPos; res <= toPos; res++) |
| 530 |
|
{ |
| 531 |
23 |
if (isVisible(seq, res)) |
| 532 |
|
{ |
| 533 |
18 |
return false; |
| 534 |
|
} |
| 535 |
|
} |
| 536 |
5 |
return true; |
| 537 |
|
} |
| 538 |
|
|
| 539 |
|
|
| 540 |
|
|
| 541 |
|
|
| 542 |
|
|
| 543 |
|
|
| 544 |
|
|
| 545 |
|
|
| 546 |
|
|
| 547 |
|
|
| 548 |
|
@param |
| 549 |
|
@param |
| 550 |
|
@param |
| 551 |
|
@return |
| 552 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 5 |
Complexity Density: 0.5 |
|
| 553 |
153 |
protected boolean doNonMotifSearches(String searchString,... |
| 554 |
|
Regex searchPattern, boolean includeDescription) |
| 555 |
|
{ |
| 556 |
153 |
SequenceI seq = viewport.getAlignment().getSequenceAt(sequenceIndex); |
| 557 |
|
|
| 558 |
|
|
| 559 |
|
|
| 560 |
|
|
| 561 |
153 |
residueIndex = 0; |
| 562 |
153 |
try |
| 563 |
|
{ |
| 564 |
153 |
int res = Integer.parseInt(searchString); |
| 565 |
5 |
return searchForResidueNumber(seq, res); |
| 566 |
|
} catch (NumberFormatException ex) |
| 567 |
|
{ |
| 568 |
|
|
| 569 |
|
} |
| 570 |
|
|
| 571 |
148 |
if (searchSequenceName(seq, searchPattern)) |
| 572 |
|
{ |
| 573 |
10 |
return true; |
| 574 |
|
} |
| 575 |
138 |
if (includeDescription && searchSequenceDescription(seq, searchPattern)) |
| 576 |
|
{ |
| 577 |
4 |
return true; |
| 578 |
|
} |
| 579 |
134 |
return false; |
| 580 |
|
} |
| 581 |
|
|
| 582 |
|
|
| 583 |
|
|
| 584 |
|
|
| 585 |
|
|
| 586 |
|
|
| 587 |
|
@param |
| 588 |
|
@param |
| 589 |
|
@return |
| 590 |
|
|
| |
|
| 94.1% |
Uncovered Elements: 2 (34) |
Complexity: 8 |
Complexity Density: 0.33 |
|
| 591 |
17 |
protected boolean searchSequenceFeatures(int from, Regex searchPattern)... |
| 592 |
|
{ |
| 593 |
17 |
if (lastFeatureSequenceIndex != sequenceIndex) |
| 594 |
|
{ |
| 595 |
9 |
lastFeatureSequenceIndex = sequenceIndex; |
| 596 |
9 |
lastFeature = null; |
| 597 |
|
} |
| 598 |
17 |
SequenceI seq = viewport.getAlignment().getSequenceAt(sequenceIndex); |
| 599 |
17 |
SequenceFeaturesI sf = seq.getFeatures(); |
| 600 |
|
|
| 601 |
|
|
| 602 |
17 |
List<SequenceFeature> allFeatures = null; |
| 603 |
17 |
if (frm != null) |
| 604 |
|
{ |
| 605 |
0 |
allFeatures = frm.findFeaturesAtResidue(seq, seq.getStart(), |
| 606 |
|
seq.getEnd()); |
| 607 |
|
} |
| 608 |
|
else |
| 609 |
|
{ |
| 610 |
|
|
| 611 |
17 |
allFeatures = sf.getAllFeatures(); |
| 612 |
|
} |
| 613 |
|
|
| 614 |
17 |
long fpos = 0; |
| 615 |
|
|
| 616 |
17 |
for (SequenceFeature feature : allFeatures) |
| 617 |
|
{ |
| 618 |
15 |
fpos++; |
| 619 |
15 |
if (lastFeature != null) |
| 620 |
|
{ |
| 621 |
|
|
| 622 |
6 |
if (lastFeature != feature) |
| 623 |
|
{ |
| 624 |
1 |
continue; |
| 625 |
|
} |
| 626 |
|
else |
| 627 |
|
{ |
| 628 |
5 |
lastFeature = null; |
| 629 |
5 |
continue; |
| 630 |
|
} |
| 631 |
|
} |
| 632 |
|
|
| 633 |
9 |
if (searchPattern.search(feature.type) || (feature.description != null |
| 634 |
|
&& searchPattern.search(feature.description))) |
| 635 |
|
{ |
| 636 |
6 |
searchResults.addResult(seq, feature.getBegin(), feature.getEnd()); |
| 637 |
6 |
lastFeature = feature; |
| 638 |
6 |
return true; |
| 639 |
|
} |
| 640 |
|
} |
| 641 |
11 |
residueIndex = Integer.MAX_VALUE; |
| 642 |
11 |
lastFeature = null; |
| 643 |
11 |
return false; |
| 644 |
|
} |
| 645 |
|
|
| 646 |
|
|
| 647 |
|
|
| 648 |
|
|
| 649 |
|
|
| 650 |
|
|
| 651 |
|
@param |
| 652 |
|
@param |
| 653 |
|
@return |
| 654 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 655 |
11 |
protected boolean searchSequenceDescription(SequenceI seq,... |
| 656 |
|
Regex searchPattern) |
| 657 |
|
{ |
| 658 |
11 |
String desc = seq.getDescription(); |
| 659 |
11 |
if (desc != null && searchPattern.search(desc) |
| 660 |
|
&& !idMatches.contains(seq)) |
| 661 |
|
{ |
| 662 |
4 |
idMatches.add(seq); |
| 663 |
4 |
return true; |
| 664 |
|
} |
| 665 |
7 |
return false; |
| 666 |
|
} |
| 667 |
|
|
| 668 |
|
|
| 669 |
|
|
| 670 |
|
|
| 671 |
|
|
| 672 |
|
|
| 673 |
|
@param |
| 674 |
|
@param |
| 675 |
|
@return |
| 676 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 677 |
148 |
protected boolean searchSequenceName(SequenceI seq, Regex searchPattern)... |
| 678 |
|
{ |
| 679 |
148 |
if (searchPattern.search(seq.getName()) && !idMatches.contains(seq)) |
| 680 |
|
{ |
| 681 |
10 |
idMatches.add(seq); |
| 682 |
10 |
return true; |
| 683 |
|
} |
| 684 |
138 |
return false; |
| 685 |
|
} |
| 686 |
|
|
| 687 |
|
|
| 688 |
|
|
| 689 |
|
|
| 690 |
|
|
| 691 |
|
|
| 692 |
|
@param |
| 693 |
|
@param |
| 694 |
|
@return |
| 695 |
|
|
| |
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 696 |
5 |
protected boolean searchForResidueNumber(SequenceI seq, int resNo)... |
| 697 |
|
{ |
| 698 |
5 |
if (seq.getStart() <= resNo && seq.getEnd() >= resNo) |
| 699 |
|
{ |
| 700 |
3 |
if (isVisible(seq, resNo)) |
| 701 |
|
{ |
| 702 |
3 |
searchResults.addResult(seq, resNo, resNo); |
| 703 |
3 |
return true; |
| 704 |
|
} |
| 705 |
|
} |
| 706 |
2 |
return false; |
| 707 |
|
} |
| 708 |
|
|
| 709 |
|
|
| 710 |
|
|
| 711 |
|
|
| 712 |
|
@param |
| 713 |
|
@param |
| 714 |
|
@return |
| 715 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 716 |
26 |
private boolean isVisible(SequenceI seq, int res)... |
| 717 |
|
{ |
| 718 |
26 |
if (!viewport.hasHiddenColumns()) |
| 719 |
|
{ |
| 720 |
0 |
return true; |
| 721 |
|
} |
| 722 |
26 |
int col = seq.findIndex(res); |
| 723 |
26 |
return viewport.getAlignment().getHiddenColumns().isVisible(col - 1); |
| 724 |
|
|
| 725 |
|
} |
| 726 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 727 |
30 |
@Override... |
| 728 |
|
public List<SequenceI> getIdMatches() |
| 729 |
|
{ |
| 730 |
30 |
return idMatches; |
| 731 |
|
} |
| 732 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 733 |
62 |
@Override... |
| 734 |
|
public SearchResultsI getSearchResults() |
| 735 |
|
{ |
| 736 |
62 |
return searchResults; |
| 737 |
|
} |
| 738 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 739 |
0 |
@Override... |
| 740 |
|
public void setFeatureRenderer(FeatureRenderer featureRenderer) |
| 741 |
|
{ |
| 742 |
0 |
frm = featureRenderer; |
| 743 |
|
} |
| 744 |
|
} |