| 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.Locale; |
| 24 |
|
|
| 25 |
|
import jalview.analysis.scoremodels.ScoreMatrix; |
| 26 |
|
import jalview.analysis.scoremodels.ScoreModels; |
| 27 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 28 |
|
import jalview.datamodel.Annotation; |
| 29 |
|
import jalview.datamodel.ResidueCount; |
| 30 |
|
import jalview.datamodel.ResidueCount.SymbolCounts; |
| 31 |
|
import jalview.datamodel.Sequence; |
| 32 |
|
import jalview.datamodel.SequenceI; |
| 33 |
|
import jalview.schemes.ResidueProperties; |
| 34 |
|
import jalview.util.Comparison; |
| 35 |
|
import jalview.util.Format; |
| 36 |
|
|
| 37 |
|
import java.awt.Color; |
| 38 |
|
import java.util.List; |
| 39 |
|
import java.util.Map; |
| 40 |
|
import java.util.Map.Entry; |
| 41 |
|
import java.util.SortedMap; |
| 42 |
|
import java.util.TreeMap; |
| 43 |
|
import java.util.Vector; |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| |
|
| 95.4% |
Uncovered Elements: 19 (414) |
Complexity: 101 |
Complexity Density: 0.4 |
|
| 48 |
|
public class Conservation |
| 49 |
|
{ |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
private static final int THRESHOLD_PERCENT = 3; |
| 55 |
|
|
| 56 |
|
private static final int TOUPPERCASE = 'a' - 'A'; |
| 57 |
|
|
| 58 |
|
private static final int GAP_INDEX = -1; |
| 59 |
|
|
| 60 |
|
private static final Format FORMAT_3DP = new Format("%2.5f"); |
| 61 |
|
|
| 62 |
|
SequenceI[] sequences; |
| 63 |
|
|
| 64 |
|
int start; |
| 65 |
|
|
| 66 |
|
int end; |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
Vector<int[]> seqNums; |
| 73 |
|
|
| 74 |
|
int maxLength = 0; |
| 75 |
|
|
| 76 |
|
boolean seqNumsChanged = false; |
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
Map<String, Integer>[] total; |
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
boolean canonicaliseAa = true; |
| 90 |
|
|
| 91 |
|
private Vector<Double> quality; |
| 92 |
|
|
| 93 |
|
private double qualityMinimum; |
| 94 |
|
|
| 95 |
|
private double qualityMaximum; |
| 96 |
|
|
| 97 |
|
private Sequence consSequence; |
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
private int threshold; |
| 103 |
|
|
| 104 |
|
private String name = ""; |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
private int[][] cons2; |
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
private int[] cons2GapCounts; |
| 115 |
|
|
| 116 |
|
private String[] consSymbs; |
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
@param |
| 122 |
|
|
| 123 |
|
@param |
| 124 |
|
|
| 125 |
|
@param |
| 126 |
|
|
| 127 |
|
@param |
| 128 |
|
|
| 129 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 130 |
1487 |
public Conservation(String name, List<SequenceI> sequences, int start,... |
| 131 |
|
int end) |
| 132 |
|
{ |
| 133 |
1487 |
this(name, THRESHOLD_PERCENT, sequences, start, end); |
| 134 |
|
} |
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
|
@param |
| 140 |
|
|
| 141 |
|
@param |
| 142 |
|
|
| 143 |
|
|
| 144 |
|
@param |
| 145 |
|
|
| 146 |
|
@param |
| 147 |
|
|
| 148 |
|
@param |
| 149 |
|
|
| 150 |
|
|
| |
|
| 89.5% |
Uncovered Elements: 2 (19) |
Complexity: 4 |
Complexity Density: 0.27 |
|
| 151 |
1491 |
public Conservation(String name, int threshold, List<SequenceI> sequences,... |
| 152 |
|
int start, int end) |
| 153 |
|
{ |
| 154 |
1490 |
this.name = name; |
| 155 |
1491 |
this.threshold = threshold; |
| 156 |
1491 |
this.start = start; |
| 157 |
1491 |
this.end = end; |
| 158 |
|
|
| 159 |
1491 |
maxLength = end - start + 1; |
| 160 |
|
|
| 161 |
|
|
| 162 |
1491 |
int s, sSize = sequences.size(); |
| 163 |
1491 |
SequenceI[] sarray = new SequenceI[sSize]; |
| 164 |
1490 |
this.sequences = sarray; |
| 165 |
1490 |
try |
| 166 |
|
{ |
| 167 |
18863 |
for (s = 0; s < sSize; s++) |
| 168 |
|
{ |
| 169 |
17371 |
sarray[s] = sequences.get(s); |
| 170 |
17371 |
if (sarray[s].getLength() > maxLength) |
| 171 |
|
{ |
| 172 |
6 |
maxLength = sarray[s].getLength(); |
| 173 |
|
} |
| 174 |
|
} |
| 175 |
|
} catch (ArrayIndexOutOfBoundsException ex) |
| 176 |
|
{ |
| 177 |
|
|
| 178 |
|
|
| 179 |
0 |
this.sequences = new SequenceI[0]; |
| 180 |
0 |
maxLength = 0; |
| 181 |
|
} |
| 182 |
|
} |
| 183 |
|
|
| 184 |
|
|
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
|
@param |
| 189 |
|
@param |
| 190 |
|
|
| |
|
| 81.6% |
Uncovered Elements: 7 (38) |
Complexity: 9 |
Complexity Density: 0.38 |
|
| 191 |
17298 |
private void calcSeqNum(int i, ScoreMatrix sm)... |
| 192 |
|
{ |
| 193 |
17298 |
int sSize = sequences.length; |
| 194 |
|
|
| 195 |
17300 |
if ((i > -1) && (i < sSize)) |
| 196 |
|
{ |
| 197 |
17299 |
String sq = sequences[i].getSequenceAsString(); |
| 198 |
|
|
| 199 |
17301 |
if (seqNums.size() <= i) |
| 200 |
|
{ |
| 201 |
17300 |
seqNums.addElement(new int[sq.length() + 1]); |
| 202 |
|
} |
| 203 |
|
|
| 204 |
|
|
| 205 |
|
|
| 206 |
|
|
| 207 |
|
|
| 208 |
17300 |
if (sq.hashCode() != seqNums.elementAt(i)[0]) |
| 209 |
|
{ |
| 210 |
17300 |
int j; |
| 211 |
17300 |
int len; |
| 212 |
17300 |
seqNumsChanged = true; |
| 213 |
17301 |
len = sq.length(); |
| 214 |
|
|
| 215 |
17300 |
if (maxLength < len) |
| 216 |
|
{ |
| 217 |
0 |
maxLength = len; |
| 218 |
|
} |
| 219 |
|
|
| 220 |
17301 |
int[] sqnum = new int[len + 1]; |
| 221 |
|
|
| 222 |
17300 |
sqnum[0] = sq.hashCode(); |
| 223 |
|
|
| 224 |
2936537 |
for (j = 1; j <= len; j++) |
| 225 |
|
{ |
| 226 |
|
|
| 227 |
2919714 |
char residue = sq.charAt(j - 1); |
| 228 |
2921149 |
if (Comparison.isGap(residue)) |
| 229 |
|
{ |
| 230 |
692638 |
sqnum[j] = GAP_INDEX; |
| 231 |
|
} |
| 232 |
|
else |
| 233 |
|
{ |
| 234 |
2229045 |
sqnum[j] = sm.getMatrixIndex(residue); |
| 235 |
2228570 |
if (sqnum[j] == -1) |
| 236 |
|
{ |
| 237 |
105 |
sqnum[j] = GAP_INDEX; |
| 238 |
|
} |
| 239 |
|
} |
| 240 |
|
} |
| 241 |
|
|
| 242 |
17299 |
seqNums.setElementAt(sqnum, i); |
| 243 |
|
} |
| 244 |
|
else |
| 245 |
|
{ |
| 246 |
0 |
jalview.bin.Console.outPrintln("SEQUENCE HAS BEEN DELETED!!!"); |
| 247 |
|
} |
| 248 |
|
} |
| 249 |
|
else |
| 250 |
|
{ |
| 251 |
|
|
| 252 |
0 |
jalview.bin.Console.errPrintln( |
| 253 |
|
"ERROR: calcSeqNum called with out of range sequence index for Alignment\n"); |
| 254 |
|
} |
| 255 |
|
} |
| 256 |
|
|
| 257 |
|
|
| 258 |
|
|
| 259 |
|
|
| |
|
| 96.3% |
Uncovered Elements: 1 (27) |
Complexity: 6 |
Complexity Density: 0.35 |
|
| 260 |
1486 |
public void calculate()... |
| 261 |
|
{ |
| 262 |
1486 |
int height = sequences.length; |
| 263 |
|
|
| 264 |
1487 |
total = new Map[maxLength]; |
| 265 |
|
|
| 266 |
220609 |
for (int column = start; column <= end; column++) |
| 267 |
|
{ |
| 268 |
219126 |
ResidueCount values = countResidues(column); |
| 269 |
|
|
| 270 |
|
|
| 271 |
|
|
| 272 |
|
|
| 273 |
219072 |
int thresh = (threshold * height) / 100; |
| 274 |
|
|
| 275 |
|
|
| 276 |
|
|
| 277 |
|
|
| 278 |
|
|
| 279 |
|
|
| 280 |
|
|
| 281 |
219077 |
SortedMap<String, Integer> resultHash = new TreeMap<>(); |
| 282 |
219109 |
SymbolCounts symbolCounts = values.getSymbolCounts(); |
| 283 |
219099 |
char[] symbols = symbolCounts.symbols; |
| 284 |
219106 |
int[] counts = symbolCounts.values; |
| 285 |
716817 |
for (int j = 0; j < symbols.length; j++) |
| 286 |
|
{ |
| 287 |
497774 |
char c = symbols[j]; |
| 288 |
497773 |
if (counts[j] > thresh) |
| 289 |
|
{ |
| 290 |
497758 |
recordConservation(resultHash, String.valueOf(c)); |
| 291 |
|
} |
| 292 |
|
} |
| 293 |
219105 |
if (values.getGapCount() > thresh) |
| 294 |
|
{ |
| 295 |
130021 |
recordConservation(resultHash, "-"); |
| 296 |
|
} |
| 297 |
|
|
| 298 |
219120 |
if (total.length > 0) |
| 299 |
|
{ |
| 300 |
219124 |
total[column - start] = resultHash; |
| 301 |
|
} |
| 302 |
|
} |
| 303 |
|
} |
| 304 |
|
|
| 305 |
|
|
| 306 |
|
|
| 307 |
|
|
| 308 |
|
@param |
| 309 |
|
|
| 310 |
|
|
| 311 |
|
|
| 312 |
|
@param |
| 313 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 5 |
Complexity Density: 0.45 |
|
| 314 |
627474 |
protected static void recordConservation(Map<String, Integer> resultMap,... |
| 315 |
|
String res) |
| 316 |
|
{ |
| 317 |
627488 |
res = res.toUpperCase(Locale.ROOT); |
| 318 |
627434 |
for (Entry<String, Map<String, Integer>> property : ResidueProperties.propHash |
| 319 |
|
.entrySet()) |
| 320 |
|
{ |
| 321 |
6248889 |
String propertyName = property.getKey(); |
| 322 |
6251328 |
Integer residuePropertyValue = property.getValue().get(res); |
| 323 |
|
|
| 324 |
6270480 |
if (!resultMap.containsKey(propertyName)) |
| 325 |
|
{ |
| 326 |
|
|
| 327 |
|
|
| 328 |
|
|
| 329 |
2188925 |
if (residuePropertyValue != null) |
| 330 |
|
{ |
| 331 |
2188609 |
resultMap.put(propertyName, residuePropertyValue); |
| 332 |
|
} |
| 333 |
|
else |
| 334 |
|
{ |
| 335 |
|
|
| 336 |
|
|
| 337 |
|
|
| 338 |
320 |
resultMap.put(propertyName, property.getValue().get("-")); |
| 339 |
|
} |
| 340 |
|
} |
| 341 |
|
else |
| 342 |
|
{ |
| 343 |
4078488 |
Integer currentResult = resultMap.get(propertyName); |
| 344 |
4081675 |
if (currentResult.intValue() != -1 |
| 345 |
|
&& !currentResult.equals(residuePropertyValue)) |
| 346 |
|
{ |
| 347 |
|
|
| 348 |
|
|
| 349 |
|
|
| 350 |
1161612 |
resultMap.put(propertyName, Integer.valueOf(-1)); |
| 351 |
|
} |
| 352 |
|
} |
| 353 |
|
} |
| 354 |
|
} |
| 355 |
|
|
| 356 |
|
|
| 357 |
|
|
| 358 |
|
|
| 359 |
|
@param |
| 360 |
|
@return |
| 361 |
|
|
| |
|
| 91.3% |
Uncovered Elements: 2 (23) |
Complexity: 6 |
Complexity Density: 0.46 |
|
| 362 |
219119 |
protected ResidueCount countResidues(int column)... |
| 363 |
|
{ |
| 364 |
219118 |
ResidueCount values = new ResidueCount(false); |
| 365 |
|
|
| 366 |
3188576 |
for (int row = 0; row < sequences.length; row++) |
| 367 |
|
{ |
| 368 |
2969400 |
if (sequences[row].getLength() > column) |
| 369 |
|
{ |
| 370 |
2921174 |
char c = sequences[row].getCharAt(column); |
| 371 |
2920457 |
if (canonicaliseAa) |
| 372 |
|
{ |
| 373 |
2920506 |
int index = ResidueProperties.aaIndex[c]; |
| 374 |
2923751 |
c = index > 20 ? '-' : ResidueProperties.aa[index].charAt(0); |
| 375 |
|
} |
| 376 |
|
else |
| 377 |
|
{ |
| 378 |
0 |
c = toUpperCase(c); |
| 379 |
|
} |
| 380 |
2923183 |
if (Comparison.isGap(c)) |
| 381 |
|
{ |
| 382 |
691101 |
values.addGap(); |
| 383 |
|
} |
| 384 |
|
else |
| 385 |
|
{ |
| 386 |
2232082 |
values.add(c); |
| 387 |
|
} |
| 388 |
|
} |
| 389 |
|
else |
| 390 |
|
{ |
| 391 |
48233 |
values.addGap(); |
| 392 |
|
} |
| 393 |
|
} |
| 394 |
219067 |
return values; |
| 395 |
|
} |
| 396 |
|
|
| 397 |
|
|
| 398 |
|
|
| 399 |
|
|
| 400 |
|
@return |
| 401 |
|
|
| |
|
| 94.1% |
Uncovered Elements: 2 (34) |
Complexity: 8 |
Complexity Density: 0.4 |
|
| 402 |
219055 |
public int[] countConservationAndGaps(int column)... |
| 403 |
|
{ |
| 404 |
219054 |
int gapCount = 0; |
| 405 |
219053 |
boolean fullyConserved = true; |
| 406 |
219054 |
int iSize = sequences.length; |
| 407 |
|
|
| 408 |
219053 |
if (iSize == 0) |
| 409 |
|
{ |
| 410 |
0 |
return new int[] { 0, 0 }; |
| 411 |
|
} |
| 412 |
|
|
| 413 |
219050 |
char lastRes = '0'; |
| 414 |
3189314 |
for (int i = 0; i < iSize; i++) |
| 415 |
|
{ |
| 416 |
2969994 |
if (column >= sequences[i].getLength()) |
| 417 |
|
{ |
| 418 |
48233 |
gapCount++; |
| 419 |
48233 |
continue; |
| 420 |
|
} |
| 421 |
|
|
| 422 |
2921898 |
char c = sequences[i].getCharAt(column); |
| 423 |
|
|
| 424 |
|
|
| 425 |
2924131 |
if (Comparison.isGap((c))) |
| 426 |
|
{ |
| 427 |
691912 |
gapCount++; |
| 428 |
|
} |
| 429 |
|
else |
| 430 |
|
{ |
| 431 |
2232312 |
c = toUpperCase(c); |
| 432 |
2233517 |
if (lastRes == '0') |
| 433 |
|
{ |
| 434 |
205337 |
lastRes = c; |
| 435 |
|
} |
| 436 |
2235299 |
if (c != lastRes) |
| 437 |
|
{ |
| 438 |
720982 |
fullyConserved = false; |
| 439 |
|
} |
| 440 |
|
} |
| 441 |
|
} |
| 442 |
|
|
| 443 |
219067 |
int[] r = new int[] { fullyConserved ? 1 : 0, gapCount }; |
| 444 |
219042 |
return r; |
| 445 |
|
} |
| 446 |
|
|
| 447 |
|
|
| 448 |
|
|
| 449 |
|
|
| 450 |
|
|
| 451 |
|
@param |
| 452 |
|
@return |
| 453 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 454 |
2232218 |
char toUpperCase(char c)... |
| 455 |
|
{ |
| 456 |
2232432 |
if ('a' <= c && c <= 'z') |
| 457 |
|
{ |
| 458 |
13560 |
c -= TOUPPERCASE; |
| 459 |
|
} |
| 460 |
2232698 |
return c; |
| 461 |
|
} |
| 462 |
|
|
| 463 |
|
|
| 464 |
|
|
| 465 |
|
|
| 466 |
|
@param |
| 467 |
|
|
| 468 |
|
|
| 469 |
|
@param |
| 470 |
|
|
| 471 |
|
|
| 472 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (55) |
Complexity: 13 |
Complexity Density: 0.39 |
|
| 473 |
1485 |
public void verdict(boolean positiveOnly, float maxPercentageGaps)... |
| 474 |
|
{ |
| 475 |
|
|
| 476 |
|
|
| 477 |
1485 |
StringBuilder consString = new StringBuilder(end); |
| 478 |
|
|
| 479 |
|
|
| 480 |
|
|
| 481 |
|
|
| 482 |
1575 |
for (int i = 0; i < start; i++) |
| 483 |
|
{ |
| 484 |
90 |
consString.append('-'); |
| 485 |
|
} |
| 486 |
1485 |
consSymbs = new String[end - start + 1]; |
| 487 |
220545 |
for (int i = start; i <= end; i++) |
| 488 |
|
{ |
| 489 |
219058 |
int[] gapcons = countConservationAndGaps(i); |
| 490 |
219043 |
boolean fullyConserved = gapcons[0] == 1; |
| 491 |
219063 |
int totGaps = gapcons[1]; |
| 492 |
219064 |
float pgaps = (totGaps * 100f) / sequences.length; |
| 493 |
|
|
| 494 |
219088 |
if (maxPercentageGaps > pgaps) |
| 495 |
|
{ |
| 496 |
152583 |
Map<String, Integer> resultHash = total[i - start]; |
| 497 |
152584 |
int count = 0; |
| 498 |
152582 |
StringBuilder positives = new StringBuilder(64); |
| 499 |
152577 |
StringBuilder negatives = new StringBuilder(32); |
| 500 |
152573 |
for (String type : resultHash.keySet()) |
| 501 |
|
{ |
| 502 |
1523895 |
int result = resultHash.get(type).intValue(); |
| 503 |
1525469 |
if (result == -1) |
| 504 |
|
{ |
| 505 |
|
|
| 506 |
|
|
| 507 |
|
|
| 508 |
725901 |
continue; |
| 509 |
|
} |
| 510 |
799547 |
count++; |
| 511 |
799702 |
if (result == 1) |
| 512 |
|
{ |
| 513 |
|
|
| 514 |
|
|
| 515 |
|
|
| 516 |
252266 |
positives.append(positives.length() == 0 ? "" : " "); |
| 517 |
252249 |
positives.append(type); |
| 518 |
|
} |
| 519 |
799693 |
if (result == 0 && !positiveOnly) |
| 520 |
|
{ |
| 521 |
|
|
| 522 |
|
|
| 523 |
|
|
| 524 |
547449 |
negatives.append(negatives.length() == 0 ? "" : " "); |
| 525 |
547472 |
negatives.append("!").append(type); |
| 526 |
|
} |
| 527 |
|
} |
| 528 |
152588 |
if (negatives.length() > 0) |
| 529 |
|
{ |
| 530 |
88542 |
positives.append(" ").append(negatives); |
| 531 |
|
} |
| 532 |
152578 |
consSymbs[i - start] = positives.toString(); |
| 533 |
|
|
| 534 |
152592 |
if (count < 10) |
| 535 |
|
{ |
| 536 |
106022 |
consString.append(count); |
| 537 |
|
} |
| 538 |
|
else |
| 539 |
|
{ |
| 540 |
46567 |
consString.append(fullyConserved ? "*" : "+"); |
| 541 |
|
} |
| 542 |
|
} |
| 543 |
|
else |
| 544 |
|
{ |
| 545 |
66510 |
consString.append('-'); |
| 546 |
|
} |
| 547 |
|
} |
| 548 |
|
|
| 549 |
1485 |
consSequence = new Sequence(name, consString.toString(), start, end); |
| 550 |
|
} |
| 551 |
|
|
| 552 |
|
|
| 553 |
|
|
| 554 |
|
|
| 555 |
|
@return |
| 556 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 557 |
1504 |
public SequenceI getConsSequence()... |
| 558 |
|
{ |
| 559 |
1504 |
return consSequence; |
| 560 |
|
} |
| 561 |
|
|
| 562 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 563 |
1473 |
public void findQuality()... |
| 564 |
|
{ |
| 565 |
1473 |
findQuality(0, maxLength - 1, ScoreModels.getInstance().getBlosum62()); |
| 566 |
|
} |
| 567 |
|
|
| 568 |
|
|
| 569 |
|
|
| 570 |
|
|
| 571 |
|
@param |
| 572 |
|
|
| |
|
| 96.7% |
Uncovered Elements: 1 (30) |
Complexity: 8 |
Complexity Density: 0.44 |
|
| 573 |
1473 |
private void percentIdentity(ScoreMatrix sm)... |
| 574 |
|
{ |
| 575 |
1473 |
seqNums = new Vector<>(); |
| 576 |
1473 |
int i = 0, iSize = sequences.length; |
| 577 |
|
|
| 578 |
18771 |
for (i = 0; i < iSize; i++) |
| 579 |
|
{ |
| 580 |
17298 |
calcSeqNum(i, sm); |
| 581 |
|
} |
| 582 |
|
|
| 583 |
1473 |
if ((cons2 == null) || seqNumsChanged) |
| 584 |
|
{ |
| 585 |
|
|
| 586 |
|
|
| 587 |
1473 |
cons2 = new int[maxLength][24]; |
| 588 |
1473 |
cons2GapCounts = new int[maxLength]; |
| 589 |
|
|
| 590 |
1473 |
int j = 0; |
| 591 |
|
|
| 592 |
18774 |
while (j < sequences.length) |
| 593 |
|
{ |
| 594 |
17301 |
int[] sqnum = seqNums.elementAt(j); |
| 595 |
|
|
| 596 |
2933496 |
for (i = 1; i < sqnum.length; i++) |
| 597 |
|
{ |
| 598 |
2916413 |
int index = sqnum[i]; |
| 599 |
2919214 |
if (index == GAP_INDEX) |
| 600 |
|
{ |
| 601 |
692551 |
cons2GapCounts[i - 1]++; |
| 602 |
|
} |
| 603 |
|
else |
| 604 |
|
{ |
| 605 |
2226572 |
cons2[i - 1][index]++; |
| 606 |
|
} |
| 607 |
|
} |
| 608 |
|
|
| 609 |
|
|
| 610 |
65489 |
for (i = sqnum.length - 1; i < maxLength; i++) |
| 611 |
|
{ |
| 612 |
48188 |
cons2GapCounts[i]++; |
| 613 |
|
} |
| 614 |
17301 |
j++; |
| 615 |
|
} |
| 616 |
|
} |
| 617 |
|
} |
| 618 |
|
|
| 619 |
|
|
| 620 |
|
|
| 621 |
|
|
| 622 |
|
|
| 623 |
|
@param |
| 624 |
|
@param |
| 625 |
|
@param |
| 626 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (61) |
Complexity: 11 |
Complexity Density: 0.27 |
|
| 627 |
1473 |
protected void findQuality(int startCol, int endCol,... |
| 628 |
|
ScoreMatrix scoreMatrix) |
| 629 |
|
{ |
| 630 |
1473 |
quality = new Vector<>(); |
| 631 |
|
|
| 632 |
1473 |
double max = -Double.MAX_VALUE; |
| 633 |
1473 |
float[][] scores = scoreMatrix.getMatrix(); |
| 634 |
|
|
| 635 |
1473 |
percentIdentity(scoreMatrix); |
| 636 |
|
|
| 637 |
1473 |
int size = seqNums.size(); |
| 638 |
1473 |
int[] lengths = new int[size]; |
| 639 |
|
|
| 640 |
18774 |
for (int l = 0; l < size; l++) |
| 641 |
|
{ |
| 642 |
17301 |
lengths[l] = seqNums.elementAt(l).length - 1; |
| 643 |
|
} |
| 644 |
|
|
| 645 |
1473 |
final int symbolCount = scoreMatrix.getSize(); |
| 646 |
|
|
| 647 |
219698 |
for (int j = startCol; j <= endCol; j++) |
| 648 |
|
{ |
| 649 |
218223 |
double bigtot = 0; |
| 650 |
|
|
| 651 |
|
|
| 652 |
218227 |
double[] x = new double[symbolCount]; |
| 653 |
|
|
| 654 |
5441569 |
for (int ii = 0; ii < symbolCount; ii++) |
| 655 |
|
{ |
| 656 |
5224049 |
x[ii] = 0; |
| 657 |
|
|
| 658 |
|
|
| 659 |
|
|
| 660 |
|
|
| 661 |
|
|
| 662 |
|
|
| 663 |
123618165 |
for (int i2 = 0; i2 < symbolCount - 1; i2++) |
| 664 |
|
{ |
| 665 |
118852696 |
x[ii] += (((double) cons2[j][i2] * scores[ii][i2]) + 4D); |
| 666 |
|
} |
| 667 |
5231350 |
x[ii] += 4D + cons2GapCounts[j] * scoreMatrix.getMinimumScore(); |
| 668 |
|
|
| 669 |
5227784 |
x[ii] /= size; |
| 670 |
|
} |
| 671 |
|
|
| 672 |
|
|
| 673 |
3184465 |
for (int k = 0; k < size; k++) |
| 674 |
|
{ |
| 675 |
2966460 |
double tot = 0; |
| 676 |
2966641 |
double[] xx = new double[symbolCount]; |
| 677 |
|
|
| 678 |
2966992 |
int seqNum = (j < lengths[k]) ? seqNums.elementAt(k)[j + 1] |
| 679 |
|
: GAP_INDEX; |
| 680 |
|
|
| 681 |
69793659 |
for (int i = 0; i < symbolCount - 1; i++) |
| 682 |
|
{ |
| 683 |
66961257 |
double sr = 4D; |
| 684 |
67398178 |
if (seqNum == GAP_INDEX) |
| 685 |
|
{ |
| 686 |
16671429 |
sr += scoreMatrix.getMinimumScore(); |
| 687 |
|
} |
| 688 |
|
else |
| 689 |
|
{ |
| 690 |
50607185 |
sr += scores[i][seqNum]; |
| 691 |
|
} |
| 692 |
|
|
| 693 |
66976949 |
xx[i] = x[i] - sr; |
| 694 |
|
|
| 695 |
67107259 |
tot += (xx[i] * xx[i]); |
| 696 |
|
} |
| 697 |
|
|
| 698 |
2966371 |
bigtot += Math.sqrt(tot); |
| 699 |
|
} |
| 700 |
|
|
| 701 |
218218 |
max = Math.max(max, bigtot); |
| 702 |
|
|
| 703 |
218220 |
quality.addElement(Double.valueOf(bigtot)); |
| 704 |
|
} |
| 705 |
|
|
| 706 |
1473 |
double newmax = -Double.MAX_VALUE; |
| 707 |
|
|
| 708 |
219729 |
for (int j = startCol; j <= endCol; j++) |
| 709 |
|
{ |
| 710 |
218256 |
double tmp = quality.elementAt(j).doubleValue(); |
| 711 |
|
|
| 712 |
218256 |
tmp = ((max - tmp) * (size - cons2GapCounts[j])) / size; |
| 713 |
|
|
| 714 |
|
|
| 715 |
218256 |
quality.setElementAt(Double.valueOf(tmp), j); |
| 716 |
|
|
| 717 |
218256 |
if (tmp > newmax) |
| 718 |
|
{ |
| 719 |
4046 |
newmax = tmp; |
| 720 |
|
} |
| 721 |
|
} |
| 722 |
|
|
| 723 |
1473 |
qualityMinimum = 0D; |
| 724 |
1473 |
qualityMaximum = newmax; |
| 725 |
|
} |
| 726 |
|
|
| 727 |
|
|
| 728 |
|
|
| 729 |
|
|
| 730 |
|
|
| 731 |
|
|
| 732 |
|
@param |
| 733 |
|
|
| 734 |
|
@param |
| 735 |
|
|
| 736 |
|
@param |
| 737 |
|
|
| 738 |
|
@param |
| 739 |
|
|
| 740 |
|
|
| |
|
| 95.6% |
Uncovered Elements: 3 (68) |
Complexity: 18 |
Complexity Density: 0.41 |
|
| 741 |
1473 |
public void completeAnnotations(AlignmentAnnotation conservation,... |
| 742 |
|
AlignmentAnnotation quality2, int istart, int alWidth) |
| 743 |
|
{ |
| 744 |
1473 |
SequenceI cons = getConsSequence(); |
| 745 |
|
|
| 746 |
|
|
| 747 |
|
|
| 748 |
|
|
| 749 |
1473 |
float minR = 0.3f; |
| 750 |
1473 |
float minG = 0.0f; |
| 751 |
1473 |
float minB = 0f; |
| 752 |
1473 |
float maxR = 1.0f - minR; |
| 753 |
1473 |
float maxG = 0.9f - minG; |
| 754 |
1473 |
float maxB = 0f - minB; |
| 755 |
|
|
| 756 |
1473 |
float min = 0f; |
| 757 |
1473 |
float max = 11f; |
| 758 |
1473 |
float qmin = 0f; |
| 759 |
1473 |
float qmax = 0f; |
| 760 |
1473 |
if (conservation!=null) |
| 761 |
|
{ |
| 762 |
1469 |
conservation.setNoOfSequencesIncluded(sequences.length); |
| 763 |
|
} |
| 764 |
1473 |
if (quality2!=null) |
| 765 |
|
{ |
| 766 |
1473 |
quality2.setNoOfSequencesIncluded(sequences.length); |
| 767 |
|
} |
| 768 |
|
|
| 769 |
1473 |
if (conservation != null && conservation.annotations != null |
| 770 |
|
&& conservation.annotations.length != alWidth) |
| 771 |
|
{ |
| 772 |
395 |
conservation.annotations = new Annotation[alWidth]; |
| 773 |
|
} |
| 774 |
|
|
| 775 |
1473 |
if (quality2 != null) |
| 776 |
|
{ |
| 777 |
1473 |
quality2.graphMax = (float) qualityMaximum; |
| 778 |
1473 |
if (quality2.annotations != null |
| 779 |
|
&& quality2.annotations.length != alWidth) |
| 780 |
|
{ |
| 781 |
396 |
quality2.annotations = new Annotation[alWidth]; |
| 782 |
|
} |
| 783 |
1473 |
qmin = (float) qualityMinimum; |
| 784 |
1473 |
qmax = (float) qualityMaximum; |
| 785 |
|
} |
| 786 |
|
|
| 787 |
219688 |
for (int i = istart; i < alWidth; i++) |
| 788 |
|
{ |
| 789 |
218208 |
float value = 0; |
| 790 |
|
|
| 791 |
218211 |
char c = cons.getCharAt(i); |
| 792 |
|
|
| 793 |
218201 |
if (Character.isDigit(c)) |
| 794 |
|
{ |
| 795 |
105733 |
value = c - '0'; |
| 796 |
|
} |
| 797 |
112467 |
else if (c == '*') |
| 798 |
|
{ |
| 799 |
46128 |
value = 11; |
| 800 |
|
} |
| 801 |
66334 |
else if (c == '+') |
| 802 |
|
{ |
| 803 |
141 |
value = 10; |
| 804 |
|
} |
| 805 |
|
|
| 806 |
218166 |
if (conservation != null) |
| 807 |
|
{ |
| 808 |
217538 |
float vprop = value - min; |
| 809 |
217540 |
vprop /= max; |
| 810 |
217551 |
int consp = i - start; |
| 811 |
217572 |
String conssym = (value > 0 && consp > -1 |
| 812 |
|
&& consp < consSymbs.length) ? consSymbs[consp] : ""; |
| 813 |
217554 |
conservation.annotations[i] = new Annotation(String.valueOf(c), |
| 814 |
|
conssym, ' ', value, new Color(minR + (maxR * vprop), |
| 815 |
|
minG + (maxG * vprop), minB + (maxB * vprop))); |
| 816 |
|
} |
| 817 |
|
|
| 818 |
|
|
| 819 |
218215 |
if (quality2 != null) |
| 820 |
|
{ |
| 821 |
218207 |
value = quality.elementAt(i).floatValue(); |
| 822 |
218212 |
float vprop = value - qmin; |
| 823 |
218215 |
vprop /= qmax; |
| 824 |
218211 |
String description = FORMAT_3DP.form(value); |
| 825 |
218206 |
quality2.annotations[i] = new Annotation(" ", description, ' ', |
| 826 |
|
value, new Color(minR + (maxR * vprop), |
| 827 |
|
minG + (maxG * vprop), minB + (maxB * vprop))); |
| 828 |
|
} |
| 829 |
|
} |
| 830 |
|
} |
| 831 |
|
|
| 832 |
|
|
| 833 |
|
|
| 834 |
|
|
| 835 |
|
@param |
| 836 |
|
|
| 837 |
|
@param |
| 838 |
|
@param |
| 839 |
|
|
| 840 |
|
@param |
| 841 |
|
|
| 842 |
|
@param |
| 843 |
|
|
| 844 |
|
|
| 845 |
|
@param |
| 846 |
|
|
| 847 |
|
@param |
| 848 |
|
|
| 849 |
|
@return |
| 850 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 851 |
1476 |
public static Conservation calculateConservation(String name,... |
| 852 |
|
List<SequenceI> seqs, int start, int end, boolean positiveOnly, |
| 853 |
|
int maxPercentGaps, boolean calcQuality) |
| 854 |
|
{ |
| 855 |
1476 |
Conservation cons = new Conservation(name, seqs, start, end); |
| 856 |
1476 |
cons.calculate(); |
| 857 |
1476 |
cons.verdict(positiveOnly, maxPercentGaps); |
| 858 |
|
|
| 859 |
1476 |
if (calcQuality) |
| 860 |
|
{ |
| 861 |
1473 |
cons.findQuality(); |
| 862 |
|
} |
| 863 |
|
|
| 864 |
1476 |
return cons; |
| 865 |
|
} |
| 866 |
|
|
| 867 |
|
|
| 868 |
|
|
| 869 |
|
|
| 870 |
|
|
| 871 |
|
|
| 872 |
|
|
| 873 |
|
@param |
| 874 |
|
@return |
| 875 |
|
|
| |
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 5 |
Complexity Density: 0.83 |
|
| 876 |
7 |
String getTooltip(int column)... |
| 877 |
|
{ |
| 878 |
7 |
SequenceI cons = getConsSequence(); |
| 879 |
7 |
char val = column < cons.getLength() ? cons.getCharAt(column) : '-'; |
| 880 |
7 |
boolean hasConservation = val != '-' && val != '0'; |
| 881 |
7 |
int consp = column - start; |
| 882 |
7 |
String tip = (hasConservation && consp > -1 && consp < consSymbs.length) |
| 883 |
|
? consSymbs[consp] |
| 884 |
|
: ""; |
| 885 |
7 |
return tip; |
| 886 |
|
} |
| 887 |
|
} |