| 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.ArrayList; |
| 24 |
|
import java.util.BitSet; |
| 25 |
|
import java.util.Collections; |
| 26 |
|
import java.util.List; |
| 27 |
|
import java.util.regex.PatternSyntaxException; |
| 28 |
|
|
| 29 |
|
import jalview.viewmodel.annotationfilter.AnnotationFilterParameter; |
| 30 |
|
import jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField; |
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| |
|
| 0% |
Uncovered Elements: 291 (291) |
Complexity: 104 |
Complexity Density: 0.68 |
|
| 36 |
|
public class ColumnSelection |
| 37 |
|
{ |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| |
|
| 0% |
Uncovered Elements: 107 (107) |
Complexity: 33 |
Complexity Density: 0.54 |
|
| 41 |
|
private class IntList |
| 42 |
|
{ |
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
private List<Integer> order; |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
private List<Integer> _uorder; |
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
private BitSet selected; |
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 61 |
0 |
IntList()... |
| 62 |
|
{ |
| 63 |
0 |
order = new ArrayList<>(); |
| 64 |
0 |
_uorder = Collections.unmodifiableList(order); |
| 65 |
0 |
selected = new BitSet(); |
| 66 |
|
} |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
@param |
| 72 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 73 |
0 |
IntList(IntList other)... |
| 74 |
|
{ |
| 75 |
0 |
this(); |
| 76 |
0 |
if (other != null) |
| 77 |
|
{ |
| 78 |
0 |
int j = other.size(); |
| 79 |
0 |
for (int i = 0; i < j; i++) |
| 80 |
|
{ |
| 81 |
0 |
add(other.elementAt(i)); |
| 82 |
|
} |
| 83 |
|
} |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
@param |
| 90 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 91 |
0 |
void add(int i)... |
| 92 |
|
{ |
| 93 |
0 |
if (!selected.get(i)) |
| 94 |
|
{ |
| 95 |
0 |
order.add(Integer.valueOf(i)); |
| 96 |
0 |
selected.set(i); |
| 97 |
|
} |
| 98 |
|
} |
| 99 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 100 |
0 |
void clear()... |
| 101 |
|
{ |
| 102 |
0 |
order.clear(); |
| 103 |
0 |
selected.clear(); |
| 104 |
|
} |
| 105 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 106 |
0 |
void remove(int col)... |
| 107 |
|
{ |
| 108 |
|
|
| 109 |
0 |
Integer colInt = Integer.valueOf(col); |
| 110 |
|
|
| 111 |
0 |
if (selected.get(col)) |
| 112 |
|
{ |
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
0 |
order.remove(colInt); |
| 117 |
0 |
selected.clear(col); |
| 118 |
|
} |
| 119 |
|
} |
| 120 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 121 |
0 |
boolean contains(Integer colInt)... |
| 122 |
|
{ |
| 123 |
0 |
return selected.get(colInt); |
| 124 |
|
} |
| 125 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 126 |
0 |
boolean isEmpty()... |
| 127 |
|
{ |
| 128 |
0 |
return order.isEmpty(); |
| 129 |
|
} |
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
@return |
| 135 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 136 |
0 |
List<Integer> getList()... |
| 137 |
|
{ |
| 138 |
0 |
return _uorder; |
| 139 |
|
} |
| 140 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 141 |
0 |
int size()... |
| 142 |
|
{ |
| 143 |
0 |
return order.size(); |
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| 149 |
|
@param |
| 150 |
|
@return |
| 151 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 152 |
0 |
int elementAt(int i)... |
| 153 |
|
{ |
| 154 |
0 |
return order.get(i); |
| 155 |
|
} |
| 156 |
|
|
| |
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 6 |
Complexity Density: 0.4 |
|
| 157 |
0 |
protected boolean pruneColumnList(final List<int[]> shifts)... |
| 158 |
|
{ |
| 159 |
0 |
int s = 0, t = shifts.size(); |
| 160 |
0 |
int[] sr = shifts.get(s++); |
| 161 |
0 |
boolean pruned = false; |
| 162 |
0 |
int i = 0, j = order.size(); |
| 163 |
0 |
while (i < j && s <= t) |
| 164 |
|
{ |
| 165 |
0 |
int c = order.get(i++).intValue(); |
| 166 |
0 |
if (sr[0] <= c) |
| 167 |
|
{ |
| 168 |
0 |
if (sr[1] + sr[0] >= c) |
| 169 |
|
{ |
| 170 |
0 |
order.remove(--i); |
| 171 |
0 |
selected.clear(c); |
| 172 |
0 |
j--; |
| 173 |
|
} |
| 174 |
|
else |
| 175 |
|
{ |
| 176 |
0 |
if (s < t) |
| 177 |
|
{ |
| 178 |
0 |
sr = shifts.get(s); |
| 179 |
|
} |
| 180 |
0 |
s++; |
| 181 |
|
} |
| 182 |
|
} |
| 183 |
|
} |
| 184 |
0 |
return pruned; |
| 185 |
|
} |
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
|
| 190 |
|
@param |
| 191 |
|
|
| 192 |
|
@param |
| 193 |
|
|
| 194 |
|
|
| |
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 195 |
0 |
void compensateForEdits(int start, int change)... |
| 196 |
|
{ |
| 197 |
0 |
BitSet mask = new BitSet(); |
| 198 |
0 |
for (int i = 0; i < order.size(); i++) |
| 199 |
|
{ |
| 200 |
0 |
int temp = order.get(i); |
| 201 |
|
|
| 202 |
0 |
if (temp >= start) |
| 203 |
|
{ |
| 204 |
|
|
| 205 |
0 |
selected.clear(temp); |
| 206 |
0 |
mask.set(temp - change); |
| 207 |
0 |
order.set(i, Integer.valueOf(temp - change)); |
| 208 |
|
} |
| 209 |
|
} |
| 210 |
|
|
| 211 |
0 |
selected.or(mask); |
| 212 |
|
} |
| 213 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 214 |
0 |
boolean isSelected(int column)... |
| 215 |
|
{ |
| 216 |
0 |
return selected.get(column); |
| 217 |
|
} |
| 218 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 219 |
0 |
int getMaxColumn()... |
| 220 |
|
{ |
| 221 |
0 |
return selected.length() - 1; |
| 222 |
|
} |
| 223 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 224 |
0 |
int getMinColumn()... |
| 225 |
|
{ |
| 226 |
0 |
return selected.get(0) ? 0 : selected.nextSetBit(0); |
| 227 |
|
} |
| 228 |
|
|
| 229 |
|
|
| 230 |
|
@return |
| 231 |
|
|
| |
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
| 232 |
0 |
List<int[]> getRanges()... |
| 233 |
|
{ |
| 234 |
0 |
List<int[]> rlist = new ArrayList<>(); |
| 235 |
0 |
if (selected.isEmpty()) |
| 236 |
|
{ |
| 237 |
0 |
return rlist; |
| 238 |
|
} |
| 239 |
0 |
int next = selected.nextSetBit(0), clear = -1; |
| 240 |
0 |
while (next != -1) |
| 241 |
|
{ |
| 242 |
0 |
clear = selected.nextClearBit(next); |
| 243 |
0 |
rlist.add(new int[] { next, clear - 1 }); |
| 244 |
0 |
next = selected.nextSetBit(clear); |
| 245 |
|
} |
| 246 |
0 |
return rlist; |
| 247 |
|
} |
| 248 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 249 |
0 |
@Override... |
| 250 |
|
public int hashCode() |
| 251 |
|
{ |
| 252 |
|
|
| 253 |
0 |
return selected.hashCode(); |
| 254 |
|
} |
| 255 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 256 |
0 |
@Override... |
| 257 |
|
public boolean equals(Object obj) |
| 258 |
|
{ |
| 259 |
0 |
if (obj instanceof IntList) |
| 260 |
|
{ |
| 261 |
0 |
return ((IntList) obj).selected.equals(selected); |
| 262 |
|
} |
| 263 |
0 |
return false; |
| 264 |
|
} |
| 265 |
|
} |
| 266 |
|
|
| 267 |
|
private IntList selection = new IntList(); |
| 268 |
|
|
| 269 |
|
|
| 270 |
|
|
| 271 |
|
|
| 272 |
|
@param |
| 273 |
|
|
| 274 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 275 |
0 |
public void addElement(int col)... |
| 276 |
|
{ |
| 277 |
0 |
selection.add(col); |
| 278 |
|
} |
| 279 |
|
|
| 280 |
|
|
| 281 |
|
|
| 282 |
|
|
| 283 |
|
@param |
| 284 |
|
|
| 285 |
|
@param |
| 286 |
|
|
| 287 |
|
|
| |
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 1 |
|
| 288 |
0 |
public void addRangeOfElements(int[] rng, boolean baseOne)... |
| 289 |
|
{ |
| 290 |
0 |
int base = baseOne ? -1 : 0; |
| 291 |
0 |
for (int c = 0; c < rng.length; c += 2) |
| 292 |
|
{ |
| 293 |
0 |
for (int p = rng[c]; p <= rng[c + 1]; p++) |
| 294 |
|
{ |
| 295 |
0 |
selection.add(base + p); |
| 296 |
|
} |
| 297 |
|
} |
| 298 |
|
|
| 299 |
|
} |
| 300 |
|
|
| 301 |
|
|
| 302 |
|
|
| 303 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 304 |
0 |
public void clear()... |
| 305 |
|
{ |
| 306 |
0 |
selection.clear(); |
| 307 |
|
} |
| 308 |
|
|
| 309 |
|
|
| 310 |
|
|
| 311 |
|
|
| 312 |
|
@param |
| 313 |
|
|
| 314 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 315 |
0 |
public void removeElement(int col)... |
| 316 |
|
{ |
| 317 |
0 |
selection.remove(col); |
| 318 |
|
} |
| 319 |
|
|
| 320 |
|
|
| 321 |
|
|
| 322 |
|
|
| 323 |
|
@param |
| 324 |
|
|
| 325 |
|
@param |
| 326 |
|
|
| 327 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 328 |
0 |
public void removeElements(int start, int end)... |
| 329 |
|
{ |
| 330 |
0 |
Integer colInt; |
| 331 |
0 |
for (int i = start; i < end; i++) |
| 332 |
|
{ |
| 333 |
0 |
colInt = Integer.valueOf(i); |
| 334 |
0 |
if (selection.contains(colInt)) |
| 335 |
|
{ |
| 336 |
0 |
selection.remove(colInt); |
| 337 |
|
} |
| 338 |
|
} |
| 339 |
|
} |
| 340 |
|
|
| 341 |
|
|
| 342 |
|
|
| 343 |
|
|
| 344 |
|
|
| 345 |
|
|
| 346 |
|
|
| 347 |
|
|
| 348 |
|
|
| 349 |
|
|
| 350 |
|
|
| 351 |
|
|
| 352 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 353 |
0 |
public List<Integer> getSelected()... |
| 354 |
|
{ |
| 355 |
0 |
return selection.getList(); |
| 356 |
|
} |
| 357 |
|
|
| 358 |
|
|
| 359 |
|
@return |
| 360 |
|
|
| 361 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 362 |
0 |
public List<int[]> getSelectedRanges()... |
| 363 |
|
{ |
| 364 |
0 |
return selection.getRanges(); |
| 365 |
|
} |
| 366 |
|
|
| 367 |
|
|
| 368 |
|
|
| 369 |
|
@param |
| 370 |
|
|
| 371 |
|
|
| 372 |
|
@return |
| 373 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 374 |
0 |
public boolean contains(int col)... |
| 375 |
|
{ |
| 376 |
0 |
return (col > -1) ? selection.isSelected(col) : false; |
| 377 |
|
} |
| 378 |
|
|
| 379 |
|
|
| 380 |
|
|
| 381 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 382 |
0 |
public boolean intersects(int from, int to)... |
| 383 |
|
{ |
| 384 |
|
|
| 385 |
0 |
for (int f = from; f <= to; f++) |
| 386 |
|
{ |
| 387 |
0 |
if (selection.isSelected(f)) |
| 388 |
|
{ |
| 389 |
0 |
return true; |
| 390 |
|
} |
| 391 |
|
} |
| 392 |
0 |
return false; |
| 393 |
|
} |
| 394 |
|
|
| 395 |
|
|
| 396 |
|
|
| 397 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 398 |
0 |
public boolean isEmpty()... |
| 399 |
|
{ |
| 400 |
0 |
return selection == null || selection.isEmpty(); |
| 401 |
|
} |
| 402 |
|
|
| 403 |
|
|
| 404 |
|
|
| 405 |
|
|
| 406 |
|
@return |
| 407 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 408 |
0 |
public int getMax()... |
| 409 |
|
{ |
| 410 |
0 |
if (selection.isEmpty()) |
| 411 |
|
{ |
| 412 |
0 |
return -1; |
| 413 |
|
} |
| 414 |
0 |
return selection.getMaxColumn(); |
| 415 |
|
} |
| 416 |
|
|
| 417 |
|
|
| 418 |
|
|
| 419 |
|
|
| 420 |
|
@return |
| 421 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 422 |
0 |
public int getMin()... |
| 423 |
|
{ |
| 424 |
0 |
if (selection.isEmpty()) |
| 425 |
|
{ |
| 426 |
0 |
return 1000000000; |
| 427 |
|
} |
| 428 |
0 |
return selection.getMinColumn(); |
| 429 |
|
} |
| 430 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 431 |
0 |
public void hideSelectedColumns(AlignmentI al)... |
| 432 |
|
{ |
| 433 |
0 |
synchronized (selection) |
| 434 |
|
{ |
| 435 |
0 |
for (int[] selregions : selection.getRanges()) |
| 436 |
|
{ |
| 437 |
0 |
al.getHiddenColumns().hideColumns(selregions[0], selregions[1]); |
| 438 |
|
} |
| 439 |
0 |
selection.clear(); |
| 440 |
|
} |
| 441 |
|
|
| 442 |
|
} |
| 443 |
|
|
| 444 |
|
|
| 445 |
|
|
| 446 |
|
|
| 447 |
|
@param |
| 448 |
|
|
| 449 |
|
|
| |
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 4 |
Complexity Density: 0.31 |
|
| 450 |
0 |
public void hideSelectedColumns(int col, HiddenColumns hidden)... |
| 451 |
|
{ |
| 452 |
|
|
| 453 |
|
|
| 454 |
|
|
| 455 |
0 |
removeElement(col); |
| 456 |
|
|
| 457 |
|
|
| 458 |
|
|
| 459 |
|
|
| 460 |
0 |
int min = col - 1, max = col + 1; |
| 461 |
0 |
while (contains(min)) |
| 462 |
|
{ |
| 463 |
0 |
removeElement(min); |
| 464 |
0 |
min--; |
| 465 |
|
} |
| 466 |
|
|
| 467 |
0 |
while (contains(max)) |
| 468 |
|
{ |
| 469 |
0 |
removeElement(max); |
| 470 |
0 |
max++; |
| 471 |
|
} |
| 472 |
|
|
| 473 |
|
|
| 474 |
|
|
| 475 |
|
|
| 476 |
0 |
min++; |
| 477 |
0 |
max--; |
| 478 |
0 |
if (min > max) |
| 479 |
|
{ |
| 480 |
0 |
min = max; |
| 481 |
|
} |
| 482 |
|
|
| 483 |
0 |
hidden.hideColumns(min, max); |
| 484 |
|
} |
| 485 |
|
|
| 486 |
|
|
| 487 |
|
|
| 488 |
|
|
| 489 |
|
@param |
| 490 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 491 |
0 |
public ColumnSelection(ColumnSelection copy)... |
| 492 |
|
{ |
| 493 |
0 |
if (copy != null) |
| 494 |
|
{ |
| 495 |
0 |
selection = new IntList(copy.selection); |
| 496 |
|
} |
| 497 |
|
} |
| 498 |
|
|
| 499 |
|
|
| 500 |
|
|
| 501 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 502 |
0 |
public ColumnSelection()... |
| 503 |
|
{ |
| 504 |
|
} |
| 505 |
|
|
| 506 |
|
|
| 507 |
|
|
| 508 |
|
|
| 509 |
|
|
| 510 |
|
@param |
| 511 |
|
@param |
| 512 |
|
|
| |
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 5 |
Complexity Density: 0.83 |
|
| 513 |
0 |
public void invertColumnSelection(int first, int width, AlignmentI al)... |
| 514 |
|
{ |
| 515 |
0 |
boolean hasHidden = al.getHiddenColumns().hasHiddenColumns(); |
| 516 |
0 |
for (int i = first; i < width; i++) |
| 517 |
|
{ |
| 518 |
0 |
if (contains(i)) |
| 519 |
|
{ |
| 520 |
0 |
removeElement(i); |
| 521 |
|
} |
| 522 |
|
else |
| 523 |
|
{ |
| 524 |
0 |
if (!hasHidden || al.getHiddenColumns().isVisible(i)) |
| 525 |
|
{ |
| 526 |
0 |
addElement(i); |
| 527 |
|
} |
| 528 |
|
} |
| 529 |
|
} |
| 530 |
|
} |
| 531 |
|
|
| 532 |
|
|
| 533 |
|
|
| 534 |
|
|
| 535 |
|
|
| 536 |
|
@param |
| 537 |
|
|
| |
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 6 |
Complexity Density: 0.75 |
|
| 538 |
0 |
public void setElementsFrom(ColumnSelection colsel,... |
| 539 |
|
HiddenColumns hiddenColumns) |
| 540 |
|
{ |
| 541 |
0 |
selection = new IntList(); |
| 542 |
0 |
if (colsel.selection != null && colsel.selection.size() > 0) |
| 543 |
|
{ |
| 544 |
0 |
if (hiddenColumns.hasHiddenColumns()) |
| 545 |
|
{ |
| 546 |
|
|
| 547 |
0 |
for (Integer col : colsel.getSelected()) |
| 548 |
|
{ |
| 549 |
0 |
if (hiddenColumns != null |
| 550 |
|
&& hiddenColumns.isVisible(col.intValue())) |
| 551 |
|
{ |
| 552 |
0 |
selection.add(col); |
| 553 |
|
} |
| 554 |
|
} |
| 555 |
|
} |
| 556 |
|
else |
| 557 |
|
{ |
| 558 |
|
|
| 559 |
0 |
for (Integer col : colsel.getSelected()) |
| 560 |
|
{ |
| 561 |
0 |
addElement(col); |
| 562 |
|
} |
| 563 |
|
} |
| 564 |
|
} |
| 565 |
|
} |
| 566 |
|
|
| 567 |
|
|
| 568 |
|
|
| 569 |
|
@return |
| 570 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 571 |
0 |
public boolean hasSelectedColumns()... |
| 572 |
|
{ |
| 573 |
0 |
return (selection != null && selection.size() > 0); |
| 574 |
|
} |
| 575 |
|
|
| 576 |
|
|
| 577 |
|
|
| 578 |
|
|
| 579 |
|
|
| 580 |
|
|
| 581 |
|
@param |
| 582 |
|
@param |
| 583 |
|
@return |
| 584 |
|
|
| |
|
| 0% |
Uncovered Elements: 92 (92) |
Complexity: 35 |
Complexity Density: 0.7 |
|
| 585 |
0 |
public int filterAnnotations(AlignmentAnnotation ann_row,... |
| 586 |
|
AnnotationFilterParameter filterParams) |
| 587 |
|
{ |
| 588 |
0 |
Annotation[] annotations = ann_row.annotations; |
| 589 |
|
|
| 590 |
|
|
| 591 |
0 |
this.clear(); |
| 592 |
|
|
| 593 |
0 |
if (ann_row.graph == AlignmentAnnotation.CONTACT_MAP && (filterParams |
| 594 |
|
.getThresholdType() == AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD |
| 595 |
|
|| filterParams |
| 596 |
|
.getThresholdType() == AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD)) |
| 597 |
|
{ |
| 598 |
0 |
float tVal = filterParams.getThresholdValue(); |
| 599 |
0 |
if (ann_row.sequenceRef != null) |
| 600 |
|
{ |
| 601 |
|
|
| 602 |
0 |
for (int column = 0; column < annotations.length; column++) |
| 603 |
|
{ |
| 604 |
0 |
if (ann_row.annotations[column] == null) |
| 605 |
|
{ |
| 606 |
0 |
continue; |
| 607 |
|
} |
| 608 |
|
|
| 609 |
0 |
int cpos = ann_row.sequenceRef.findPosition(column) - 1; |
| 610 |
0 |
ContactListI clist = ann_row.sequenceRef |
| 611 |
|
.getContactListFor(ann_row, cpos); |
| 612 |
0 |
for (int row = column + 8, rowEnd = clist |
| 613 |
0 |
.getContactHeight(); row < rowEnd; row++) |
| 614 |
|
{ |
| 615 |
0 |
if (filterParams |
| 616 |
|
.getThresholdType() == AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD |
| 617 |
|
? (clist.getContactAt(row) > tVal) |
| 618 |
|
: (clist.getContactAt(row) < tVal)) |
| 619 |
|
{ |
| 620 |
0 |
addElement(column); |
| 621 |
0 |
break; |
| 622 |
|
|
| 623 |
|
|
| 624 |
|
} |
| 625 |
|
} |
| 626 |
|
} |
| 627 |
|
} |
| 628 |
0 |
return selection.size(); |
| 629 |
|
} |
| 630 |
|
|
| 631 |
0 |
int addedCount = 0; |
| 632 |
0 |
int column = 0; |
| 633 |
0 |
do |
| 634 |
|
{ |
| 635 |
0 |
Annotation ann = annotations[column]; |
| 636 |
0 |
if (ann != null) |
| 637 |
|
{ |
| 638 |
0 |
float value = ann.value; |
| 639 |
0 |
boolean matched = false; |
| 640 |
|
|
| 641 |
|
|
| 642 |
|
|
| 643 |
|
|
| 644 |
|
|
| 645 |
0 |
if (filterParams |
| 646 |
|
.getThresholdType() == AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD |
| 647 |
|
&& value > filterParams.getThresholdValue()) |
| 648 |
|
{ |
| 649 |
0 |
matched = true; |
| 650 |
|
} |
| 651 |
|
|
| 652 |
0 |
if (!matched && filterParams |
| 653 |
|
.getThresholdType() == AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD |
| 654 |
|
&& value < filterParams.getThresholdValue()) |
| 655 |
|
{ |
| 656 |
0 |
matched = true; |
| 657 |
|
} |
| 658 |
|
|
| 659 |
0 |
if (!matched && filterParams.isFilterAlphaHelix() |
| 660 |
|
&& ann.secondaryStructure == 'H') |
| 661 |
|
{ |
| 662 |
0 |
matched = true; |
| 663 |
|
} |
| 664 |
|
|
| 665 |
0 |
if (!matched && filterParams.isFilterBetaSheet() |
| 666 |
|
&& ann.secondaryStructure == 'E') |
| 667 |
|
{ |
| 668 |
0 |
matched = true; |
| 669 |
|
} |
| 670 |
|
|
| 671 |
0 |
if (!matched && filterParams.isFilterTurn() |
| 672 |
|
&& ann.secondaryStructure == 'S') |
| 673 |
|
{ |
| 674 |
0 |
matched = true; |
| 675 |
|
} |
| 676 |
|
|
| 677 |
0 |
String regexSearchString = filterParams.getRegexString(); |
| 678 |
0 |
if (!matched && regexSearchString != null) |
| 679 |
|
{ |
| 680 |
0 |
List<SearchableAnnotationField> fields = filterParams |
| 681 |
|
.getRegexSearchFields(); |
| 682 |
0 |
for (SearchableAnnotationField field : fields) |
| 683 |
|
{ |
| 684 |
0 |
String compareTo = field == SearchableAnnotationField.DISPLAY_STRING |
| 685 |
|
? ann.displayCharacter |
| 686 |
|
: ann.description; |
| 687 |
0 |
if (compareTo != null) |
| 688 |
|
{ |
| 689 |
0 |
try |
| 690 |
|
{ |
| 691 |
0 |
if (compareTo.matches(regexSearchString)) |
| 692 |
|
{ |
| 693 |
0 |
matched = true; |
| 694 |
|
} |
| 695 |
|
} catch (PatternSyntaxException pse) |
| 696 |
|
{ |
| 697 |
0 |
if (compareTo.equals(regexSearchString)) |
| 698 |
|
{ |
| 699 |
0 |
matched = true; |
| 700 |
|
} |
| 701 |
|
} |
| 702 |
0 |
if (matched) |
| 703 |
|
{ |
| 704 |
0 |
break; |
| 705 |
|
} |
| 706 |
|
} |
| 707 |
|
} |
| 708 |
|
} |
| 709 |
|
|
| 710 |
0 |
if (matched) |
| 711 |
|
{ |
| 712 |
0 |
this.addElement(column); |
| 713 |
0 |
addedCount++; |
| 714 |
|
} |
| 715 |
|
} |
| 716 |
0 |
column++; |
| 717 |
0 |
} while (column < annotations.length); |
| 718 |
|
|
| 719 |
0 |
return addedCount; |
| 720 |
|
} |
| 721 |
|
|
| 722 |
|
|
| 723 |
|
|
| 724 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 725 |
0 |
@Override... |
| 726 |
|
public int hashCode() |
| 727 |
|
{ |
| 728 |
0 |
return selection.hashCode(); |
| 729 |
|
} |
| 730 |
|
|
| 731 |
|
|
| 732 |
|
|
| 733 |
|
|
| 734 |
|
|
| |
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.56 |
|
| 735 |
0 |
@Override... |
| 736 |
|
public boolean equals(Object obj) |
| 737 |
|
{ |
| 738 |
0 |
if (!(obj instanceof ColumnSelection)) |
| 739 |
|
{ |
| 740 |
0 |
return false; |
| 741 |
|
} |
| 742 |
0 |
ColumnSelection that = (ColumnSelection) obj; |
| 743 |
|
|
| 744 |
|
|
| 745 |
|
|
| 746 |
|
|
| 747 |
0 |
if (this.selection == null) |
| 748 |
|
{ |
| 749 |
0 |
if (that.selection != null) |
| 750 |
|
{ |
| 751 |
0 |
return false; |
| 752 |
|
} |
| 753 |
|
} |
| 754 |
0 |
if (!this.selection.equals(that.selection)) |
| 755 |
|
{ |
| 756 |
0 |
return false; |
| 757 |
|
} |
| 758 |
|
|
| 759 |
0 |
return true; |
| 760 |
|
} |
| 761 |
|
|
| 762 |
|
|
| 763 |
|
|
| 764 |
|
|
| 765 |
|
|
| 766 |
|
@param |
| 767 |
|
|
| 768 |
|
@param |
| 769 |
|
|
| 770 |
|
@param |
| 771 |
|
|
| 772 |
|
@param |
| 773 |
|
|
| 774 |
|
@param |
| 775 |
|
|
| 776 |
|
@param |
| 777 |
|
|
| 778 |
|
|
| 779 |
|
@return |
| 780 |
|
|
| |
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 14 |
Complexity Density: 0.61 |
|
| 781 |
0 |
public boolean markColumns(BitSet markedColumns, int startCol, int endCol,... |
| 782 |
|
boolean invert, boolean extendCurrent, boolean toggle) |
| 783 |
|
{ |
| 784 |
0 |
boolean changed = false; |
| 785 |
0 |
if (!extendCurrent && !toggle) |
| 786 |
|
{ |
| 787 |
0 |
changed = !this.isEmpty(); |
| 788 |
0 |
clear(); |
| 789 |
|
} |
| 790 |
0 |
if (invert) |
| 791 |
|
{ |
| 792 |
|
|
| 793 |
0 |
int i = markedColumns.nextClearBit(startCol); |
| 794 |
0 |
int ibs = markedColumns.nextSetBit(startCol); |
| 795 |
0 |
while (i >= startCol && i <= endCol) |
| 796 |
|
{ |
| 797 |
0 |
if (ibs < 0 || i < ibs) |
| 798 |
|
{ |
| 799 |
0 |
changed = true; |
| 800 |
0 |
if (toggle && contains(i)) |
| 801 |
|
{ |
| 802 |
0 |
removeElement(i++); |
| 803 |
|
} |
| 804 |
|
else |
| 805 |
|
{ |
| 806 |
0 |
addElement(i++); |
| 807 |
|
} |
| 808 |
|
} |
| 809 |
|
else |
| 810 |
|
{ |
| 811 |
0 |
i = markedColumns.nextClearBit(ibs); |
| 812 |
0 |
ibs = markedColumns.nextSetBit(i); |
| 813 |
|
} |
| 814 |
|
} |
| 815 |
|
} |
| 816 |
|
else |
| 817 |
|
{ |
| 818 |
0 |
int i = markedColumns.nextSetBit(startCol); |
| 819 |
0 |
while (i >= startCol && i <= endCol) |
| 820 |
|
{ |
| 821 |
0 |
changed = true; |
| 822 |
0 |
if (toggle && contains(i)) |
| 823 |
|
{ |
| 824 |
0 |
removeElement(i); |
| 825 |
|
} |
| 826 |
|
else |
| 827 |
|
{ |
| 828 |
0 |
addElement(i); |
| 829 |
|
} |
| 830 |
0 |
i = markedColumns.nextSetBit(i + 1); |
| 831 |
|
} |
| 832 |
|
} |
| 833 |
0 |
return changed; |
| 834 |
|
} |
| 835 |
|
|
| 836 |
|
|
| 837 |
|
|
| 838 |
|
|
| 839 |
|
|
| 840 |
|
|
| 841 |
|
|
| 842 |
|
@param |
| 843 |
|
|
| 844 |
|
@param |
| 845 |
|
|
| 846 |
|
@param |
| 847 |
|
|
| 848 |
|
@param |
| 849 |
|
|
| 850 |
|
|
| |
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 7 |
Complexity Density: 0.7 |
|
| 851 |
0 |
public void stretchGroup(int res, SequenceGroup sg, int min, int max)... |
| 852 |
|
{ |
| 853 |
0 |
if (!contains(res)) |
| 854 |
|
{ |
| 855 |
0 |
addElement(res); |
| 856 |
|
} |
| 857 |
|
|
| 858 |
0 |
if (res > sg.getStartRes()) |
| 859 |
|
{ |
| 860 |
|
|
| 861 |
0 |
sg.setEndRes(res); |
| 862 |
|
} |
| 863 |
0 |
if (res < sg.getStartRes()) |
| 864 |
|
{ |
| 865 |
|
|
| 866 |
0 |
sg.setStartRes(res); |
| 867 |
|
} |
| 868 |
|
|
| 869 |
|
|
| 870 |
|
|
| 871 |
|
|
| 872 |
|
|
| 873 |
0 |
for (int col = min; col <= max; col++) |
| 874 |
|
{ |
| 875 |
0 |
if (col < sg.getStartRes() || col > sg.getEndRes()) |
| 876 |
|
{ |
| 877 |
|
|
| 878 |
0 |
removeElement(col); |
| 879 |
|
} |
| 880 |
|
else |
| 881 |
|
{ |
| 882 |
|
|
| 883 |
0 |
addElement(col); |
| 884 |
|
} |
| 885 |
|
} |
| 886 |
|
} |
| 887 |
|
} |