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 jalview.analysis.scoremodels.ScoreMatrix; |
24 |
|
import jalview.analysis.scoremodels.ScoreModels; |
25 |
|
import jalview.datamodel.AlignmentAnnotation; |
26 |
|
import jalview.datamodel.Annotation; |
27 |
|
import jalview.datamodel.ResidueCount; |
28 |
|
import jalview.datamodel.ResidueCount.SymbolCounts; |
29 |
|
import jalview.datamodel.Sequence; |
30 |
|
import jalview.datamodel.SequenceI; |
31 |
|
import jalview.schemes.ResidueProperties; |
32 |
|
import jalview.util.Comparison; |
33 |
|
import jalview.util.Format; |
34 |
|
|
35 |
|
import java.awt.Color; |
36 |
|
import java.util.List; |
37 |
|
import java.util.Map; |
38 |
|
import java.util.Map.Entry; |
39 |
|
import java.util.SortedMap; |
40 |
|
import java.util.TreeMap; |
41 |
|
import java.util.Vector; |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
|
|
| 95.6% |
Uncovered Elements: 18 (406) |
Complexity: 99 |
Complexity Density: 0.4 |
|
46 |
|
public class Conservation |
47 |
|
{ |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
private static final int THRESHOLD_PERCENT = 3; |
53 |
|
|
54 |
|
private static final int TOUPPERCASE = 'a' - 'A'; |
55 |
|
|
56 |
|
private static final int GAP_INDEX = -1; |
57 |
|
|
58 |
|
private static final Format FORMAT_3DP = new Format("%2.5f"); |
59 |
|
|
60 |
|
SequenceI[] sequences; |
61 |
|
|
62 |
|
int start; |
63 |
|
|
64 |
|
int end; |
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
Vector<int[]> seqNums; |
71 |
|
|
72 |
|
int maxLength = 0; |
73 |
|
|
74 |
|
boolean seqNumsChanged = false; |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
Map<String, Integer>[] total; |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
boolean canonicaliseAa = true; |
88 |
|
|
89 |
|
private Vector<Double> quality; |
90 |
|
|
91 |
|
private double qualityMinimum; |
92 |
|
|
93 |
|
private double qualityMaximum; |
94 |
|
|
95 |
|
private Sequence consSequence; |
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
private int threshold; |
101 |
|
|
102 |
|
private String name = ""; |
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
private int[][] cons2; |
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
private int[] cons2GapCounts; |
113 |
|
|
114 |
|
private String[] consSymbs; |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
@param |
120 |
|
|
121 |
|
@param |
122 |
|
|
123 |
|
@param |
124 |
|
|
125 |
|
@param |
126 |
|
|
127 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
128 |
511 |
public Conservation(String name, List<SequenceI> sequences, int start,... |
129 |
|
int end) |
130 |
|
{ |
131 |
511 |
this(name, THRESHOLD_PERCENT, sequences, start, end); |
132 |
|
} |
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
@param |
138 |
|
|
139 |
|
@param |
140 |
|
|
141 |
|
|
142 |
|
@param |
143 |
|
|
144 |
|
@param |
145 |
|
|
146 |
|
@param |
147 |
|
|
148 |
|
|
|
|
| 89.5% |
Uncovered Elements: 2 (19) |
Complexity: 4 |
Complexity Density: 0.27 |
|
149 |
515 |
public Conservation(String name, int threshold, List<SequenceI> sequences,... |
150 |
|
int start, int end) |
151 |
|
{ |
152 |
515 |
this.name = name; |
153 |
515 |
this.threshold = threshold; |
154 |
515 |
this.start = start; |
155 |
515 |
this.end = end; |
156 |
|
|
157 |
515 |
maxLength = end - start + 1; |
158 |
|
|
159 |
|
|
160 |
515 |
int s, sSize = sequences.size(); |
161 |
515 |
SequenceI[] sarray = new SequenceI[sSize]; |
162 |
515 |
this.sequences = sarray; |
163 |
515 |
try |
164 |
|
{ |
165 |
5820 |
for (s = 0; s < sSize; s++) |
166 |
|
{ |
167 |
5305 |
sarray[s] = sequences.get(s); |
168 |
5305 |
if (sarray[s].getLength() > maxLength) |
169 |
|
{ |
170 |
6 |
maxLength = sarray[s].getLength(); |
171 |
|
} |
172 |
|
} |
173 |
|
} catch (ArrayIndexOutOfBoundsException ex) |
174 |
|
{ |
175 |
|
|
176 |
|
|
177 |
0 |
this.sequences = new SequenceI[0]; |
178 |
0 |
maxLength = 0; |
179 |
|
} |
180 |
|
} |
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
@param |
187 |
|
@param |
188 |
|
|
|
|
| 81.6% |
Uncovered Elements: 7 (38) |
Complexity: 9 |
Complexity Density: 0.38 |
|
189 |
5231 |
private void calcSeqNum(int i, ScoreMatrix sm)... |
190 |
|
{ |
191 |
5231 |
int sSize = sequences.length; |
192 |
|
|
193 |
5231 |
if ((i > -1) && (i < sSize)) |
194 |
|
{ |
195 |
5231 |
String sq = sequences[i].getSequenceAsString(); |
196 |
|
|
197 |
5231 |
if (seqNums.size() <= i) |
198 |
|
{ |
199 |
5231 |
seqNums.addElement(new int[sq.length() + 1]); |
200 |
|
} |
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
|
206 |
5231 |
if (sq.hashCode() != seqNums.elementAt(i)[0]) |
207 |
|
{ |
208 |
5231 |
int j; |
209 |
5231 |
int len; |
210 |
5231 |
seqNumsChanged = true; |
211 |
5231 |
len = sq.length(); |
212 |
|
|
213 |
5231 |
if (maxLength < len) |
214 |
|
{ |
215 |
0 |
maxLength = len; |
216 |
|
} |
217 |
|
|
218 |
5231 |
int[] sqnum = new int[len + 1]; |
219 |
|
|
220 |
5231 |
sqnum[0] = sq.hashCode(); |
221 |
|
|
222 |
820839 |
for (j = 1; j <= len; j++) |
223 |
|
{ |
224 |
|
|
225 |
815662 |
char residue = sq.charAt(j - 1); |
226 |
815958 |
if (Comparison.isGap(residue)) |
227 |
|
{ |
228 |
120043 |
sqnum[j] = GAP_INDEX; |
229 |
|
} |
230 |
|
else |
231 |
|
{ |
232 |
695920 |
sqnum[j] = sm.getMatrixIndex(residue); |
233 |
695929 |
if (sqnum[j] == -1) |
234 |
|
{ |
235 |
29 |
sqnum[j] = GAP_INDEX; |
236 |
|
} |
237 |
|
} |
238 |
|
} |
239 |
|
|
240 |
5230 |
seqNums.setElementAt(sqnum, i); |
241 |
|
} |
242 |
|
else |
243 |
|
{ |
244 |
0 |
System.out.println("SEQUENCE HAS BEEN DELETED!!!"); |
245 |
|
} |
246 |
|
} |
247 |
|
else |
248 |
|
{ |
249 |
|
|
250 |
0 |
System.err.println( |
251 |
|
"ERROR: calcSeqNum called with out of range sequence index for Alignment\n"); |
252 |
|
} |
253 |
|
} |
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
|
|
| 96.3% |
Uncovered Elements: 1 (27) |
Complexity: 6 |
Complexity Density: 0.35 |
|
258 |
511 |
public void calculate()... |
259 |
|
{ |
260 |
511 |
int height = sequences.length; |
261 |
|
|
262 |
511 |
total = new Map[maxLength]; |
263 |
|
|
264 |
73199 |
for (int column = start; column <= end; column++) |
265 |
|
{ |
266 |
72689 |
ResidueCount values = countResidues(column); |
267 |
|
|
268 |
|
|
269 |
|
|
270 |
|
|
271 |
72687 |
int thresh = (threshold * height) / 100; |
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
279 |
72687 |
SortedMap<String, Integer> resultHash = new TreeMap<>(); |
280 |
72685 |
SymbolCounts symbolCounts = values.getSymbolCounts(); |
281 |
72692 |
char[] symbols = symbolCounts.symbols; |
282 |
72692 |
int[] counts = symbolCounts.values; |
283 |
229802 |
for (int j = 0; j < symbols.length; j++) |
284 |
|
{ |
285 |
157113 |
char c = symbols[j]; |
286 |
157111 |
if (counts[j] > thresh) |
287 |
|
{ |
288 |
157108 |
recordConservation(resultHash, String.valueOf(c)); |
289 |
|
} |
290 |
|
} |
291 |
72691 |
if (values.getGapCount() > thresh) |
292 |
|
{ |
293 |
38996 |
recordConservation(resultHash, "-"); |
294 |
|
} |
295 |
|
|
296 |
72689 |
if (total.length > 0) |
297 |
|
{ |
298 |
72690 |
total[column - start] = resultHash; |
299 |
|
} |
300 |
|
} |
301 |
|
} |
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
|
306 |
|
@param |
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
@param |
311 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 5 |
Complexity Density: 0.45 |
|
312 |
196077 |
protected static void recordConservation(Map<String, Integer> resultMap,... |
313 |
|
String res) |
314 |
|
{ |
315 |
196082 |
res = res.toUpperCase(); |
316 |
196083 |
for (Entry<String, Map<String, Integer>> property : ResidueProperties.propHash |
317 |
|
.entrySet()) |
318 |
|
{ |
319 |
1957588 |
String propertyName = property.getKey(); |
320 |
1957969 |
Integer residuePropertyValue = property.getValue().get(res); |
321 |
|
|
322 |
1960342 |
if (!resultMap.containsKey(propertyName)) |
323 |
|
{ |
324 |
|
|
325 |
|
|
326 |
|
|
327 |
726667 |
if (residuePropertyValue != null) |
328 |
|
{ |
329 |
726589 |
resultMap.put(propertyName, residuePropertyValue); |
330 |
|
} |
331 |
|
else |
332 |
|
{ |
333 |
|
|
334 |
|
|
335 |
|
|
336 |
110 |
resultMap.put(propertyName, property.getValue().get("-")); |
337 |
|
} |
338 |
|
} |
339 |
|
else |
340 |
|
{ |
341 |
1234042 |
Integer currentResult = resultMap.get(propertyName); |
342 |
1234001 |
if (currentResult.intValue() != -1 |
343 |
|
&& !currentResult.equals(residuePropertyValue)) |
344 |
|
{ |
345 |
|
|
346 |
|
|
347 |
|
|
348 |
371807 |
resultMap.put(propertyName, Integer.valueOf(-1)); |
349 |
|
} |
350 |
|
} |
351 |
|
} |
352 |
|
} |
353 |
|
|
354 |
|
|
355 |
|
|
356 |
|
|
357 |
|
@param |
358 |
|
@return |
359 |
|
|
|
|
| 91.3% |
Uncovered Elements: 2 (23) |
Complexity: 6 |
Complexity Density: 0.46 |
|
360 |
72689 |
protected ResidueCount countResidues(int column)... |
361 |
|
{ |
362 |
72688 |
ResidueCount values = new ResidueCount(false); |
363 |
|
|
364 |
910578 |
for (int row = 0; row < sequences.length; row++) |
365 |
|
{ |
366 |
837824 |
if (sequences[row].getLength() > column) |
367 |
|
{ |
368 |
823426 |
char c = sequences[row].getCharAt(column); |
369 |
823326 |
if (canonicaliseAa) |
370 |
|
{ |
371 |
823351 |
int index = ResidueProperties.aaIndex[c]; |
372 |
823662 |
c = index > 20 ? '-' : ResidueProperties.aa[index].charAt(0); |
373 |
|
} |
374 |
|
else |
375 |
|
{ |
376 |
0 |
c = toUpperCase(c); |
377 |
|
} |
378 |
823683 |
if (Comparison.isGap(c)) |
379 |
|
{ |
380 |
121282 |
values.addGap(); |
381 |
|
} |
382 |
|
else |
383 |
|
{ |
384 |
702411 |
values.add(c); |
385 |
|
} |
386 |
|
} |
387 |
|
else |
388 |
|
{ |
389 |
14428 |
values.addGap(); |
390 |
|
} |
391 |
|
} |
392 |
72687 |
return values; |
393 |
|
} |
394 |
|
|
395 |
|
|
396 |
|
|
397 |
|
|
398 |
|
@return |
399 |
|
|
|
|
| 94.1% |
Uncovered Elements: 2 (34) |
Complexity: 8 |
Complexity Density: 0.4 |
|
400 |
72675 |
public int[] countConservationAndGaps(int column)... |
401 |
|
{ |
402 |
72675 |
int gapCount = 0; |
403 |
72675 |
boolean fullyConserved = true; |
404 |
72675 |
int iSize = sequences.length; |
405 |
|
|
406 |
72676 |
if (iSize == 0) |
407 |
|
{ |
408 |
0 |
return new int[] { 0, 0 }; |
409 |
|
} |
410 |
|
|
411 |
72676 |
char lastRes = '0'; |
412 |
908873 |
for (int i = 0; i < iSize; i++) |
413 |
|
{ |
414 |
836263 |
if (column >= sequences[i].getLength()) |
415 |
|
{ |
416 |
14428 |
gapCount++; |
417 |
14428 |
continue; |
418 |
|
} |
419 |
|
|
420 |
821871 |
char c = sequences[i].getCharAt(column); |
421 |
|
|
422 |
|
|
423 |
822344 |
if (Comparison.isGap((c))) |
424 |
|
{ |
425 |
121183 |
gapCount++; |
426 |
|
} |
427 |
|
else |
428 |
|
{ |
429 |
701216 |
c = toUpperCase(c); |
430 |
701562 |
if (lastRes == '0') |
431 |
|
{ |
432 |
71770 |
lastRes = c; |
433 |
|
} |
434 |
701905 |
if (c != lastRes) |
435 |
|
{ |
436 |
206231 |
fullyConserved = false; |
437 |
|
} |
438 |
|
} |
439 |
|
} |
440 |
|
|
441 |
72674 |
int[] r = new int[] { fullyConserved ? 1 : 0, gapCount }; |
442 |
72671 |
return r; |
443 |
|
} |
444 |
|
|
445 |
|
|
446 |
|
|
447 |
|
|
448 |
|
|
449 |
|
@param |
450 |
|
@return |
451 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
452 |
701224 |
char toUpperCase(char c)... |
453 |
|
{ |
454 |
701266 |
if ('a' <= c && c <= 'z') |
455 |
|
{ |
456 |
198 |
c -= TOUPPERCASE; |
457 |
|
} |
458 |
701253 |
return c; |
459 |
|
} |
460 |
|
|
461 |
|
|
462 |
|
|
463 |
|
|
464 |
|
@param |
465 |
|
|
466 |
|
|
467 |
|
@param |
468 |
|
|
469 |
|
|
470 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (55) |
Complexity: 13 |
Complexity Density: 0.39 |
|
471 |
509 |
public void verdict(boolean positiveOnly, float maxPercentageGaps)... |
472 |
|
{ |
473 |
|
|
474 |
|
|
475 |
509 |
StringBuilder consString = new StringBuilder(end); |
476 |
|
|
477 |
|
|
478 |
|
|
479 |
|
|
480 |
599 |
for (int i = 0; i < start; i++) |
481 |
|
{ |
482 |
90 |
consString.append('-'); |
483 |
|
} |
484 |
509 |
consSymbs = new String[end - start + 1]; |
485 |
73178 |
for (int i = start; i <= end; i++) |
486 |
|
{ |
487 |
72670 |
int[] gapcons = countConservationAndGaps(i); |
488 |
72669 |
boolean fullyConserved = gapcons[0] == 1; |
489 |
72671 |
int totGaps = gapcons[1]; |
490 |
72672 |
float pgaps = (totGaps * 100f) / sequences.length; |
491 |
|
|
492 |
72680 |
if (maxPercentageGaps > pgaps) |
493 |
|
{ |
494 |
52918 |
Map<String, Integer> resultHash = total[i - start]; |
495 |
52918 |
int count = 0; |
496 |
52918 |
StringBuilder positives = new StringBuilder(64); |
497 |
52916 |
StringBuilder negatives = new StringBuilder(32); |
498 |
52916 |
for (String type : resultHash.keySet()) |
499 |
|
{ |
500 |
528472 |
int result = resultHash.get(type).intValue(); |
501 |
528860 |
if (result == -1) |
502 |
|
{ |
503 |
|
|
504 |
|
|
505 |
|
|
506 |
216787 |
continue; |
507 |
|
} |
508 |
312105 |
count++; |
509 |
312198 |
if (result == 1) |
510 |
|
{ |
511 |
|
|
512 |
|
|
513 |
|
|
514 |
96417 |
positives.append(positives.length() == 0 ? "" : " "); |
515 |
96407 |
positives.append(type); |
516 |
|
} |
517 |
312200 |
if (result == 0 && !positiveOnly) |
518 |
|
{ |
519 |
|
|
520 |
|
|
521 |
|
|
522 |
215844 |
negatives.append(negatives.length() == 0 ? "" : " "); |
523 |
215793 |
negatives.append("!").append(type); |
524 |
|
} |
525 |
|
} |
526 |
52914 |
if (negatives.length() > 0) |
527 |
|
{ |
528 |
33583 |
positives.append(" ").append(negatives); |
529 |
|
} |
530 |
52912 |
consSymbs[i - start] = positives.toString(); |
531 |
|
|
532 |
52917 |
if (count < 10) |
533 |
|
{ |
534 |
32421 |
consString.append(count); |
535 |
|
} |
536 |
|
else |
537 |
|
{ |
538 |
20494 |
consString.append(fullyConserved ? "*" : "+"); |
539 |
|
} |
540 |
|
} |
541 |
|
else |
542 |
|
{ |
543 |
19763 |
consString.append('-'); |
544 |
|
} |
545 |
|
} |
546 |
|
|
547 |
509 |
consSequence = new Sequence(name, consString.toString(), start, end); |
548 |
|
} |
549 |
|
|
550 |
|
|
551 |
|
|
552 |
|
|
553 |
|
@return |
554 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
555 |
532 |
public SequenceI getConsSequence()... |
556 |
|
{ |
557 |
532 |
return consSequence; |
558 |
|
} |
559 |
|
|
560 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
561 |
497 |
public void findQuality()... |
562 |
|
{ |
563 |
497 |
findQuality(0, maxLength - 1, ScoreModels.getInstance().getBlosum62()); |
564 |
|
} |
565 |
|
|
566 |
|
|
567 |
|
|
568 |
|
|
569 |
|
@param |
570 |
|
|
|
|
| 96.7% |
Uncovered Elements: 1 (30) |
Complexity: 8 |
Complexity Density: 0.44 |
|
571 |
497 |
private void percentIdentity(ScoreMatrix sm)... |
572 |
|
{ |
573 |
497 |
seqNums = new Vector<>(); |
574 |
497 |
int i = 0, iSize = sequences.length; |
575 |
|
|
576 |
5728 |
for (i = 0; i < iSize; i++) |
577 |
|
{ |
578 |
5231 |
calcSeqNum(i, sm); |
579 |
|
} |
580 |
|
|
581 |
497 |
if ((cons2 == null) || seqNumsChanged) |
582 |
|
{ |
583 |
|
|
584 |
|
|
585 |
497 |
cons2 = new int[maxLength][24]; |
586 |
497 |
cons2GapCounts = new int[maxLength]; |
587 |
|
|
588 |
497 |
int j = 0; |
589 |
|
|
590 |
5728 |
while (j < sequences.length) |
591 |
|
{ |
592 |
5231 |
int[] sqnum = seqNums.elementAt(j); |
593 |
|
|
594 |
821957 |
for (i = 1; i < sqnum.length; i++) |
595 |
|
{ |
596 |
816726 |
int index = sqnum[i]; |
597 |
816726 |
if (index == GAP_INDEX) |
598 |
|
{ |
599 |
120080 |
cons2GapCounts[i - 1]++; |
600 |
|
} |
601 |
|
else |
602 |
|
{ |
603 |
696646 |
cons2[i - 1][index]++; |
604 |
|
} |
605 |
|
} |
606 |
|
|
607 |
|
|
608 |
19614 |
for (i = sqnum.length - 1; i < maxLength; i++) |
609 |
|
{ |
610 |
14383 |
cons2GapCounts[i]++; |
611 |
|
} |
612 |
5231 |
j++; |
613 |
|
} |
614 |
|
} |
615 |
|
} |
616 |
|
|
617 |
|
|
618 |
|
|
619 |
|
|
620 |
|
|
621 |
|
@param |
622 |
|
@param |
623 |
|
@param |
624 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (61) |
Complexity: 11 |
Complexity Density: 0.27 |
|
625 |
497 |
protected void findQuality(int startCol, int endCol,... |
626 |
|
ScoreMatrix scoreMatrix) |
627 |
|
{ |
628 |
497 |
quality = new Vector<>(); |
629 |
|
|
630 |
497 |
double max = -Double.MAX_VALUE; |
631 |
497 |
float[][] scores = scoreMatrix.getMatrix(); |
632 |
|
|
633 |
497 |
percentIdentity(scoreMatrix); |
634 |
|
|
635 |
497 |
int size = seqNums.size(); |
636 |
497 |
int[] lengths = new int[size]; |
637 |
|
|
638 |
5728 |
for (int l = 0; l < size; l++) |
639 |
|
{ |
640 |
5231 |
lengths[l] = seqNums.elementAt(l).length - 1; |
641 |
|
} |
642 |
|
|
643 |
497 |
final int symbolCount = scoreMatrix.getSize(); |
644 |
|
|
645 |
72309 |
for (int j = startCol; j <= endCol; j++) |
646 |
|
{ |
647 |
71812 |
double bigtot = 0; |
648 |
|
|
649 |
|
|
650 |
71812 |
double[] x = new double[symbolCount]; |
651 |
|
|
652 |
1786279 |
for (int ii = 0; ii < symbolCount; ii++) |
653 |
|
{ |
654 |
1714386 |
x[ii] = 0; |
655 |
|
|
656 |
|
|
657 |
|
|
658 |
|
|
659 |
|
|
660 |
|
|
661 |
40581604 |
for (int i2 = 0; i2 < symbolCount - 1; i2++) |
662 |
|
{ |
663 |
38871949 |
x[ii] += (((double) cons2[j][i2] * scores[ii][i2]) + 4D); |
664 |
|
} |
665 |
1720882 |
x[ii] += 4D + cons2GapCounts[j] * scoreMatrix.getMinimumScore(); |
666 |
|
|
667 |
1714331 |
x[ii] /= size; |
668 |
|
} |
669 |
|
|
670 |
|
|
671 |
901889 |
for (int k = 0; k < size; k++) |
672 |
|
{ |
673 |
830209 |
double tot = 0; |
674 |
830406 |
double[] xx = new double[symbolCount]; |
675 |
|
|
676 |
830550 |
int seqNum = (j < lengths[k]) ? seqNums.elementAt(k)[j + 1] |
677 |
|
: GAP_INDEX; |
678 |
|
|
679 |
19520242 |
for (int i = 0; i < symbolCount - 1; i++) |
680 |
|
{ |
681 |
18665192 |
double sr = 4D; |
682 |
18808219 |
if (seqNum == GAP_INDEX) |
683 |
|
{ |
684 |
3081031 |
sr += scoreMatrix.getMinimumScore(); |
685 |
|
} |
686 |
|
else |
687 |
|
{ |
688 |
15732088 |
sr += scores[i][seqNum]; |
689 |
|
} |
690 |
|
|
691 |
18721783 |
xx[i] = x[i] - sr; |
692 |
|
|
693 |
18726681 |
tot += (xx[i] * xx[i]); |
694 |
|
} |
695 |
|
|
696 |
830605 |
bigtot += Math.sqrt(tot); |
697 |
|
} |
698 |
|
|
699 |
71812 |
max = Math.max(max, bigtot); |
700 |
|
|
701 |
71811 |
quality.addElement(Double.valueOf(bigtot)); |
702 |
|
} |
703 |
|
|
704 |
497 |
double newmax = -Double.MAX_VALUE; |
705 |
|
|
706 |
72313 |
for (int j = startCol; j <= endCol; j++) |
707 |
|
{ |
708 |
71816 |
double tmp = quality.elementAt(j).doubleValue(); |
709 |
|
|
710 |
71816 |
tmp = ((max - tmp) * (size - cons2GapCounts[j])) / size; |
711 |
|
|
712 |
|
|
713 |
71816 |
quality.setElementAt(Double.valueOf(tmp), j); |
714 |
|
|
715 |
71816 |
if (tmp > newmax) |
716 |
|
{ |
717 |
1346 |
newmax = tmp; |
718 |
|
} |
719 |
|
} |
720 |
|
|
721 |
497 |
qualityMinimum = 0D; |
722 |
497 |
qualityMaximum = newmax; |
723 |
|
} |
724 |
|
|
725 |
|
|
726 |
|
|
727 |
|
|
728 |
|
|
729 |
|
|
730 |
|
@param |
731 |
|
|
732 |
|
@param |
733 |
|
|
734 |
|
@param |
735 |
|
|
736 |
|
@param |
737 |
|
|
738 |
|
|
|
|
| 96.7% |
Uncovered Elements: 2 (60) |
Complexity: 16 |
Complexity Density: 0.4 |
|
739 |
497 |
public void completeAnnotations(AlignmentAnnotation conservation,... |
740 |
|
AlignmentAnnotation quality2, int istart, int alWidth) |
741 |
|
{ |
742 |
497 |
SequenceI cons = getConsSequence(); |
743 |
|
|
744 |
|
|
745 |
|
|
746 |
|
|
747 |
497 |
float minR = 0.3f; |
748 |
497 |
float minG = 0.0f; |
749 |
497 |
float minB = 0f; |
750 |
497 |
float maxR = 1.0f - minR; |
751 |
497 |
float maxG = 0.9f - minG; |
752 |
497 |
float maxB = 0f - minB; |
753 |
|
|
754 |
497 |
float min = 0f; |
755 |
497 |
float max = 11f; |
756 |
497 |
float qmin = 0f; |
757 |
497 |
float qmax = 0f; |
758 |
|
|
759 |
497 |
if (conservation != null && conservation.annotations != null |
760 |
|
&& conservation.annotations.length != alWidth) |
761 |
|
{ |
762 |
218 |
conservation.annotations = new Annotation[alWidth]; |
763 |
|
} |
764 |
|
|
765 |
497 |
if (quality2 != null) |
766 |
|
{ |
767 |
497 |
quality2.graphMax = (float) qualityMaximum; |
768 |
497 |
if (quality2.annotations != null |
769 |
|
&& quality2.annotations.length != alWidth) |
770 |
|
{ |
771 |
219 |
quality2.annotations = new Annotation[alWidth]; |
772 |
|
} |
773 |
497 |
qmin = (float) qualityMinimum; |
774 |
497 |
qmax = (float) qualityMaximum; |
775 |
|
} |
776 |
|
|
777 |
72310 |
for (int i = istart; i < alWidth; i++) |
778 |
|
{ |
779 |
71813 |
float value = 0; |
780 |
|
|
781 |
71813 |
char c = cons.getCharAt(i); |
782 |
|
|
783 |
71813 |
if (Character.isDigit(c)) |
784 |
|
{ |
785 |
32131 |
value = c - '0'; |
786 |
|
} |
787 |
39683 |
else if (c == '*') |
788 |
|
{ |
789 |
20150 |
value = 11; |
790 |
|
} |
791 |
19533 |
else if (c == '+') |
792 |
|
{ |
793 |
48 |
value = 10; |
794 |
|
} |
795 |
|
|
796 |
71808 |
if (conservation != null) |
797 |
|
{ |
798 |
71650 |
float vprop = value - min; |
799 |
71649 |
vprop /= max; |
800 |
71650 |
int consp = i - start; |
801 |
71655 |
String conssym = (value > 0 && consp > -1 |
802 |
|
&& consp < consSymbs.length) ? consSymbs[consp] : ""; |
803 |
71649 |
conservation.annotations[i] = new Annotation(String.valueOf(c), |
804 |
|
conssym, ' ', value, new Color(minR + (maxR * vprop), |
805 |
|
minG + (maxG * vprop), minB + (maxB * vprop))); |
806 |
|
} |
807 |
|
|
808 |
|
|
809 |
71815 |
if (quality2 != null) |
810 |
|
{ |
811 |
71815 |
value = quality.elementAt(i).floatValue(); |
812 |
71815 |
float vprop = value - qmin; |
813 |
71815 |
vprop /= qmax; |
814 |
71816 |
String description = FORMAT_3DP.form(value); |
815 |
71816 |
quality2.annotations[i] = new Annotation(" ", description, |
816 |
|
' ', value, new Color(minR + (maxR * vprop), |
817 |
|
minG + (maxG * vprop), minB + (maxB * vprop))); |
818 |
|
} |
819 |
|
} |
820 |
|
} |
821 |
|
|
822 |
|
|
823 |
|
|
824 |
|
|
825 |
|
@param |
826 |
|
|
827 |
|
@param |
828 |
|
@param |
829 |
|
|
830 |
|
@param |
831 |
|
|
832 |
|
@param |
833 |
|
|
834 |
|
|
835 |
|
@param |
836 |
|
|
837 |
|
@param |
838 |
|
|
839 |
|
@return |
840 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
841 |
500 |
public static Conservation calculateConservation(String name,... |
842 |
|
List<SequenceI> seqs, int start, int end, boolean positiveOnly, |
843 |
|
int maxPercentGaps, boolean calcQuality) |
844 |
|
{ |
845 |
500 |
Conservation cons = new Conservation(name, seqs, start, end); |
846 |
500 |
cons.calculate(); |
847 |
500 |
cons.verdict(positiveOnly, maxPercentGaps); |
848 |
|
|
849 |
500 |
if (calcQuality) |
850 |
|
{ |
851 |
497 |
cons.findQuality(); |
852 |
|
} |
853 |
|
|
854 |
500 |
return cons; |
855 |
|
} |
856 |
|
|
857 |
|
|
858 |
|
|
859 |
|
|
860 |
|
|
861 |
|
|
862 |
|
|
863 |
|
@param |
864 |
|
@return |
865 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 5 |
Complexity Density: 0.83 |
|
866 |
7 |
String getTooltip(int column)... |
867 |
|
{ |
868 |
7 |
SequenceI cons = getConsSequence(); |
869 |
7 |
char val = column < cons.getLength() ? cons.getCharAt(column) : '-'; |
870 |
7 |
boolean hasConservation = val != '-' && val != '0'; |
871 |
7 |
int consp = column - start; |
872 |
7 |
String tip = (hasConservation && consp > -1 && consp < consSymbs.length) |
873 |
|
? consSymbs[consp] |
874 |
|
: ""; |
875 |
7 |
return tip; |
876 |
|
} |
877 |
|
} |