| 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.Iterator; |
| 24 |
|
|
| |
|
| 48.5% |
Uncovered Elements: 101 (196) |
Complexity: 50 |
Complexity Density: 0.4 |
|
| 25 |
|
public class CigarArray extends CigarBase |
| 26 |
|
{ |
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
public CigarSimple refCigars[] = null; |
| 36 |
|
|
| 37 |
|
private boolean seqcigararray = false; |
| 38 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 39 |
0 |
private CigarArray()... |
| 40 |
|
{ |
| 41 |
0 |
super(); |
| 42 |
|
} |
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
@return |
| 48 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 49 |
156 |
public boolean isSeqCigarArray()... |
| 50 |
|
{ |
| 51 |
156 |
return seqcigararray; |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
@param |
| 59 |
|
|
| 60 |
|
|
| |
|
| 78.6% |
Uncovered Elements: 3 (14) |
Complexity: 6 |
Complexity Density: 0.75 |
|
| 61 |
90 |
public CigarArray(CigarSimple[] cigars)... |
| 62 |
|
{ |
| 63 |
90 |
super(); |
| 64 |
90 |
seqcigararray = true; |
| 65 |
90 |
if (cigars != null && cigars.length > 0) |
| 66 |
|
{ |
| 67 |
90 |
refCigars = new CigarSimple[cigars.length]; |
| 68 |
344 |
for (int c = 0; c < cigars.length; c++) |
| 69 |
|
{ |
| 70 |
254 |
refCigars[c] = cigars[c]; |
| 71 |
254 |
if (!((cigars[c] instanceof SeqCigar) |
| 72 |
|
|| cigars[c] instanceof CigarCigar)) |
| 73 |
|
{ |
| 74 |
0 |
seqcigararray = false; |
| 75 |
|
} |
| 76 |
|
} |
| 77 |
|
} |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
@param |
| 86 |
|
@param |
| 87 |
|
@param |
| 88 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 89 |
89 |
public CigarArray(AlignmentI alignment, HiddenColumns hidden,... |
| 90 |
|
SequenceGroup selectionGroup) |
| 91 |
|
{ |
| 92 |
89 |
this(constructSeqCigarArray(alignment, selectionGroup)); |
| 93 |
89 |
constructFromAlignment(alignment, hidden, selectionGroup); |
| 94 |
|
} |
| 95 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 96 |
178 |
private static int[] _calcStartEndBounds(AlignmentI alignment,... |
| 97 |
|
SequenceGroup selectionGroup) |
| 98 |
|
{ |
| 99 |
178 |
int[] startend = new int[] { 0, 0, 0 }; |
| 100 |
178 |
if (selectionGroup != null) |
| 101 |
|
{ |
| 102 |
38 |
startend[0] = selectionGroup.getSize(); |
| 103 |
38 |
startend[1] = selectionGroup.getStartRes(); |
| 104 |
38 |
startend[2] = selectionGroup.getEndRes(); |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
} |
| 108 |
|
else |
| 109 |
|
{ |
| 110 |
140 |
startend[0] = alignment.getHeight(); |
| 111 |
140 |
startend[2] = alignment.getWidth() - 1; |
| 112 |
|
} |
| 113 |
178 |
return startend; |
| 114 |
|
} |
| 115 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 3 |
Complexity Density: 0.19 |
|
| 116 |
89 |
public static SeqCigar[] constructSeqCigarArray(AlignmentI alignment,... |
| 117 |
|
SequenceGroup selectionGroup) |
| 118 |
|
{ |
| 119 |
89 |
SequenceI[] seqs = null; |
| 120 |
89 |
int i, iSize; |
| 121 |
89 |
int _startend[] = _calcStartEndBounds(alignment, selectionGroup); |
| 122 |
89 |
int start = _startend[1], end = _startend[2]; |
| 123 |
89 |
if (selectionGroup != null) |
| 124 |
|
{ |
| 125 |
19 |
iSize = selectionGroup.getSize(); |
| 126 |
19 |
seqs = selectionGroup.getSequencesInOrder(alignment); |
| 127 |
19 |
start = selectionGroup.getStartRes(); |
| 128 |
19 |
end = selectionGroup.getEndRes(); |
| 129 |
|
|
| 130 |
|
} |
| 131 |
|
else |
| 132 |
|
{ |
| 133 |
70 |
iSize = alignment.getHeight(); |
| 134 |
70 |
seqs = alignment.getSequencesArray(); |
| 135 |
70 |
end = alignment.getWidth() - 1; |
| 136 |
|
} |
| 137 |
89 |
SeqCigar[] selseqs = new SeqCigar[iSize]; |
| 138 |
342 |
for (i = 0; i < iSize; i++) |
| 139 |
|
{ |
| 140 |
253 |
selseqs[i] = new SeqCigar(seqs[i], start, end); |
| 141 |
|
} |
| 142 |
89 |
return selseqs; |
| 143 |
|
} |
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
@param |
| 149 |
|
@param |
| 150 |
|
|
| 151 |
|
|
| 152 |
|
@param |
| 153 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (36) |
Complexity: 8 |
Complexity Density: 0.33 |
|
| 154 |
89 |
private void constructFromAlignment(AlignmentI alignment,... |
| 155 |
|
HiddenColumns hidden, SequenceGroup selectionGroup) |
| 156 |
|
{ |
| 157 |
89 |
int[] _startend = _calcStartEndBounds(alignment, selectionGroup); |
| 158 |
89 |
int start = _startend[1]; |
| 159 |
89 |
int end = _startend[2]; |
| 160 |
|
|
| 161 |
89 |
if (hidden != null) |
| 162 |
|
{ |
| 163 |
29 |
int[] region; |
| 164 |
29 |
int hideStart; |
| 165 |
29 |
int hideEnd; |
| 166 |
29 |
int last = start; |
| 167 |
|
|
| 168 |
29 |
Iterator<int[]> regions = hidden.getBoundedIterator(start, end); |
| 169 |
75 |
while (regions.hasNext()) |
| 170 |
|
{ |
| 171 |
46 |
region = regions.next(); |
| 172 |
46 |
hideStart = region[0]; |
| 173 |
46 |
hideEnd = region[1]; |
| 174 |
|
|
| 175 |
|
|
| 176 |
46 |
if ((hideStart < last) && (hideEnd >= last)) |
| 177 |
|
{ |
| 178 |
8 |
hideStart = last; |
| 179 |
|
} |
| 180 |
|
|
| 181 |
|
|
| 182 |
46 |
if (hideEnd > end) |
| 183 |
|
{ |
| 184 |
2 |
hideEnd = end; |
| 185 |
|
} |
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
|
| 190 |
46 |
if (last < hideStart) |
| 191 |
|
{ |
| 192 |
27 |
addOperation(CigarArray.M, hideStart - last); |
| 193 |
|
} |
| 194 |
46 |
addOperation(CigarArray.D, 1 + hideEnd - hideStart); |
| 195 |
46 |
last = hideEnd + 1; |
| 196 |
|
} |
| 197 |
|
|
| 198 |
|
|
| 199 |
29 |
if (last <= end) |
| 200 |
|
{ |
| 201 |
20 |
addOperation(CigarArray.M, end - last + 1); |
| 202 |
|
} |
| 203 |
|
} |
| 204 |
|
else |
| 205 |
|
{ |
| 206 |
60 |
addOperation(CigarArray.M, end - start + 1); |
| 207 |
|
} |
| 208 |
|
} |
| 209 |
|
|
| 210 |
|
|
| 211 |
|
@see |
| 212 |
|
@param |
| 213 |
|
|
| 214 |
|
@return |
| 215 |
|
|
| |
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 6 |
Complexity Density: 0.67 |
|
| 216 |
0 |
protected Object[][] getArrayofSequenceAndDeletions(char GapChar)... |
| 217 |
|
{ |
| 218 |
0 |
if (refCigars == null || refCigars.length == 0 || length == 0) |
| 219 |
|
{ |
| 220 |
0 |
return null; |
| 221 |
|
} |
| 222 |
0 |
Object[][] sqanddels = new Object[refCigars.length][]; |
| 223 |
0 |
for (int c = 0; c < refCigars.length; c++) |
| 224 |
|
{ |
| 225 |
0 |
String refString = refCigars[c].getSequenceString(GapChar); |
| 226 |
0 |
if (refString != null) |
| 227 |
|
{ |
| 228 |
0 |
sqanddels[c] = getSequenceAndDeletions(refString, GapChar); |
| 229 |
|
} |
| 230 |
|
else |
| 231 |
|
{ |
| 232 |
0 |
sqanddels[c] = null; |
| 233 |
|
} |
| 234 |
|
} |
| 235 |
0 |
return sqanddels; |
| 236 |
|
} |
| 237 |
|
|
| 238 |
|
|
| 239 |
|
|
| 240 |
|
|
| 241 |
|
@return |
| 242 |
|
|
| 243 |
|
@param |
| 244 |
|
|
| 245 |
|
@return |
| 246 |
|
|
| |
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
| 247 |
0 |
public String getSequenceString(char GapChar)... |
| 248 |
|
{ |
| 249 |
0 |
if (length == 0 || refCigars == null) |
| 250 |
|
{ |
| 251 |
0 |
return ""; |
| 252 |
|
} |
| 253 |
0 |
StringBuffer seqStrings = new StringBuffer(); |
| 254 |
0 |
Object[][] sqanddels = getArrayofSequenceAndDeletions(GapChar); |
| 255 |
0 |
for (int c = 0; c < refCigars.length; c++) |
| 256 |
|
{ |
| 257 |
0 |
if (sqanddels[c] != null) |
| 258 |
|
{ |
| 259 |
0 |
seqStrings.append((String) sqanddels[c][0]); |
| 260 |
0 |
sqanddels[c][0] = null; |
| 261 |
|
} |
| 262 |
0 |
seqStrings.append('\n'); |
| 263 |
|
} |
| 264 |
0 |
return seqStrings.toString(); |
| 265 |
|
} |
| 266 |
|
|
| 267 |
|
|
| 268 |
|
|
| 269 |
|
|
| 270 |
|
@param |
| 271 |
|
|
| 272 |
|
@return |
| 273 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 5 |
Complexity Density: 0.71 |
|
| 274 |
0 |
public String[] getSequenceStrings(char GapChar)... |
| 275 |
|
{ |
| 276 |
|
|
| 277 |
0 |
if (length == 0 || refCigars == null || refCigars.length == 0) |
| 278 |
|
{ |
| 279 |
0 |
return null; |
| 280 |
|
} |
| 281 |
0 |
Object[][] sqanddels = getArrayofSequenceAndDeletions(GapChar); |
| 282 |
0 |
String[] seqs = new String[sqanddels.length]; |
| 283 |
0 |
for (int c = 0; c < refCigars.length; c++) |
| 284 |
|
{ |
| 285 |
0 |
seqs[c] = (String) sqanddels[c][0]; |
| 286 |
|
} |
| 287 |
0 |
return seqs; |
| 288 |
|
} |
| 289 |
|
|
| 290 |
|
|
| 291 |
|
|
| 292 |
|
|
| 293 |
|
|
| 294 |
|
@return |
| 295 |
|
|
| 296 |
|
|
| 297 |
|
|
| 298 |
|
|
| 299 |
|
|
| 300 |
|
|
| 301 |
|
|
| 302 |
|
|
| 303 |
|
|
| 304 |
|
@return |
| 305 |
|
|
| 306 |
|
|
| |
|
| 0% |
Uncovered Elements: 48 (48) |
Complexity: 9 |
Complexity Density: 0.28 |
|
| 307 |
0 |
public int[] applyDeletions()... |
| 308 |
|
{ |
| 309 |
0 |
java.util.Vector delpos = null; |
| 310 |
0 |
if (length == 0) |
| 311 |
|
{ |
| 312 |
0 |
return null; |
| 313 |
|
} |
| 314 |
0 |
int cursor = 0; |
| 315 |
0 |
int vcursor = 0; |
| 316 |
0 |
int offset = 0; |
| 317 |
0 |
int i = 0; |
| 318 |
0 |
while (i < length) |
| 319 |
|
{ |
| 320 |
0 |
if (operation[i] != D) |
| 321 |
|
{ |
| 322 |
0 |
if (operation[i] == M) |
| 323 |
|
{ |
| 324 |
0 |
cursor += range[i]; |
| 325 |
|
} |
| 326 |
0 |
vcursor += range[i++]; |
| 327 |
|
} |
| 328 |
|
else |
| 329 |
|
{ |
| 330 |
0 |
if (delpos == null) |
| 331 |
|
{ |
| 332 |
0 |
delpos = new java.util.Vector(); |
| 333 |
|
} |
| 334 |
0 |
int delstart = cursor, delend = cursor + range[i] - 1; |
| 335 |
0 |
delpos.addElement(new int[] { vcursor + offset, range[i] }); |
| 336 |
|
|
| 337 |
|
|
| 338 |
|
|
| 339 |
|
|
| 340 |
|
|
| 341 |
0 |
offset += range[i] - 1; |
| 342 |
0 |
System.arraycopy(operation, i + 1, operation, i, length - i); |
| 343 |
0 |
System.arraycopy(range, i + 1, range, i, length - i); |
| 344 |
0 |
length--; |
| 345 |
|
|
| 346 |
|
|
| 347 |
|
|
| 348 |
|
|
| 349 |
|
|
| 350 |
0 |
for (int s = 0; s < refCigars.length; s++) |
| 351 |
|
{ |
| 352 |
0 |
int d = refCigars[s].deleteRange(delstart, delend); |
| 353 |
|
} |
| 354 |
|
|
| 355 |
|
} |
| 356 |
|
} |
| 357 |
0 |
if (delpos != null) |
| 358 |
|
{ |
| 359 |
0 |
int[] pos = new int[delpos.size() * 2]; |
| 360 |
0 |
for (int k = 0, l = delpos.size(); k < l; k++) |
| 361 |
|
{ |
| 362 |
0 |
int[] dr = ((int[]) delpos.elementAt(k)); |
| 363 |
0 |
pos[k * 2] = dr[0]; |
| 364 |
0 |
pos[k * 2 + 1] = dr[1]; |
| 365 |
0 |
delpos.setElementAt(null, k); |
| 366 |
|
} |
| 367 |
0 |
delpos = null; |
| 368 |
0 |
return pos; |
| 369 |
|
} |
| 370 |
0 |
return null; |
| 371 |
|
} |
| 372 |
|
|
| 373 |
|
|
| 374 |
|
|
| 375 |
|
@return |
| 376 |
|
|
| 377 |
|
|
| |
|
| 80% |
Uncovered Elements: 2 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 378 |
78 |
public SeqCigar[] getSeqCigarArray()... |
| 379 |
|
{ |
| 380 |
78 |
if (!isSeqCigarArray()) |
| 381 |
|
{ |
| 382 |
0 |
return null; |
| 383 |
|
} |
| 384 |
78 |
SeqCigar[] sa = new SeqCigar[refCigars.length]; |
| 385 |
320 |
for (int i = 0; i < refCigars.length; i++) |
| 386 |
|
{ |
| 387 |
242 |
sa[i] = (SeqCigar) refCigars[i]; |
| 388 |
|
} |
| 389 |
78 |
return sa; |
| 390 |
|
} |
| 391 |
|
} |