| 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.List; |
| 25 |
|
import java.util.Map; |
| 26 |
|
|
| |
|
| 0% |
Uncovered Elements: 219 (219) |
Complexity: 59 |
Complexity Density: 0.45 |
|
| 27 |
|
public class HiddenSequences |
| 28 |
|
{ |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
public SequenceI[] hiddenSequences; |
| 33 |
|
|
| 34 |
|
AlignmentI alignment; |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
@param |
| 40 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 41 |
0 |
public HiddenSequences(AlignmentI al)... |
| 42 |
|
{ |
| 43 |
0 |
alignment = al; |
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
@return |
| 50 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 51 |
0 |
public int getSize()... |
| 52 |
|
{ |
| 53 |
0 |
if (hiddenSequences == null) |
| 54 |
|
{ |
| 55 |
0 |
return 0; |
| 56 |
|
} |
| 57 |
0 |
int count = 0; |
| 58 |
0 |
for (SequenceI seq : hiddenSequences) |
| 59 |
|
{ |
| 60 |
0 |
if (seq != null) |
| 61 |
|
{ |
| 62 |
0 |
count++; |
| 63 |
|
} |
| 64 |
|
} |
| 65 |
|
|
| 66 |
0 |
return count; |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
@return |
| 73 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 74 |
0 |
public int getWidth()... |
| 75 |
|
{ |
| 76 |
0 |
if (hiddenSequences == null) |
| 77 |
|
{ |
| 78 |
0 |
return 0; |
| 79 |
|
} |
| 80 |
0 |
int width = 0; |
| 81 |
0 |
for (SequenceI seq : hiddenSequences) |
| 82 |
|
{ |
| 83 |
0 |
if (seq != null && seq.getLength() > width) |
| 84 |
|
{ |
| 85 |
0 |
width = seq.getLength(); |
| 86 |
|
} |
| 87 |
|
} |
| 88 |
|
|
| 89 |
0 |
return width; |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| |
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.42 |
|
| 95 |
0 |
public void adjustHeightSequenceDeleted(int seqIndex)... |
| 96 |
|
{ |
| 97 |
0 |
if (hiddenSequences == null) |
| 98 |
|
{ |
| 99 |
0 |
return; |
| 100 |
|
} |
| 101 |
|
|
| 102 |
0 |
int alHeight = alignment.getHeight(); |
| 103 |
|
|
| 104 |
0 |
SequenceI[] tmp = new SequenceI[alHeight + getSize()]; |
| 105 |
0 |
int deletionIndex = adjustForHiddenSeqs(seqIndex); |
| 106 |
|
|
| 107 |
0 |
for (int i = 0; i < hiddenSequences.length; i++) |
| 108 |
|
{ |
| 109 |
0 |
if (hiddenSequences[i] == null) |
| 110 |
|
{ |
| 111 |
0 |
continue; |
| 112 |
|
} |
| 113 |
|
|
| 114 |
0 |
if (i > deletionIndex) |
| 115 |
|
{ |
| 116 |
0 |
tmp[i - 1] = hiddenSequences[i]; |
| 117 |
|
} |
| 118 |
|
else |
| 119 |
|
{ |
| 120 |
0 |
tmp[i] = hiddenSequences[i]; |
| 121 |
|
} |
| 122 |
|
} |
| 123 |
|
|
| 124 |
0 |
hiddenSequences = tmp; |
| 125 |
|
|
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 131 |
0 |
public void adjustHeightSequenceAdded()... |
| 132 |
|
{ |
| 133 |
0 |
if (hiddenSequences == null) |
| 134 |
|
{ |
| 135 |
0 |
return; |
| 136 |
|
} |
| 137 |
|
|
| 138 |
0 |
int alHeight = alignment.getHeight(); |
| 139 |
|
|
| 140 |
0 |
SequenceI[] tmp = new SequenceI[alHeight + getSize()]; |
| 141 |
0 |
System.arraycopy(hiddenSequences, 0, tmp, 0, hiddenSequences.length); |
| 142 |
0 |
hiddenSequences = tmp; |
| 143 |
|
} |
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
@param |
| 149 |
|
|
| |
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 150 |
0 |
public void hideSequence(SequenceI sequence)... |
| 151 |
|
{ |
| 152 |
0 |
if (hiddenSequences == null) |
| 153 |
|
{ |
| 154 |
0 |
hiddenSequences = new SequenceI[alignment.getHeight()]; |
| 155 |
|
} |
| 156 |
|
|
| 157 |
0 |
int absAlignmentIndex = alignment.findIndex(sequence); |
| 158 |
0 |
int alignmentIndex = adjustForHiddenSeqs(absAlignmentIndex); |
| 159 |
|
|
| 160 |
0 |
if (alignmentIndex < 0 || hiddenSequences[alignmentIndex] != null) |
| 161 |
|
{ |
| 162 |
0 |
jalview.bin.Console.outPrintln("ERROR!!!!!!!!!!!"); |
| 163 |
0 |
return; |
| 164 |
|
} |
| 165 |
|
|
| 166 |
0 |
hiddenSequences[alignmentIndex] = sequence; |
| 167 |
|
|
| 168 |
0 |
alignment.deleteHiddenSequence(absAlignmentIndex); |
| 169 |
|
} |
| 170 |
|
|
| |
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 171 |
0 |
public List<SequenceI> showAll(... |
| 172 |
|
Map<SequenceI, SequenceCollectionI> hiddenRepSequences) |
| 173 |
|
{ |
| 174 |
0 |
List<SequenceI> revealedSeqs = new ArrayList<>(); |
| 175 |
|
|
| 176 |
0 |
if (hiddenSequences == null) |
| 177 |
|
{ |
| 178 |
0 |
return revealedSeqs; |
| 179 |
|
} |
| 180 |
|
|
| 181 |
0 |
for (int i = 0; i < hiddenSequences.length; i++) |
| 182 |
|
{ |
| 183 |
0 |
if (hiddenSequences[i] != null) |
| 184 |
|
{ |
| 185 |
0 |
List<SequenceI> tmp = showSequence(i, hiddenRepSequences); |
| 186 |
0 |
for (SequenceI seq : tmp) |
| 187 |
|
{ |
| 188 |
0 |
revealedSeqs.add(seq); |
| 189 |
|
} |
| 190 |
|
} |
| 191 |
|
} |
| 192 |
0 |
return revealedSeqs; |
| 193 |
|
} |
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
|
|
| 200 |
|
|
| 201 |
|
@param |
| 202 |
|
@param |
| 203 |
|
|
| 204 |
|
@return |
| 205 |
|
|
| |
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 8 |
Complexity Density: 0.4 |
|
| 206 |
0 |
public List<SequenceI> showSequence(int alignmentIndex,... |
| 207 |
|
Map<SequenceI, SequenceCollectionI> hiddenRepSequences) |
| 208 |
|
{ |
| 209 |
0 |
List<SequenceI> revealedSeqs = new ArrayList<>(); |
| 210 |
0 |
SequenceI repSequence = alignment.getSequenceAt(alignmentIndex); |
| 211 |
0 |
if (repSequence != null && hiddenRepSequences != null |
| 212 |
|
&& hiddenRepSequences.containsKey(repSequence)) |
| 213 |
|
{ |
| 214 |
0 |
hiddenRepSequences.remove(repSequence); |
| 215 |
0 |
revealedSeqs.add(repSequence); |
| 216 |
|
} |
| 217 |
|
|
| 218 |
0 |
int start = adjustForHiddenSeqs(alignmentIndex - 1); |
| 219 |
0 |
int end = adjustForHiddenSeqs(alignmentIndex); |
| 220 |
0 |
if (end >= hiddenSequences.length) |
| 221 |
|
{ |
| 222 |
0 |
end = hiddenSequences.length - 1; |
| 223 |
|
} |
| 224 |
|
|
| 225 |
0 |
List<SequenceI> asequences = alignment.getSequences(); |
| 226 |
0 |
synchronized (asequences) |
| 227 |
|
{ |
| 228 |
0 |
for (int index = end; index > start; index--) |
| 229 |
|
{ |
| 230 |
0 |
SequenceI seq = hiddenSequences[index]; |
| 231 |
0 |
hiddenSequences[index] = null; |
| 232 |
|
|
| 233 |
0 |
if (seq != null) |
| 234 |
|
{ |
| 235 |
0 |
if (seq.getLength() > 0) |
| 236 |
|
{ |
| 237 |
0 |
revealedSeqs.add(seq); |
| 238 |
0 |
asequences.add(alignmentIndex, seq); |
| 239 |
|
} |
| 240 |
|
else |
| 241 |
|
{ |
| 242 |
0 |
jalview.bin.Console.outPrintln( |
| 243 |
|
seq.getName() + " has been deleted whilst hidden"); |
| 244 |
|
} |
| 245 |
|
} |
| 246 |
|
} |
| 247 |
|
} |
| 248 |
0 |
return revealedSeqs; |
| 249 |
|
} |
| 250 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 251 |
0 |
public SequenceI getHiddenSequence(int alignmentIndex)... |
| 252 |
|
{ |
| 253 |
0 |
return hiddenSequences == null ? null : hiddenSequences[alignmentIndex]; |
| 254 |
|
} |
| 255 |
|
|
| 256 |
|
|
| 257 |
|
|
| 258 |
|
|
| 259 |
|
|
| 260 |
|
@param |
| 261 |
|
@return |
| 262 |
|
|
| |
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 5 |
Complexity Density: 0.38 |
|
| 263 |
0 |
public int findIndexWithoutHiddenSeqs(int alignmentIndex)... |
| 264 |
|
{ |
| 265 |
0 |
if (hiddenSequences == null) |
| 266 |
|
{ |
| 267 |
0 |
return alignmentIndex; |
| 268 |
|
} |
| 269 |
0 |
int index = 0; |
| 270 |
0 |
int hiddenSeqs = 0; |
| 271 |
0 |
int diff = 0; |
| 272 |
0 |
if (hiddenSequences.length <= alignmentIndex) |
| 273 |
|
{ |
| 274 |
|
|
| 275 |
|
|
| 276 |
|
|
| 277 |
|
|
| 278 |
0 |
diff = alignmentIndex - hiddenSequences.length + 1; |
| 279 |
0 |
alignmentIndex = hiddenSequences.length - 1; |
| 280 |
|
} |
| 281 |
|
|
| 282 |
0 |
while (index <= alignmentIndex) |
| 283 |
|
{ |
| 284 |
0 |
if (hiddenSequences[index] != null) |
| 285 |
|
{ |
| 286 |
0 |
hiddenSeqs++; |
| 287 |
|
} |
| 288 |
0 |
index++; |
| 289 |
|
} |
| 290 |
|
|
| 291 |
0 |
return (alignmentIndex - hiddenSeqs + diff); |
| 292 |
|
} |
| 293 |
|
|
| 294 |
|
|
| 295 |
|
|
| 296 |
|
|
| 297 |
|
|
| 298 |
|
|
| 299 |
|
@param |
| 300 |
|
|
| 301 |
|
@param |
| 302 |
|
|
| 303 |
|
@return |
| 304 |
|
|
| |
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 5 |
Complexity Density: 0.56 |
|
| 305 |
0 |
public int subtractVisibleRows(int visibleDistance, int startRow)... |
| 306 |
|
{ |
| 307 |
|
|
| 308 |
|
|
| 309 |
|
|
| 310 |
0 |
if (hiddenSequences == null) |
| 311 |
|
{ |
| 312 |
0 |
return startRow - visibleDistance; |
| 313 |
|
} |
| 314 |
|
|
| 315 |
0 |
int index = Math.min(startRow, hiddenSequences.length - 1); |
| 316 |
0 |
int count = 0; |
| 317 |
0 |
while ((index > -1) && (count < visibleDistance)) |
| 318 |
|
{ |
| 319 |
0 |
if (hiddenSequences[index] == null) |
| 320 |
|
{ |
| 321 |
|
|
| 322 |
0 |
count++; |
| 323 |
|
} |
| 324 |
0 |
index--; |
| 325 |
|
} |
| 326 |
0 |
return index; |
| 327 |
|
} |
| 328 |
|
|
| 329 |
|
|
| 330 |
|
|
| 331 |
|
|
| 332 |
|
@param |
| 333 |
|
@return |
| 334 |
|
|
| |
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
| 335 |
0 |
public int adjustForHiddenSeqs(int alignmentIndex)... |
| 336 |
|
{ |
| 337 |
0 |
if (hiddenSequences == null) |
| 338 |
|
{ |
| 339 |
0 |
return alignmentIndex; |
| 340 |
|
} |
| 341 |
0 |
int index = 0; |
| 342 |
0 |
int hSize = hiddenSequences.length; |
| 343 |
0 |
while (index <= alignmentIndex && index < hSize) |
| 344 |
|
{ |
| 345 |
0 |
if (hiddenSequences[index] != null) |
| 346 |
|
{ |
| 347 |
0 |
alignmentIndex++; |
| 348 |
|
} |
| 349 |
0 |
index++; |
| 350 |
|
} |
| 351 |
0 |
; |
| 352 |
|
|
| 353 |
0 |
return alignmentIndex; |
| 354 |
|
} |
| 355 |
|
|
| 356 |
|
|
| 357 |
|
|
| 358 |
|
|
| 359 |
|
|
| 360 |
|
|
| 361 |
|
@return |
| 362 |
|
|
| |
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 4 |
Complexity Density: 0.22 |
|
| 363 |
0 |
public AlignmentI getFullAlignment()... |
| 364 |
|
{ |
| 365 |
0 |
SequenceI[] seq; |
| 366 |
0 |
if (hiddenSequences == null) |
| 367 |
|
{ |
| 368 |
0 |
seq = alignment.getSequencesArray(); |
| 369 |
|
} |
| 370 |
|
else |
| 371 |
|
{ |
| 372 |
0 |
int isize = hiddenSequences.length; |
| 373 |
0 |
seq = new Sequence[isize]; |
| 374 |
|
|
| 375 |
0 |
int index = 0; |
| 376 |
0 |
for (int i = 0; i < hiddenSequences.length; i++) |
| 377 |
|
{ |
| 378 |
0 |
if (hiddenSequences[i] != null) |
| 379 |
|
{ |
| 380 |
0 |
seq[i] = hiddenSequences[i]; |
| 381 |
|
} |
| 382 |
|
else |
| 383 |
|
{ |
| 384 |
0 |
seq[i] = alignment.getSequenceAt(index); |
| 385 |
0 |
index++; |
| 386 |
|
} |
| 387 |
|
} |
| 388 |
|
} |
| 389 |
0 |
Alignment fAlignmt = new Alignment(seq); |
| 390 |
0 |
fAlignmt.annotations = alignment.getAlignmentAnnotation(); |
| 391 |
0 |
fAlignmt.alignmentProperties = alignment.getProperties(); |
| 392 |
0 |
fAlignmt.groups = alignment.getGroups(); |
| 393 |
0 |
fAlignmt.hasRNAStructure = alignment.hasRNAStructure(); |
| 394 |
0 |
fAlignmt.setSeqrep(alignment.getSeqrep()); |
| 395 |
|
|
| 396 |
0 |
return fAlignmt; |
| 397 |
|
} |
| 398 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 5 |
Complexity Density: 1 |
|
| 399 |
0 |
public boolean isHidden(SequenceI seq)... |
| 400 |
|
{ |
| 401 |
0 |
if (hiddenSequences != null) |
| 402 |
|
{ |
| 403 |
0 |
for (int i = 0; i < hiddenSequences.length; i++) |
| 404 |
|
{ |
| 405 |
0 |
if (hiddenSequences[i] != null && hiddenSequences[i] == seq) |
| 406 |
|
{ |
| 407 |
0 |
return true; |
| 408 |
|
} |
| 409 |
|
} |
| 410 |
|
} |
| 411 |
|
|
| 412 |
0 |
return false; |
| 413 |
|
} |
| 414 |
|
|
| 415 |
|
|
| 416 |
|
|
| 417 |
|
|
| 418 |
|
@param |
| 419 |
|
|
| 420 |
|
@return |
| 421 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 422 |
0 |
public boolean isHidden(int seq)... |
| 423 |
|
{ |
| 424 |
0 |
if (hiddenSequences != null) |
| 425 |
|
{ |
| 426 |
0 |
return (hiddenSequences[seq] != null); |
| 427 |
|
} |
| 428 |
0 |
return false; |
| 429 |
|
} |
| 430 |
|
} |