| 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.api.analysis.ScoreModelI; |
| 28 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 29 |
|
import jalview.datamodel.Annotation; |
| 30 |
|
import jalview.datamodel.ResidueCount; |
| 31 |
|
import jalview.datamodel.ResidueCount.SymbolCounts; |
| 32 |
|
import jalview.datamodel.Sequence; |
| 33 |
|
import jalview.datamodel.SequenceI; |
| 34 |
|
import jalview.schemes.ResidueProperties; |
| 35 |
|
import jalview.util.Comparison; |
| 36 |
|
import jalview.util.Format; |
| 37 |
|
|
| 38 |
|
import java.awt.Color; |
| 39 |
|
import java.util.List; |
| 40 |
|
import java.util.Map; |
| 41 |
|
import java.util.Map.Entry; |
| 42 |
|
import java.util.SortedMap; |
| 43 |
|
import java.util.TreeMap; |
| 44 |
|
import java.util.Vector; |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| |
|
| 95.3% |
Uncovered Elements: 20 (427) |
Complexity: 107 |
Complexity Density: 0.41 |
|
| 49 |
|
public class Conservation |
| 50 |
|
{ |
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
private static final int THRESHOLD_PERCENT = 3; |
| 56 |
|
|
| 57 |
|
private static final int TOUPPERCASE = 'a' - 'A'; |
| 58 |
|
|
| 59 |
|
private static final int GAP_INDEX = -1; |
| 60 |
|
|
| 61 |
|
private static final Format FORMAT_3DP = new Format("%2.5f"); |
| 62 |
|
|
| 63 |
|
SequenceI[] sequences; |
| 64 |
|
|
| 65 |
|
int start; |
| 66 |
|
|
| 67 |
|
int end; |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
Vector<int[]> seqNums; |
| 74 |
|
|
| 75 |
|
int maxLength = 0; |
| 76 |
|
|
| 77 |
|
boolean seqNumsChanged = false; |
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
Map<String, Integer>[] total; |
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
boolean canonicaliseAa = true; |
| 91 |
|
|
| 92 |
|
private Vector<Double> quality; |
| 93 |
|
|
| 94 |
|
private double qualityMinimum; |
| 95 |
|
|
| 96 |
|
private double qualityMaximum; |
| 97 |
|
|
| 98 |
|
private Sequence consSequence; |
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
private int threshold; |
| 104 |
|
|
| 105 |
|
private String name = ""; |
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
private int[][] cons2; |
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
private int[] cons2GapCounts; |
| 116 |
|
|
| 117 |
|
private String[] consSymbs; |
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 |
|
@param |
| 123 |
|
|
| 124 |
|
@param |
| 125 |
|
|
| 126 |
|
@param |
| 127 |
|
|
| 128 |
|
@param |
| 129 |
|
|
| 130 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 131 |
890 |
public Conservation(String name, List<SequenceI> sequences, int start,... |
| 132 |
|
int end) |
| 133 |
|
{ |
| 134 |
890 |
this(name, THRESHOLD_PERCENT, sequences, start, end); |
| 135 |
|
} |
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
|
|
| 140 |
|
@param |
| 141 |
|
|
| 142 |
|
@param |
| 143 |
|
|
| 144 |
|
|
| 145 |
|
@param |
| 146 |
|
|
| 147 |
|
@param |
| 148 |
|
|
| 149 |
|
@param |
| 150 |
|
|
| 151 |
|
|
| |
|
| 89.5% |
Uncovered Elements: 2 (19) |
Complexity: 4 |
Complexity Density: 0.27 |
|
| 152 |
894 |
public Conservation(String name, int threshold, List<SequenceI> sequences,... |
| 153 |
|
int start, int end) |
| 154 |
|
{ |
| 155 |
894 |
this.name = name; |
| 156 |
894 |
this.threshold = threshold; |
| 157 |
894 |
this.start = start; |
| 158 |
894 |
this.end = end; |
| 159 |
|
|
| 160 |
894 |
maxLength = end - start + 1; |
| 161 |
|
|
| 162 |
|
|
| 163 |
894 |
int s, sSize = sequences.size(); |
| 164 |
894 |
SequenceI[] sarray = new SequenceI[sSize]; |
| 165 |
894 |
this.sequences = sarray; |
| 166 |
894 |
try |
| 167 |
|
{ |
| 168 |
9945 |
for (s = 0; s < sSize; s++) |
| 169 |
|
{ |
| 170 |
9050 |
sarray[s] = sequences.get(s); |
| 171 |
9050 |
if (sarray[s].getLength() > maxLength) |
| 172 |
|
{ |
| 173 |
6 |
maxLength = sarray[s].getLength(); |
| 174 |
|
} |
| 175 |
|
} |
| 176 |
|
} catch (ArrayIndexOutOfBoundsException ex) |
| 177 |
|
{ |
| 178 |
|
|
| 179 |
|
|
| 180 |
0 |
this.sequences = new SequenceI[0]; |
| 181 |
0 |
maxLength = 0; |
| 182 |
|
} |
| 183 |
|
} |
| 184 |
|
|
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
@param |
| 190 |
|
@param |
| 191 |
|
|
| |
|
| 81.6% |
Uncovered Elements: 7 (38) |
Complexity: 9 |
Complexity Density: 0.38 |
|
| 192 |
8977 |
private void calcSeqNum(int i, ScoreMatrix sm)... |
| 193 |
|
{ |
| 194 |
8977 |
int sSize = sequences.length; |
| 195 |
|
|
| 196 |
8977 |
if ((i > -1) && (i < sSize)) |
| 197 |
|
{ |
| 198 |
8977 |
String sq = sequences[i].getSequenceAsString(); |
| 199 |
|
|
| 200 |
8977 |
if (seqNums.size() <= i) |
| 201 |
|
{ |
| 202 |
8977 |
seqNums.addElement(new int[sq.length() + 1]); |
| 203 |
|
} |
| 204 |
|
|
| 205 |
|
|
| 206 |
|
|
| 207 |
|
|
| 208 |
|
|
| 209 |
8977 |
if (sq.hashCode() != seqNums.elementAt(i)[0]) |
| 210 |
|
{ |
| 211 |
8977 |
int j; |
| 212 |
8977 |
int len; |
| 213 |
8977 |
seqNumsChanged = true; |
| 214 |
8977 |
len = sq.length(); |
| 215 |
|
|
| 216 |
8977 |
if (maxLength < len) |
| 217 |
|
{ |
| 218 |
0 |
maxLength = len; |
| 219 |
|
} |
| 220 |
|
|
| 221 |
8977 |
int[] sqnum = new int[len + 1]; |
| 222 |
|
|
| 223 |
8977 |
sqnum[0] = sq.hashCode(); |
| 224 |
|
|
| 225 |
1462619 |
for (j = 1; j <= len; j++) |
| 226 |
|
{ |
| 227 |
|
|
| 228 |
1453643 |
char residue = sq.charAt(j - 1); |
| 229 |
1453817 |
if (Comparison.isGap(residue)) |
| 230 |
|
{ |
| 231 |
292291 |
sqnum[j] = GAP_INDEX; |
| 232 |
|
} |
| 233 |
|
else |
| 234 |
|
{ |
| 235 |
1161516 |
sqnum[j] = sm.getMatrixIndex(residue); |
| 236 |
1161515 |
if (sqnum[j] == -1) |
| 237 |
|
{ |
| 238 |
58 |
sqnum[j] = GAP_INDEX; |
| 239 |
|
} |
| 240 |
|
} |
| 241 |
|
} |
| 242 |
|
|
| 243 |
8977 |
seqNums.setElementAt(sqnum, i); |
| 244 |
|
} |
| 245 |
|
else |
| 246 |
|
{ |
| 247 |
0 |
jalview.bin.Console.outPrintln("SEQUENCE HAS BEEN DELETED!!!"); |
| 248 |
|
} |
| 249 |
|
} |
| 250 |
|
else |
| 251 |
|
{ |
| 252 |
|
|
| 253 |
0 |
jalview.bin.Console.errPrintln( |
| 254 |
|
"ERROR: calcSeqNum called with out of range sequence index for Alignment\n"); |
| 255 |
|
} |
| 256 |
|
} |
| 257 |
|
|
| 258 |
|
|
| 259 |
|
|
| 260 |
|
|
| |
|
| 96.3% |
Uncovered Elements: 1 (27) |
Complexity: 6 |
Complexity Density: 0.35 |
|
| 261 |
890 |
public void calculate()... |
| 262 |
|
{ |
| 263 |
890 |
int height = sequences.length; |
| 264 |
|
|
| 265 |
890 |
total = new Map[maxLength]; |
| 266 |
|
|
| 267 |
120812 |
for (int column = start; column <= end; column++) |
| 268 |
|
{ |
| 269 |
119919 |
ResidueCount values = countResidues(column); |
| 270 |
|
|
| 271 |
|
|
| 272 |
|
|
| 273 |
|
|
| 274 |
119916 |
int thresh = (threshold * height) / 100; |
| 275 |
|
|
| 276 |
|
|
| 277 |
|
|
| 278 |
|
|
| 279 |
|
|
| 280 |
|
|
| 281 |
|
|
| 282 |
119914 |
SortedMap<String, Integer> resultHash = new TreeMap<>(); |
| 283 |
119911 |
SymbolCounts symbolCounts = values.getSymbolCounts(); |
| 284 |
119896 |
char[] symbols = symbolCounts.symbols; |
| 285 |
119895 |
int[] counts = symbolCounts.values; |
| 286 |
381366 |
for (int j = 0; j < symbols.length; j++) |
| 287 |
|
{ |
| 288 |
261420 |
char c = symbols[j]; |
| 289 |
261403 |
if (counts[j] > thresh) |
| 290 |
|
{ |
| 291 |
261394 |
recordConservation(resultHash, String.valueOf(c)); |
| 292 |
|
} |
| 293 |
|
} |
| 294 |
119929 |
if (values.getGapCount() > thresh) |
| 295 |
|
{ |
| 296 |
64523 |
recordConservation(resultHash, "-"); |
| 297 |
|
} |
| 298 |
|
|
| 299 |
119925 |
if (total.length > 0) |
| 300 |
|
{ |
| 301 |
119924 |
total[column - start] = resultHash; |
| 302 |
|
} |
| 303 |
|
} |
| 304 |
|
} |
| 305 |
|
|
| 306 |
|
|
| 307 |
|
|
| 308 |
|
|
| 309 |
|
@param |
| 310 |
|
|
| 311 |
|
|
| 312 |
|
|
| 313 |
|
@param |
| 314 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 5 |
Complexity Density: 0.45 |
|
| 315 |
325874 |
protected static void recordConservation(Map<String, Integer> resultMap,... |
| 316 |
|
String res) |
| 317 |
|
{ |
| 318 |
325882 |
res = res.toUpperCase(Locale.ROOT); |
| 319 |
325881 |
for (Entry<String, Map<String, Integer>> property : ResidueProperties.propHash |
| 320 |
|
.entrySet()) |
| 321 |
|
{ |
| 322 |
3255733 |
String propertyName = property.getKey(); |
| 323 |
3256539 |
Integer residuePropertyValue = property.getValue().get(res); |
| 324 |
|
|
| 325 |
3259276 |
if (!resultMap.containsKey(propertyName)) |
| 326 |
|
{ |
| 327 |
|
|
| 328 |
|
|
| 329 |
|
|
| 330 |
1199142 |
if (residuePropertyValue != null) |
| 331 |
|
{ |
| 332 |
1198862 |
resultMap.put(propertyName, residuePropertyValue); |
| 333 |
|
} |
| 334 |
|
else |
| 335 |
|
{ |
| 336 |
|
|
| 337 |
|
|
| 338 |
|
|
| 339 |
360 |
resultMap.put(propertyName, property.getValue().get("-")); |
| 340 |
|
} |
| 341 |
|
} |
| 342 |
|
else |
| 343 |
|
{ |
| 344 |
2060098 |
Integer currentResult = resultMap.get(propertyName); |
| 345 |
2060881 |
if (currentResult.intValue() != -1 |
| 346 |
|
&& !currentResult.equals(residuePropertyValue)) |
| 347 |
|
{ |
| 348 |
|
|
| 349 |
|
|
| 350 |
|
|
| 351 |
595695 |
resultMap.put(propertyName, Integer.valueOf(-1)); |
| 352 |
|
} |
| 353 |
|
} |
| 354 |
|
} |
| 355 |
|
} |
| 356 |
|
|
| 357 |
|
|
| 358 |
|
|
| 359 |
|
|
| 360 |
|
@param |
| 361 |
|
@return |
| 362 |
|
|
| |
|
| 91.3% |
Uncovered Elements: 2 (23) |
Complexity: 6 |
Complexity Density: 0.46 |
|
| 363 |
119916 |
protected ResidueCount countResidues(int column)... |
| 364 |
|
{ |
| 365 |
119917 |
ResidueCount values = new ResidueCount(false); |
| 366 |
|
|
| 367 |
1605787 |
for (int row = 0; row < sequences.length; row++) |
| 368 |
|
{ |
| 369 |
1485844 |
if (sequences[row].getLength() > column) |
| 370 |
|
{ |
| 371 |
1460178 |
char c = sequences[row].getCharAt(column); |
| 372 |
1460090 |
if (canonicaliseAa) |
| 373 |
|
{ |
| 374 |
1460094 |
int index = ResidueProperties.aaIndex[c]; |
| 375 |
1460606 |
c = index > 20 ? '-' : ResidueProperties.aa[index].charAt(0); |
| 376 |
|
} |
| 377 |
|
else |
| 378 |
|
{ |
| 379 |
0 |
c = toUpperCase(c); |
| 380 |
|
} |
| 381 |
1460570 |
if (Comparison.isGap(c)) |
| 382 |
|
{ |
| 383 |
293525 |
values.addGap(); |
| 384 |
|
} |
| 385 |
|
else |
| 386 |
|
{ |
| 387 |
1167063 |
values.add(c); |
| 388 |
|
} |
| 389 |
|
} |
| 390 |
|
else |
| 391 |
|
{ |
| 392 |
25702 |
values.addGap(); |
| 393 |
|
} |
| 394 |
|
} |
| 395 |
119918 |
return values; |
| 396 |
|
} |
| 397 |
|
|
| 398 |
|
|
| 399 |
|
|
| 400 |
|
|
| 401 |
|
@return |
| 402 |
|
|
| |
|
| 94.1% |
Uncovered Elements: 2 (34) |
Complexity: 8 |
Complexity Density: 0.4 |
|
| 403 |
119923 |
public int[] countConservationAndGaps(int column)... |
| 404 |
|
{ |
| 405 |
119923 |
int gapCount = 0; |
| 406 |
119923 |
boolean fullyConserved = true; |
| 407 |
119922 |
int iSize = sequences.length; |
| 408 |
|
|
| 409 |
119922 |
if (iSize == 0) |
| 410 |
|
{ |
| 411 |
0 |
return new int[] { 0, 0 }; |
| 412 |
|
} |
| 413 |
|
|
| 414 |
119922 |
char lastRes = '0'; |
| 415 |
1605645 |
for (int i = 0; i < iSize; i++) |
| 416 |
|
{ |
| 417 |
1485610 |
if (column >= sequences[i].getLength()) |
| 418 |
|
{ |
| 419 |
25702 |
gapCount++; |
| 420 |
25702 |
continue; |
| 421 |
|
} |
| 422 |
|
|
| 423 |
1459915 |
char c = sequences[i].getCharAt(column); |
| 424 |
|
|
| 425 |
|
|
| 426 |
1460345 |
if (Comparison.isGap((c))) |
| 427 |
|
{ |
| 428 |
293478 |
gapCount++; |
| 429 |
|
} |
| 430 |
|
else |
| 431 |
|
{ |
| 432 |
1166866 |
c = toUpperCase(c); |
| 433 |
1167086 |
if (lastRes == '0') |
| 434 |
|
{ |
| 435 |
115345 |
lastRes = c; |
| 436 |
|
} |
| 437 |
1167650 |
if (c != lastRes) |
| 438 |
|
{ |
| 439 |
359338 |
fullyConserved = false; |
| 440 |
|
} |
| 441 |
|
} |
| 442 |
|
} |
| 443 |
|
|
| 444 |
119922 |
int[] r = new int[] { fullyConserved ? 1 : 0, gapCount }; |
| 445 |
119916 |
return r; |
| 446 |
|
} |
| 447 |
|
|
| 448 |
|
|
| 449 |
|
|
| 450 |
|
|
| 451 |
|
|
| 452 |
|
@param |
| 453 |
|
@return |
| 454 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 455 |
1166858 |
char toUpperCase(char c)... |
| 456 |
|
{ |
| 457 |
1166865 |
if ('a' <= c && c <= 'z') |
| 458 |
|
{ |
| 459 |
5159 |
c -= TOUPPERCASE; |
| 460 |
|
} |
| 461 |
1166885 |
return c; |
| 462 |
|
} |
| 463 |
|
|
| 464 |
|
|
| 465 |
|
|
| 466 |
|
|
| 467 |
|
@param |
| 468 |
|
|
| 469 |
|
|
| 470 |
|
@param |
| 471 |
|
|
| 472 |
|
|
| 473 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (55) |
Complexity: 13 |
Complexity Density: 0.39 |
|
| 474 |
888 |
public void verdict(boolean positiveOnly, float maxPercentageGaps)... |
| 475 |
|
{ |
| 476 |
|
|
| 477 |
|
|
| 478 |
888 |
StringBuilder consString = new StringBuilder(end); |
| 479 |
|
|
| 480 |
|
|
| 481 |
|
|
| 482 |
|
|
| 483 |
978 |
for (int i = 0; i < start; i++) |
| 484 |
|
{ |
| 485 |
90 |
consString.append('-'); |
| 486 |
|
} |
| 487 |
888 |
consSymbs = new String[end - start + 1]; |
| 488 |
120807 |
for (int i = start; i <= end; i++) |
| 489 |
|
{ |
| 490 |
119919 |
int[] gapcons = countConservationAndGaps(i); |
| 491 |
119912 |
boolean fullyConserved = gapcons[0] == 1; |
| 492 |
119913 |
int totGaps = gapcons[1]; |
| 493 |
119913 |
float pgaps = (totGaps * 100f) / sequences.length; |
| 494 |
|
|
| 495 |
119920 |
if (maxPercentageGaps > pgaps) |
| 496 |
|
{ |
| 497 |
87597 |
Map<String, Integer> resultHash = total[i - start]; |
| 498 |
87598 |
int count = 0; |
| 499 |
87598 |
StringBuilder positives = new StringBuilder(64); |
| 500 |
87600 |
StringBuilder negatives = new StringBuilder(32); |
| 501 |
87600 |
for (String type : resultHash.keySet()) |
| 502 |
|
{ |
| 503 |
875751 |
int result = resultHash.get(type).intValue(); |
| 504 |
875936 |
if (result == -1) |
| 505 |
|
{ |
| 506 |
|
|
| 507 |
|
|
| 508 |
|
|
| 509 |
367735 |
continue; |
| 510 |
|
} |
| 511 |
508156 |
count++; |
| 512 |
508202 |
if (result == 1) |
| 513 |
|
{ |
| 514 |
|
|
| 515 |
|
|
| 516 |
|
|
| 517 |
155897 |
positives.append(positives.length() == 0 ? "" : " "); |
| 518 |
155897 |
positives.append(type); |
| 519 |
|
} |
| 520 |
508216 |
if (result == 0 && !positiveOnly) |
| 521 |
|
{ |
| 522 |
|
|
| 523 |
|
|
| 524 |
|
|
| 525 |
352324 |
negatives.append(negatives.length() == 0 ? "" : " "); |
| 526 |
352320 |
negatives.append("!").append(type); |
| 527 |
|
} |
| 528 |
|
} |
| 529 |
87600 |
if (negatives.length() > 0) |
| 530 |
|
{ |
| 531 |
55142 |
positives.append(" ").append(negatives); |
| 532 |
|
} |
| 533 |
87595 |
consSymbs[i - start] = positives.toString(); |
| 534 |
|
|
| 535 |
87598 |
if (count < 10) |
| 536 |
|
{ |
| 537 |
54311 |
consString.append(count); |
| 538 |
|
} |
| 539 |
|
else |
| 540 |
|
{ |
| 541 |
33285 |
consString.append(fullyConserved ? "*" : "+"); |
| 542 |
|
} |
| 543 |
|
} |
| 544 |
|
else |
| 545 |
|
{ |
| 546 |
32325 |
consString.append('-'); |
| 547 |
|
} |
| 548 |
|
} |
| 549 |
|
|
| 550 |
888 |
consSequence = new Sequence(name, consString.toString(), start, end); |
| 551 |
|
} |
| 552 |
|
|
| 553 |
|
|
| 554 |
|
|
| 555 |
|
|
| 556 |
|
@return |
| 557 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 558 |
905 |
public SequenceI getConsSequence()... |
| 559 |
|
{ |
| 560 |
905 |
return consSequence; |
| 561 |
|
} |
| 562 |
|
|
| 563 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 564 |
876 |
public void findQuality()... |
| 565 |
|
{ |
| 566 |
876 |
findQuality(0, maxLength - 1, getQualitySubstMat()); |
| 567 |
|
} |
| 568 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 569 |
876 |
public ScoreMatrix getQualitySubstMat()... |
| 570 |
|
{ |
| 571 |
876 |
return sm; |
| 572 |
|
} |
| 573 |
|
|
| 574 |
|
|
| 575 |
|
|
| 576 |
|
|
| 577 |
|
private ScoreMatrix sm = ScoreModels.getInstance().getBlosum62(); |
| 578 |
|
|
| 579 |
|
|
| 580 |
|
|
| 581 |
|
|
| 582 |
|
@param |
| 583 |
|
|
| 584 |
|
|
| 585 |
|
|
| |
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
| 586 |
876 |
public void setQualitySubstMat(ScoreMatrix scoreMatrix)... |
| 587 |
|
{ |
| 588 |
876 |
if (scoreMatrix != null && scoreMatrix.isProtein()) |
| 589 |
|
{ |
| 590 |
876 |
sm = scoreMatrix; |
| 591 |
|
} |
| 592 |
|
} |
| 593 |
|
|
| 594 |
|
|
| 595 |
|
|
| 596 |
|
|
| 597 |
|
@param |
| 598 |
|
|
| |
|
| 96.7% |
Uncovered Elements: 1 (30) |
Complexity: 8 |
Complexity Density: 0.44 |
|
| 599 |
876 |
private void percentIdentity(ScoreMatrix sm)... |
| 600 |
|
{ |
| 601 |
876 |
seqNums = new Vector<>(); |
| 602 |
876 |
int i = 0, iSize = sequences.length; |
| 603 |
|
|
| 604 |
9853 |
for (i = 0; i < iSize; i++) |
| 605 |
|
{ |
| 606 |
8977 |
calcSeqNum(i, sm); |
| 607 |
|
} |
| 608 |
|
|
| 609 |
876 |
if ((cons2 == null) || seqNumsChanged) |
| 610 |
|
{ |
| 611 |
|
|
| 612 |
|
|
| 613 |
876 |
cons2 = new int[maxLength][24]; |
| 614 |
876 |
cons2GapCounts = new int[maxLength]; |
| 615 |
|
|
| 616 |
876 |
int j = 0; |
| 617 |
|
|
| 618 |
9853 |
while (j < sequences.length) |
| 619 |
|
{ |
| 620 |
8977 |
int[] sqnum = seqNums.elementAt(j); |
| 621 |
|
|
| 622 |
1463543 |
for (i = 1; i < sqnum.length; i++) |
| 623 |
|
{ |
| 624 |
1454566 |
int index = sqnum[i]; |
| 625 |
1454566 |
if (index == GAP_INDEX) |
| 626 |
|
{ |
| 627 |
292356 |
cons2GapCounts[i - 1]++; |
| 628 |
|
} |
| 629 |
|
else |
| 630 |
|
{ |
| 631 |
1162210 |
cons2[i - 1][index]++; |
| 632 |
|
} |
| 633 |
|
} |
| 634 |
|
|
| 635 |
|
|
| 636 |
34634 |
for (i = sqnum.length - 1; i < maxLength; i++) |
| 637 |
|
{ |
| 638 |
25657 |
cons2GapCounts[i]++; |
| 639 |
|
} |
| 640 |
8977 |
j++; |
| 641 |
|
} |
| 642 |
|
} |
| 643 |
|
} |
| 644 |
|
|
| 645 |
|
|
| 646 |
|
|
| 647 |
|
|
| 648 |
|
|
| 649 |
|
@param |
| 650 |
|
@param |
| 651 |
|
@param |
| 652 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (61) |
Complexity: 11 |
Complexity Density: 0.27 |
|
| 653 |
876 |
protected void findQuality(int startCol, int endCol,... |
| 654 |
|
ScoreMatrix scoreMatrix) |
| 655 |
|
{ |
| 656 |
876 |
quality = new Vector<>(); |
| 657 |
|
|
| 658 |
876 |
double max = -Double.MAX_VALUE; |
| 659 |
876 |
float[][] scores = scoreMatrix.getMatrix(); |
| 660 |
|
|
| 661 |
876 |
percentIdentity(scoreMatrix); |
| 662 |
|
|
| 663 |
876 |
int size = seqNums.size(); |
| 664 |
876 |
int[] lengths = new int[size]; |
| 665 |
|
|
| 666 |
9853 |
for (int l = 0; l < size; l++) |
| 667 |
|
{ |
| 668 |
8977 |
lengths[l] = seqNums.elementAt(l).length - 1; |
| 669 |
|
} |
| 670 |
|
|
| 671 |
876 |
final int symbolCount = scoreMatrix.getSize(); |
| 672 |
|
|
| 673 |
119840 |
for (int j = startCol; j <= endCol; j++) |
| 674 |
|
{ |
| 675 |
118965 |
double bigtot = 0; |
| 676 |
|
|
| 677 |
|
|
| 678 |
118966 |
double[] x = new double[symbolCount]; |
| 679 |
|
|
| 680 |
2968980 |
for (int ii = 0; ii < symbolCount; ii++) |
| 681 |
|
{ |
| 682 |
2850062 |
x[ii] = 0; |
| 683 |
|
|
| 684 |
|
|
| 685 |
|
|
| 686 |
|
|
| 687 |
|
|
| 688 |
|
|
| 689 |
68235236 |
for (int i2 = 0; i2 < symbolCount - 1; i2++) |
| 690 |
|
{ |
| 691 |
65408282 |
x[ii] += (((double) cons2[j][i2] * scores[ii][i2]) + 4D); |
| 692 |
|
} |
| 693 |
2849153 |
x[ii] += 4D + cons2GapCounts[j] * scoreMatrix.getMinimumScore(); |
| 694 |
|
|
| 695 |
2849722 |
x[ii] /= size; |
| 696 |
|
} |
| 697 |
|
|
| 698 |
|
|
| 699 |
1596808 |
for (int k = 0; k < size; k++) |
| 700 |
|
{ |
| 701 |
1477890 |
double tot = 0; |
| 702 |
1477979 |
double[] xx = new double[symbolCount]; |
| 703 |
|
|
| 704 |
1477301 |
int seqNum = (j < lengths[k]) ? seqNums.elementAt(k)[j + 1] |
| 705 |
|
: GAP_INDEX; |
| 706 |
|
|
| 707 |
35111581 |
for (int i = 0; i < symbolCount - 1; i++) |
| 708 |
|
{ |
| 709 |
33741860 |
double sr = 4D; |
| 710 |
33743734 |
if (seqNum == GAP_INDEX) |
| 711 |
|
{ |
| 712 |
7303733 |
sr += scoreMatrix.getMinimumScore(); |
| 713 |
|
} |
| 714 |
|
else |
| 715 |
|
{ |
| 716 |
26491349 |
sr += scores[i][seqNum]; |
| 717 |
|
} |
| 718 |
|
|
| 719 |
33765554 |
xx[i] = x[i] - sr; |
| 720 |
|
|
| 721 |
33810158 |
tot += (xx[i] * xx[i]); |
| 722 |
|
} |
| 723 |
|
|
| 724 |
1478086 |
bigtot += Math.sqrt(tot); |
| 725 |
|
} |
| 726 |
|
|
| 727 |
118960 |
max = Math.max(max, bigtot); |
| 728 |
|
|
| 729 |
118961 |
quality.addElement(Double.valueOf(bigtot)); |
| 730 |
|
} |
| 731 |
|
|
| 732 |
875 |
double newmax = -Double.MAX_VALUE; |
| 733 |
|
|
| 734 |
119777 |
for (int j = startCol; j <= endCol; j++) |
| 735 |
|
{ |
| 736 |
118902 |
double tmp = quality.elementAt(j).doubleValue(); |
| 737 |
|
|
| 738 |
118902 |
tmp = ((max - tmp) * (size - cons2GapCounts[j])) / size; |
| 739 |
|
|
| 740 |
|
|
| 741 |
118902 |
quality.setElementAt(Double.valueOf(tmp), j); |
| 742 |
|
|
| 743 |
118902 |
if (tmp > newmax) |
| 744 |
|
{ |
| 745 |
2336 |
newmax = tmp; |
| 746 |
|
} |
| 747 |
|
} |
| 748 |
|
|
| 749 |
875 |
qualityMinimum = 0D; |
| 750 |
875 |
qualityMaximum = newmax; |
| 751 |
|
} |
| 752 |
|
|
| 753 |
|
|
| 754 |
|
|
| 755 |
|
|
| 756 |
|
|
| 757 |
|
|
| 758 |
|
@param |
| 759 |
|
|
| 760 |
|
@param |
| 761 |
|
|
| 762 |
|
@param |
| 763 |
|
|
| 764 |
|
@param |
| 765 |
|
|
| 766 |
|
|
| |
|
| 95.6% |
Uncovered Elements: 3 (68) |
Complexity: 18 |
Complexity Density: 0.41 |
|
| 767 |
875 |
public void completeAnnotations(AlignmentAnnotation conservation,... |
| 768 |
|
AlignmentAnnotation quality2, int istart, int alWidth) |
| 769 |
|
{ |
| 770 |
875 |
SequenceI cons = getConsSequence(); |
| 771 |
|
|
| 772 |
|
|
| 773 |
|
|
| 774 |
|
|
| 775 |
875 |
float minR = 0.3f; |
| 776 |
875 |
float minG = 0.0f; |
| 777 |
875 |
float minB = 0f; |
| 778 |
875 |
float maxR = 1.0f - minR; |
| 779 |
875 |
float maxG = 0.9f - minG; |
| 780 |
875 |
float maxB = 0f - minB; |
| 781 |
|
|
| 782 |
875 |
float min = 0f; |
| 783 |
875 |
float max = 11f; |
| 784 |
875 |
float qmin = 0f; |
| 785 |
875 |
float qmax = 0f; |
| 786 |
875 |
if (conservation!=null) |
| 787 |
|
{ |
| 788 |
873 |
conservation.setNoOfSequencesIncluded(sequences.length); |
| 789 |
|
} |
| 790 |
875 |
if (quality2!=null) |
| 791 |
|
{ |
| 792 |
875 |
quality2.setNoOfSequencesIncluded(sequences.length); |
| 793 |
|
} |
| 794 |
|
|
| 795 |
875 |
if (conservation != null && conservation.annotations != null |
| 796 |
|
&& conservation.annotations.length != alWidth) |
| 797 |
|
{ |
| 798 |
396 |
conservation.annotations = new Annotation[alWidth]; |
| 799 |
|
} |
| 800 |
|
|
| 801 |
875 |
if (quality2 != null) |
| 802 |
|
{ |
| 803 |
875 |
quality2.graphMax = (float) qualityMaximum; |
| 804 |
875 |
if (quality2.annotations != null |
| 805 |
|
&& quality2.annotations.length != alWidth) |
| 806 |
|
{ |
| 807 |
397 |
quality2.annotations = new Annotation[alWidth]; |
| 808 |
|
} |
| 809 |
875 |
qmin = (float) qualityMinimum; |
| 810 |
875 |
qmax = (float) qualityMaximum; |
| 811 |
|
} |
| 812 |
|
|
| 813 |
119385 |
for (int i = istart; i < alWidth; i++) |
| 814 |
|
{ |
| 815 |
118513 |
float value = 0; |
| 816 |
|
|
| 817 |
118513 |
char c = cons.getCharAt(i); |
| 818 |
|
|
| 819 |
118513 |
if (Character.isDigit(c)) |
| 820 |
|
{ |
| 821 |
53692 |
value = c - '0'; |
| 822 |
|
} |
| 823 |
64821 |
else if (c == '*') |
| 824 |
|
{ |
| 825 |
32768 |
value = 11; |
| 826 |
|
} |
| 827 |
32053 |
else if (c == '+') |
| 828 |
|
{ |
| 829 |
89 |
value = 10; |
| 830 |
|
} |
| 831 |
|
|
| 832 |
118513 |
if (conservation != null) |
| 833 |
|
{ |
| 834 |
118199 |
float vprop = value - min; |
| 835 |
118199 |
vprop /= max; |
| 836 |
118199 |
int consp = i - start; |
| 837 |
118199 |
String conssym = (value > 0 && consp > -1 |
| 838 |
|
&& consp < consSymbs.length) ? consSymbs[consp] : ""; |
| 839 |
118199 |
conservation.annotations[i] = new Annotation(String.valueOf(c), |
| 840 |
|
conssym, ' ', value, new Color(minR + (maxR * vprop), |
| 841 |
|
minG + (maxG * vprop), minB + (maxB * vprop))); |
| 842 |
|
} |
| 843 |
|
|
| 844 |
|
|
| 845 |
118512 |
if (quality2 != null) |
| 846 |
|
{ |
| 847 |
118512 |
value = quality.elementAt(i).floatValue(); |
| 848 |
118512 |
float vprop = value - qmin; |
| 849 |
118512 |
vprop /= qmax; |
| 850 |
118512 |
String description = FORMAT_3DP.form(value); |
| 851 |
118510 |
quality2.annotations[i] = new Annotation(" ", description, ' ', |
| 852 |
|
value, new Color(minR + (maxR * vprop), |
| 853 |
|
minG + (maxG * vprop), minB + (maxB * vprop))); |
| 854 |
|
} |
| 855 |
|
} |
| 856 |
|
} |
| 857 |
|
|
| 858 |
|
|
| 859 |
|
|
| 860 |
|
|
| 861 |
|
@param |
| 862 |
|
|
| 863 |
|
@param |
| 864 |
|
@param |
| 865 |
|
|
| 866 |
|
@param |
| 867 |
|
|
| 868 |
|
@param |
| 869 |
|
|
| 870 |
|
|
| 871 |
|
@param |
| 872 |
|
|
| 873 |
|
@param |
| 874 |
|
|
| 875 |
|
@return |
| 876 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 877 |
3 |
public static Conservation calculateConservation(String name,... |
| 878 |
|
List<SequenceI> seqs, int start, int end, boolean positiveOnly, |
| 879 |
|
int maxPercentGaps, boolean calcQuality) |
| 880 |
|
{ |
| 881 |
3 |
return calculateConservation(name, seqs, start, end, positiveOnly, |
| 882 |
|
maxPercentGaps, calcQuality, null); |
| 883 |
|
} |
| 884 |
|
|
| 885 |
|
|
| 886 |
|
|
| 887 |
|
|
| 888 |
|
@param |
| 889 |
|
|
| 890 |
|
@param |
| 891 |
|
@param |
| 892 |
|
|
| 893 |
|
@param |
| 894 |
|
|
| 895 |
|
@param |
| 896 |
|
|
| 897 |
|
|
| 898 |
|
@param |
| 899 |
|
|
| 900 |
|
@param |
| 901 |
|
|
| 902 |
|
@param |
| 903 |
|
|
| 904 |
|
@return |
| 905 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 906 |
879 |
public static Conservation calculateConservation(String name,... |
| 907 |
|
List<SequenceI> seqs, int start, int end, boolean positiveOnly, |
| 908 |
|
int maxPercentGaps, boolean calcQuality, ScoreMatrix scoreMatrix) |
| 909 |
|
{ |
| 910 |
879 |
Conservation cons = new Conservation(name, seqs, start, end); |
| 911 |
879 |
if (scoreMatrix != null) |
| 912 |
|
{ |
| 913 |
876 |
cons.setQualitySubstMat(scoreMatrix); |
| 914 |
|
} |
| 915 |
879 |
cons.calculate(); |
| 916 |
879 |
cons.verdict(positiveOnly, maxPercentGaps); |
| 917 |
|
|
| 918 |
879 |
if (calcQuality) |
| 919 |
|
{ |
| 920 |
876 |
cons.findQuality(); |
| 921 |
|
} |
| 922 |
|
|
| 923 |
878 |
return cons; |
| 924 |
|
} |
| 925 |
|
|
| 926 |
|
|
| 927 |
|
|
| 928 |
|
|
| 929 |
|
|
| 930 |
|
|
| 931 |
|
|
| 932 |
|
@param |
| 933 |
|
@return |
| 934 |
|
|
| |
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 5 |
Complexity Density: 0.83 |
|
| 935 |
7 |
String getTooltip(int column)... |
| 936 |
|
{ |
| 937 |
7 |
SequenceI cons = getConsSequence(); |
| 938 |
7 |
char val = column < cons.getLength() ? cons.getCharAt(column) : '-'; |
| 939 |
7 |
boolean hasConservation = val != '-' && val != '0'; |
| 940 |
7 |
int consp = column - start; |
| 941 |
7 |
String tip = (hasConservation && consp > -1 && consp < consSymbs.length) |
| 942 |
|
? consSymbs[consp] |
| 943 |
|
: ""; |
| 944 |
7 |
return tip; |
| 945 |
|
} |
| 946 |
|
} |