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.6% |
Uncovered Elements: 18 (406) |
Complexity: 99 |
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 |
1005 |
public Conservation(String name, List<SequenceI> sequences, int start,... |
131 |
|
int end) |
132 |
|
{ |
133 |
1005 |
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 |
1010 |
public Conservation(String name, int threshold, List<SequenceI> sequences,... |
152 |
|
int start, int end) |
153 |
|
{ |
154 |
1010 |
this.name = name; |
155 |
1010 |
this.threshold = threshold; |
156 |
1009 |
this.start = start; |
157 |
1010 |
this.end = end; |
158 |
|
|
159 |
1010 |
maxLength = end - start + 1; |
160 |
|
|
161 |
|
|
162 |
1009 |
int s, sSize = sequences.size(); |
163 |
1010 |
SequenceI[] sarray = new SequenceI[sSize]; |
164 |
1010 |
this.sequences = sarray; |
165 |
1010 |
try |
166 |
|
{ |
167 |
12378 |
for (s = 0; s < sSize; s++) |
168 |
|
{ |
169 |
11366 |
sarray[s] = sequences.get(s); |
170 |
11368 |
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 |
11295 |
private void calcSeqNum(int i, ScoreMatrix sm)... |
192 |
|
{ |
193 |
11295 |
int sSize = sequences.length; |
194 |
|
|
195 |
11295 |
if ((i > -1) && (i < sSize)) |
196 |
|
{ |
197 |
11295 |
String sq = sequences[i].getSequenceAsString(); |
198 |
|
|
199 |
11295 |
if (seqNums.size() <= i) |
200 |
|
{ |
201 |
11295 |
seqNums.addElement(new int[sq.length() + 1]); |
202 |
|
} |
203 |
|
|
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
|
208 |
11295 |
if (sq.hashCode() != seqNums.elementAt(i)[0]) |
209 |
|
{ |
210 |
11295 |
int j; |
211 |
11295 |
int len; |
212 |
11295 |
seqNumsChanged = true; |
213 |
11295 |
len = sq.length(); |
214 |
|
|
215 |
11295 |
if (maxLength < len) |
216 |
|
{ |
217 |
0 |
maxLength = len; |
218 |
|
} |
219 |
|
|
220 |
11295 |
int[] sqnum = new int[len + 1]; |
221 |
|
|
222 |
11295 |
sqnum[0] = sq.hashCode(); |
223 |
|
|
224 |
1875673 |
for (j = 1; j <= len; j++) |
225 |
|
{ |
226 |
|
|
227 |
1865392 |
char residue = sq.charAt(j - 1); |
228 |
1865169 |
if (Comparison.isGap(residue)) |
229 |
|
{ |
230 |
417949 |
sqnum[j] = GAP_INDEX; |
231 |
|
} |
232 |
|
else |
233 |
|
{ |
234 |
1448124 |
sqnum[j] = sm.getMatrixIndex(residue); |
235 |
1447766 |
if (sqnum[j] == -1) |
236 |
|
{ |
237 |
41 |
sqnum[j] = GAP_INDEX; |
238 |
|
} |
239 |
|
} |
240 |
|
} |
241 |
|
|
242 |
11295 |
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 |
1006 |
public void calculate()... |
261 |
|
{ |
262 |
1006 |
int height = sequences.length; |
263 |
|
|
264 |
1006 |
total = new Map[maxLength]; |
265 |
|
|
266 |
142559 |
for (int column = start; column <= end; column++) |
267 |
|
{ |
268 |
141554 |
ResidueCount values = countResidues(column); |
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 |
141547 |
int thresh = (threshold * height) / 100; |
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
279 |
|
|
280 |
|
|
281 |
141550 |
SortedMap<String, Integer> resultHash = new TreeMap<>(); |
282 |
141553 |
SymbolCounts symbolCounts = values.getSymbolCounts(); |
283 |
141539 |
char[] symbols = symbolCounts.symbols; |
284 |
141550 |
int[] counts = symbolCounts.values; |
285 |
457732 |
for (int j = 0; j < symbols.length; j++) |
286 |
|
{ |
287 |
316187 |
char c = symbols[j]; |
288 |
316196 |
if (counts[j] > thresh) |
289 |
|
{ |
290 |
316208 |
recordConservation(resultHash, String.valueOf(c)); |
291 |
|
} |
292 |
|
} |
293 |
141555 |
if (values.getGapCount() > thresh) |
294 |
|
{ |
295 |
82899 |
recordConservation(resultHash, "-"); |
296 |
|
} |
297 |
|
|
298 |
141552 |
if (total.length > 0) |
299 |
|
{ |
300 |
141553 |
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 |
399044 |
protected static void recordConservation(Map<String, Integer> resultMap,... |
315 |
|
String res) |
316 |
|
{ |
317 |
399055 |
res = res.toUpperCase(Locale.ROOT); |
318 |
399057 |
for (Entry<String, Map<String, Integer>> property : ResidueProperties.propHash |
319 |
|
.entrySet()) |
320 |
|
{ |
321 |
3979925 |
String propertyName = property.getKey(); |
322 |
3981428 |
Integer residuePropertyValue = property.getValue().get(res); |
323 |
|
|
324 |
3989011 |
if (!resultMap.containsKey(propertyName)) |
325 |
|
{ |
326 |
|
|
327 |
|
|
328 |
|
|
329 |
1414923 |
if (residuePropertyValue != null) |
330 |
|
{ |
331 |
1414773 |
resultMap.put(propertyName, residuePropertyValue); |
332 |
|
} |
333 |
|
else |
334 |
|
{ |
335 |
|
|
336 |
|
|
337 |
|
|
338 |
140 |
resultMap.put(propertyName, property.getValue().get("-")); |
339 |
|
} |
340 |
|
} |
341 |
|
else |
342 |
|
{ |
343 |
2573333 |
Integer currentResult = resultMap.get(propertyName); |
344 |
2573231 |
if (currentResult.intValue() != -1 |
345 |
|
&& !currentResult.equals(residuePropertyValue)) |
346 |
|
{ |
347 |
|
|
348 |
|
|
349 |
|
|
350 |
748248 |
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 |
141555 |
protected ResidueCount countResidues(int column)... |
363 |
|
{ |
364 |
141555 |
ResidueCount values = new ResidueCount(false); |
365 |
|
|
366 |
2028279 |
for (int row = 0; row < sequences.length; row++) |
367 |
|
{ |
368 |
1886682 |
if (sequences[row].getLength() > column) |
369 |
|
{ |
370 |
1871697 |
char c = sequences[row].getCharAt(column); |
371 |
1871587 |
if (canonicaliseAa) |
372 |
|
{ |
373 |
1871602 |
int index = ResidueProperties.aaIndex[c]; |
374 |
1872098 |
c = index > 20 ? '-' : ResidueProperties.aa[index].charAt(0); |
375 |
|
} |
376 |
|
else |
377 |
|
{ |
378 |
0 |
c = toUpperCase(c); |
379 |
|
} |
380 |
1872074 |
if (Comparison.isGap(c)) |
381 |
|
{ |
382 |
419220 |
values.addGap(); |
383 |
|
} |
384 |
|
else |
385 |
|
{ |
386 |
1452904 |
values.add(c); |
387 |
|
} |
388 |
|
} |
389 |
|
else |
390 |
|
{ |
391 |
15129 |
values.addGap(); |
392 |
|
} |
393 |
|
} |
394 |
141547 |
return values; |
395 |
|
} |
396 |
|
|
397 |
|
|
398 |
|
|
399 |
|
|
400 |
|
@return |
401 |
|
|
|
|
| 94.1% |
Uncovered Elements: 2 (34) |
Complexity: 8 |
Complexity Density: 0.4 |
|
402 |
141534 |
public int[] countConservationAndGaps(int column)... |
403 |
|
{ |
404 |
141537 |
int gapCount = 0; |
405 |
141540 |
boolean fullyConserved = true; |
406 |
141544 |
int iSize = sequences.length; |
407 |
|
|
408 |
141536 |
if (iSize == 0) |
409 |
|
{ |
410 |
0 |
return new int[] { 0, 0 }; |
411 |
|
} |
412 |
|
|
413 |
141535 |
char lastRes = '0'; |
414 |
2026610 |
for (int i = 0; i < iSize; i++) |
415 |
|
{ |
416 |
1884830 |
if (column >= sequences[i].getLength()) |
417 |
|
{ |
418 |
15129 |
gapCount++; |
419 |
15129 |
continue; |
420 |
|
} |
421 |
|
|
422 |
1869751 |
char c = sequences[i].getCharAt(column); |
423 |
|
|
424 |
|
|
425 |
1871129 |
if (Comparison.isGap((c))) |
426 |
|
{ |
427 |
419122 |
gapCount++; |
428 |
|
} |
429 |
|
else |
430 |
|
{ |
431 |
1452013 |
c = toUpperCase(c); |
432 |
1452473 |
if (lastRes == '0') |
433 |
|
{ |
434 |
134112 |
lastRes = c; |
435 |
|
} |
436 |
1453260 |
if (c != lastRes) |
437 |
|
{ |
438 |
457619 |
fullyConserved = false; |
439 |
|
} |
440 |
|
} |
441 |
|
} |
442 |
|
|
443 |
141535 |
int[] r = new int[] { fullyConserved ? 1 : 0, gapCount }; |
444 |
141525 |
return r; |
445 |
|
} |
446 |
|
|
447 |
|
|
448 |
|
|
449 |
|
|
450 |
|
|
451 |
|
@param |
452 |
|
@return |
453 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
454 |
1452041 |
char toUpperCase(char c)... |
455 |
|
{ |
456 |
1452179 |
if ('a' <= c && c <= 'z') |
457 |
|
{ |
458 |
6813 |
c -= TOUPPERCASE; |
459 |
|
} |
460 |
1452258 |
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 |
1004 |
public void verdict(boolean positiveOnly, float maxPercentageGaps)... |
474 |
|
{ |
475 |
|
|
476 |
|
|
477 |
1004 |
StringBuilder consString = new StringBuilder(end); |
478 |
|
|
479 |
|
|
480 |
|
|
481 |
|
|
482 |
1094 |
for (int i = 0; i < start; i++) |
483 |
|
{ |
484 |
90 |
consString.append('-'); |
485 |
|
} |
486 |
1004 |
consSymbs = new String[end - start + 1]; |
487 |
142528 |
for (int i = start; i <= end; i++) |
488 |
|
{ |
489 |
141529 |
int[] gapcons = countConservationAndGaps(i); |
490 |
141523 |
boolean fullyConserved = gapcons[0] == 1; |
491 |
141536 |
int totGaps = gapcons[1]; |
492 |
141544 |
float pgaps = (totGaps * 100f) / sequences.length; |
493 |
|
|
494 |
141542 |
if (maxPercentageGaps > pgaps) |
495 |
|
{ |
496 |
99619 |
Map<String, Integer> resultHash = total[i - start]; |
497 |
99618 |
int count = 0; |
498 |
99618 |
StringBuilder positives = new StringBuilder(64); |
499 |
99620 |
StringBuilder negatives = new StringBuilder(32); |
500 |
99620 |
for (String type : resultHash.keySet()) |
501 |
|
{ |
502 |
995338 |
int result = resultHash.get(type).intValue(); |
503 |
996045 |
if (result == -1) |
504 |
|
{ |
505 |
|
|
506 |
|
|
507 |
|
|
508 |
461814 |
continue; |
509 |
|
} |
510 |
534064 |
count++; |
511 |
534210 |
if (result == 1) |
512 |
|
{ |
513 |
|
|
514 |
|
|
515 |
|
|
516 |
167795 |
positives.append(positives.length() == 0 ? "" : " "); |
517 |
167792 |
positives.append(type); |
518 |
|
} |
519 |
534224 |
if (result == 0 && !positiveOnly) |
520 |
|
{ |
521 |
|
|
522 |
|
|
523 |
|
|
524 |
366446 |
negatives.append(negatives.length() == 0 ? "" : " "); |
525 |
366449 |
negatives.append("!").append(type); |
526 |
|
} |
527 |
|
} |
528 |
99619 |
if (negatives.length() > 0) |
529 |
|
{ |
530 |
58471 |
positives.append(" ").append(negatives); |
531 |
|
} |
532 |
99618 |
consSymbs[i - start] = positives.toString(); |
533 |
|
|
534 |
99620 |
if (count < 10) |
535 |
|
{ |
536 |
67966 |
consString.append(count); |
537 |
|
} |
538 |
|
else |
539 |
|
{ |
540 |
31652 |
consString.append(fullyConserved ? "*" : "+"); |
541 |
|
} |
542 |
|
} |
543 |
|
else |
544 |
|
{ |
545 |
41924 |
consString.append('-'); |
546 |
|
} |
547 |
|
} |
548 |
|
|
549 |
1004 |
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 |
1021 |
public SequenceI getConsSequence()... |
558 |
|
{ |
559 |
1021 |
return consSequence; |
560 |
|
} |
561 |
|
|
562 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
563 |
992 |
public void findQuality()... |
564 |
|
{ |
565 |
992 |
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 |
992 |
private void percentIdentity(ScoreMatrix sm)... |
574 |
|
{ |
575 |
992 |
seqNums = new Vector<>(); |
576 |
992 |
int i = 0, iSize = sequences.length; |
577 |
|
|
578 |
12287 |
for (i = 0; i < iSize; i++) |
579 |
|
{ |
580 |
11295 |
calcSeqNum(i, sm); |
581 |
|
} |
582 |
|
|
583 |
992 |
if ((cons2 == null) || seqNumsChanged) |
584 |
|
{ |
585 |
|
|
586 |
|
|
587 |
992 |
cons2 = new int[maxLength][24]; |
588 |
992 |
cons2GapCounts = new int[maxLength]; |
589 |
|
|
590 |
992 |
int j = 0; |
591 |
|
|
592 |
12287 |
while (j < sequences.length) |
593 |
|
{ |
594 |
11295 |
int[] sqnum = seqNums.elementAt(j); |
595 |
|
|
596 |
1871080 |
for (i = 1; i < sqnum.length; i++) |
597 |
|
{ |
598 |
1859882 |
int index = sqnum[i]; |
599 |
1861729 |
if (index == GAP_INDEX) |
600 |
|
{ |
601 |
417909 |
cons2GapCounts[i - 1]++; |
602 |
|
} |
603 |
|
else |
604 |
|
{ |
605 |
1443975 |
cons2[i - 1][index]++; |
606 |
|
} |
607 |
|
} |
608 |
|
|
609 |
|
|
610 |
26379 |
for (i = sqnum.length - 1; i < maxLength; i++) |
611 |
|
{ |
612 |
15084 |
cons2GapCounts[i]++; |
613 |
|
} |
614 |
11295 |
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 |
992 |
protected void findQuality(int startCol, int endCol,... |
628 |
|
ScoreMatrix scoreMatrix) |
629 |
|
{ |
630 |
992 |
quality = new Vector<>(); |
631 |
|
|
632 |
992 |
double max = -Double.MAX_VALUE; |
633 |
992 |
float[][] scores = scoreMatrix.getMatrix(); |
634 |
|
|
635 |
992 |
percentIdentity(scoreMatrix); |
636 |
|
|
637 |
992 |
int size = seqNums.size(); |
638 |
992 |
int[] lengths = new int[size]; |
639 |
|
|
640 |
12284 |
for (int l = 0; l < size; l++) |
641 |
|
{ |
642 |
11295 |
lengths[l] = seqNums.elementAt(l).length - 1; |
643 |
|
} |
644 |
|
|
645 |
992 |
final int symbolCount = scoreMatrix.getSize(); |
646 |
|
|
647 |
141655 |
for (int j = startCol; j <= endCol; j++) |
648 |
|
{ |
649 |
140668 |
double bigtot = 0; |
650 |
|
|
651 |
|
|
652 |
140670 |
double[] x = new double[symbolCount]; |
653 |
|
|
654 |
3500936 |
for (int ii = 0; ii < symbolCount; ii++) |
655 |
|
{ |
656 |
3361201 |
x[ii] = 0; |
657 |
|
|
658 |
|
|
659 |
|
|
660 |
|
|
661 |
|
|
662 |
|
|
663 |
78027057 |
for (int i2 = 0; i2 < symbolCount - 1; i2++) |
664 |
|
{ |
665 |
74668491 |
x[ii] += (((double) cons2[j][i2] * scores[ii][i2]) + 4D); |
666 |
|
} |
667 |
3357450 |
x[ii] += 4D + cons2GapCounts[j] * scoreMatrix.getMinimumScore(); |
668 |
|
|
669 |
3360318 |
x[ii] /= size; |
670 |
|
} |
671 |
|
|
672 |
|
|
673 |
2019056 |
for (int k = 0; k < size; k++) |
674 |
|
{ |
675 |
1878609 |
double tot = 0; |
676 |
1878932 |
double[] xx = new double[symbolCount]; |
677 |
|
|
678 |
1879805 |
int seqNum = (j < lengths[k]) ? seqNums.elementAt(k)[j + 1] |
679 |
|
: GAP_INDEX; |
680 |
|
|
681 |
44525869 |
for (int i = 0; i < symbolCount - 1; i++) |
682 |
|
{ |
683 |
42784483 |
double sr = 4D; |
684 |
42712784 |
if (seqNum == GAP_INDEX) |
685 |
|
{ |
686 |
9944414 |
sr += scoreMatrix.getMinimumScore(); |
687 |
|
} |
688 |
|
else |
689 |
|
{ |
690 |
32952333 |
sr += scores[i][seqNum]; |
691 |
|
} |
692 |
|
|
693 |
42666250 |
xx[i] = x[i] - sr; |
694 |
|
|
695 |
42823196 |
tot += (xx[i] * xx[i]); |
696 |
|
} |
697 |
|
|
698 |
1878637 |
bigtot += Math.sqrt(tot); |
699 |
|
} |
700 |
|
|
701 |
140655 |
max = Math.max(max, bigtot); |
702 |
|
|
703 |
140662 |
quality.addElement(Double.valueOf(bigtot)); |
704 |
|
} |
705 |
|
|
706 |
992 |
double newmax = -Double.MAX_VALUE; |
707 |
|
|
708 |
141621 |
for (int j = startCol; j <= endCol; j++) |
709 |
|
{ |
710 |
140624 |
double tmp = quality.elementAt(j).doubleValue(); |
711 |
|
|
712 |
140634 |
tmp = ((max - tmp) * (size - cons2GapCounts[j])) / size; |
713 |
|
|
714 |
|
|
715 |
140630 |
quality.setElementAt(Double.valueOf(tmp), j); |
716 |
|
|
717 |
140633 |
if (tmp > newmax) |
718 |
|
{ |
719 |
2722 |
newmax = tmp; |
720 |
|
} |
721 |
|
} |
722 |
|
|
723 |
992 |
qualityMinimum = 0D; |
724 |
992 |
qualityMaximum = newmax; |
725 |
|
} |
726 |
|
|
727 |
|
|
728 |
|
|
729 |
|
|
730 |
|
|
731 |
|
|
732 |
|
@param |
733 |
|
|
734 |
|
@param |
735 |
|
|
736 |
|
@param |
737 |
|
|
738 |
|
@param |
739 |
|
|
740 |
|
|
|
|
| 96.7% |
Uncovered Elements: 2 (60) |
Complexity: 16 |
Complexity Density: 0.4 |
|
741 |
991 |
public void completeAnnotations(AlignmentAnnotation conservation,... |
742 |
|
AlignmentAnnotation quality2, int istart, int alWidth) |
743 |
|
{ |
744 |
991 |
SequenceI cons = getConsSequence(); |
745 |
|
|
746 |
|
|
747 |
|
|
748 |
|
|
749 |
991 |
float minR = 0.3f; |
750 |
992 |
float minG = 0.0f; |
751 |
991 |
float minB = 0f; |
752 |
991 |
float maxR = 1.0f - minR; |
753 |
991 |
float maxG = 0.9f - minG; |
754 |
992 |
float maxB = 0f - minB; |
755 |
|
|
756 |
992 |
float min = 0f; |
757 |
991 |
float max = 11f; |
758 |
992 |
float qmin = 0f; |
759 |
992 |
float qmax = 0f; |
760 |
|
|
761 |
992 |
if (conservation != null && conservation.annotations != null |
762 |
|
&& conservation.annotations.length != alWidth) |
763 |
|
{ |
764 |
368 |
conservation.annotations = new Annotation[alWidth]; |
765 |
|
} |
766 |
|
|
767 |
992 |
if (quality2 != null) |
768 |
|
{ |
769 |
992 |
quality2.graphMax = (float) qualityMaximum; |
770 |
991 |
if (quality2.annotations != null |
771 |
|
&& quality2.annotations.length != alWidth) |
772 |
|
{ |
773 |
369 |
quality2.annotations = new Annotation[alWidth]; |
774 |
|
} |
775 |
992 |
qmin = (float) qualityMinimum; |
776 |
992 |
qmax = (float) qualityMaximum; |
777 |
|
} |
778 |
|
|
779 |
141668 |
for (int i = istart; i < alWidth; i++) |
780 |
|
{ |
781 |
140677 |
float value = 0; |
782 |
|
|
783 |
140677 |
char c = cons.getCharAt(i); |
784 |
|
|
785 |
140674 |
if (Character.isDigit(c)) |
786 |
|
{ |
787 |
67677 |
value = c - '0'; |
788 |
|
} |
789 |
73000 |
else if (c == '*') |
790 |
|
{ |
791 |
31263 |
value = 11; |
792 |
|
} |
793 |
41737 |
else if (c == '+') |
794 |
|
{ |
795 |
92 |
value = 10; |
796 |
|
} |
797 |
|
|
798 |
140675 |
if (conservation != null) |
799 |
|
{ |
800 |
140515 |
float vprop = value - min; |
801 |
140519 |
vprop /= max; |
802 |
140514 |
int consp = i - start; |
803 |
140518 |
String conssym = (value > 0 && consp > -1 |
804 |
|
&& consp < consSymbs.length) ? consSymbs[consp] : ""; |
805 |
140513 |
conservation.annotations[i] = new Annotation(String.valueOf(c), |
806 |
|
conssym, ' ', value, new Color(minR + (maxR * vprop), |
807 |
|
minG + (maxG * vprop), minB + (maxB * vprop))); |
808 |
|
} |
809 |
|
|
810 |
|
|
811 |
140677 |
if (quality2 != null) |
812 |
|
{ |
813 |
140676 |
value = quality.elementAt(i).floatValue(); |
814 |
140678 |
float vprop = value - qmin; |
815 |
140679 |
vprop /= qmax; |
816 |
140679 |
String description = FORMAT_3DP.form(value); |
817 |
140677 |
quality2.annotations[i] = new Annotation(" ", description, ' ', |
818 |
|
value, new Color(minR + (maxR * vprop), |
819 |
|
minG + (maxG * vprop), minB + (maxB * vprop))); |
820 |
|
} |
821 |
|
} |
822 |
|
} |
823 |
|
|
824 |
|
|
825 |
|
|
826 |
|
|
827 |
|
@param |
828 |
|
|
829 |
|
@param |
830 |
|
@param |
831 |
|
|
832 |
|
@param |
833 |
|
|
834 |
|
@param |
835 |
|
|
836 |
|
|
837 |
|
@param |
838 |
|
|
839 |
|
@param |
840 |
|
|
841 |
|
@return |
842 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
843 |
995 |
public static Conservation calculateConservation(String name,... |
844 |
|
List<SequenceI> seqs, int start, int end, boolean positiveOnly, |
845 |
|
int maxPercentGaps, boolean calcQuality) |
846 |
|
{ |
847 |
995 |
Conservation cons = new Conservation(name, seqs, start, end); |
848 |
995 |
cons.calculate(); |
849 |
995 |
cons.verdict(positiveOnly, maxPercentGaps); |
850 |
|
|
851 |
995 |
if (calcQuality) |
852 |
|
{ |
853 |
992 |
cons.findQuality(); |
854 |
|
} |
855 |
|
|
856 |
995 |
return cons; |
857 |
|
} |
858 |
|
|
859 |
|
|
860 |
|
|
861 |
|
|
862 |
|
|
863 |
|
|
864 |
|
|
865 |
|
@param |
866 |
|
@return |
867 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 5 |
Complexity Density: 0.83 |
|
868 |
7 |
String getTooltip(int column)... |
869 |
|
{ |
870 |
7 |
SequenceI cons = getConsSequence(); |
871 |
7 |
char val = column < cons.getLength() ? cons.getCharAt(column) : '-'; |
872 |
7 |
boolean hasConservation = val != '-' && val != '0'; |
873 |
7 |
int consp = column - start; |
874 |
7 |
String tip = (hasConservation && consp > -1 && consp < consSymbs.length) |
875 |
|
? consSymbs[consp] |
876 |
|
: ""; |
877 |
7 |
return tip; |
878 |
|
} |
879 |
|
} |