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.datamodel.AlignedCodonFrame; |
24 |
|
import jalview.datamodel.AlignmentAnnotation; |
25 |
|
import jalview.datamodel.AlignmentI; |
26 |
|
import jalview.datamodel.Annotation; |
27 |
|
import jalview.datamodel.Profile; |
28 |
|
import jalview.datamodel.ProfileI; |
29 |
|
import jalview.datamodel.Profiles; |
30 |
|
import jalview.datamodel.ProfilesI; |
31 |
|
import jalview.datamodel.ResidueCount; |
32 |
|
import jalview.datamodel.ResidueCount.SymbolCounts; |
33 |
|
import jalview.datamodel.SecondaryStructureCount; |
34 |
|
import jalview.datamodel.SequenceI; |
35 |
|
import jalview.ext.android.SparseIntArray; |
36 |
|
import jalview.util.Comparison; |
37 |
|
import jalview.util.Format; |
38 |
|
import jalview.util.MappingUtils; |
39 |
|
import jalview.util.QuickSort; |
40 |
|
|
41 |
|
import java.awt.Color; |
42 |
|
import java.util.Arrays; |
43 |
|
import java.util.Hashtable; |
44 |
|
import java.util.List; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
@author |
53 |
|
@version |
54 |
|
|
|
|
| 86.7% |
Uncovered Elements: 65 (488) |
Complexity: 112 |
Complexity Density: 0.35 |
|
55 |
|
public class AAFrequency |
56 |
|
{ |
57 |
|
public static final String PROFILE = "P"; |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
private static final String[] CHARS = new String['Z' - 'A' + 1]; |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
64 |
50 |
static... |
65 |
|
{ |
66 |
1350 |
for (char c = 'A'; c <= 'Z'; c++) |
67 |
|
{ |
68 |
1300 |
CHARS[c - 'A'] = String.valueOf(c); |
69 |
|
} |
70 |
|
} |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
72 |
3 |
public static final ProfilesI calculate(List<SequenceI> list, int start,... |
73 |
|
int end) |
74 |
|
{ |
75 |
3 |
return calculate(list, start, end, false); |
76 |
|
} |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
78 |
368 |
public static final ProfilesI calculate(List<SequenceI> sequences,... |
79 |
|
int start, int end, boolean profile) |
80 |
|
{ |
81 |
368 |
SequenceI[] seqs = new SequenceI[sequences.size()]; |
82 |
368 |
int width = 0; |
83 |
368 |
synchronized (sequences) |
84 |
|
{ |
85 |
3012 |
for (int i = 0; i < sequences.size(); i++) |
86 |
|
{ |
87 |
2644 |
seqs[i] = sequences.get(i); |
88 |
2644 |
int length = seqs[i].getLength(); |
89 |
2644 |
if (length > width) |
90 |
|
{ |
91 |
367 |
width = length; |
92 |
|
} |
93 |
|
} |
94 |
|
|
95 |
368 |
if (end >= width) |
96 |
|
{ |
97 |
210 |
end = width; |
98 |
|
} |
99 |
|
|
100 |
368 |
ProfilesI reply = calculate(seqs, width, start, end, profile); |
101 |
368 |
return reply; |
102 |
|
} |
103 |
|
} |
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
@param |
109 |
|
@param |
110 |
|
|
111 |
|
@param |
112 |
|
|
113 |
|
@param |
114 |
|
|
115 |
|
@param |
116 |
|
|
117 |
|
|
|
|
| 93.3% |
Uncovered Elements: 3 (45) |
Complexity: 10 |
Complexity Density: 0.34 |
|
118 |
1309 |
public static final ProfilesI calculate(final SequenceI[] sequences,... |
119 |
|
int width, int start, int end, boolean saveFullProfile) |
120 |
|
{ |
121 |
|
|
122 |
1309 |
int seqCount = sequences.length; |
123 |
1309 |
boolean nucleotide = false; |
124 |
1309 |
int nucleotideCount = 0; |
125 |
1309 |
int peptideCount = 0; |
126 |
|
|
127 |
1309 |
ProfileI[] result = new ProfileI[width]; |
128 |
|
|
129 |
607067 |
for (int column = start; column < end; column++) |
130 |
|
{ |
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
605768 |
if (nucleotideCount > 100 && column % 10 == 0) |
142 |
|
{ |
143 |
54700 |
nucleotide = (9 * peptideCount < nucleotideCount); |
144 |
|
} |
145 |
605767 |
ResidueCount residueCounts = new ResidueCount(nucleotide); |
146 |
|
|
147 |
11242366 |
for (int row = 0; row < seqCount; row++) |
148 |
|
{ |
149 |
10636509 |
if (sequences[row] == null) |
150 |
|
{ |
151 |
0 |
jalview.bin.Console.errPrintln( |
152 |
|
"WARNING: Consensus skipping null sequence - possible race condition."); |
153 |
0 |
continue; |
154 |
|
} |
155 |
10630722 |
if (sequences[row].getLength() > column) |
156 |
|
{ |
157 |
10596515 |
char c = sequences[row].getCharAt(column); |
158 |
10582447 |
residueCounts.add(c); |
159 |
10619879 |
if (Comparison.isNucleotide(c)) |
160 |
|
{ |
161 |
961773 |
nucleotideCount++; |
162 |
|
} |
163 |
9603674 |
else if (!Comparison.isGap(c)) |
164 |
|
{ |
165 |
822263 |
peptideCount++; |
166 |
|
} |
167 |
|
} |
168 |
|
else |
169 |
|
{ |
170 |
|
|
171 |
|
|
172 |
|
|
173 |
38052 |
residueCounts.addGap(); |
174 |
|
} |
175 |
|
} |
176 |
|
|
177 |
605714 |
int maxCount = residueCounts.getModalCount(); |
178 |
605711 |
String maxResidue = residueCounts.getResiduesForCount(maxCount); |
179 |
605685 |
int gapCount = residueCounts.getGapCount(); |
180 |
605683 |
ProfileI profile = new Profile(seqCount, gapCount, maxCount, |
181 |
|
maxResidue); |
182 |
|
|
183 |
605746 |
if (saveFullProfile) |
184 |
|
{ |
185 |
587937 |
profile.setCounts(residueCounts); |
186 |
|
} |
187 |
|
|
188 |
605712 |
result[column] = profile; |
189 |
|
} |
190 |
1309 |
return new Profiles(seqCount, result); |
191 |
|
|
192 |
|
|
193 |
|
} |
194 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
195 |
0 |
public static final ProfilesI calculateSS(List<SequenceI> list, int start,... |
196 |
|
int end, String source) |
197 |
|
{ |
198 |
0 |
return calculateSS(list, start, end, false, source); |
199 |
|
} |
200 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
201 |
365 |
public static final ProfilesI calculateSS(List<SequenceI> sequences,... |
202 |
|
int start, int end, boolean profile, String source) |
203 |
|
{ |
204 |
365 |
SequenceI[] seqs = new SequenceI[sequences.size()]; |
205 |
365 |
int width = 0; |
206 |
365 |
synchronized (sequences) |
207 |
|
{ |
208 |
3006 |
for (int i = 0; i < sequences.size(); i++) |
209 |
|
{ |
210 |
2641 |
seqs[i] = sequences.get(i); |
211 |
2641 |
int length = seqs[i].getLength(); |
212 |
2641 |
if (length > width) |
213 |
|
{ |
214 |
364 |
width = length; |
215 |
|
} |
216 |
|
} |
217 |
|
|
218 |
365 |
if (end >= width) |
219 |
|
{ |
220 |
210 |
end = width; |
221 |
|
} |
222 |
|
|
223 |
365 |
ProfilesI reply = calculateSS(seqs, width, start, end, profile, |
224 |
|
source); |
225 |
365 |
return reply; |
226 |
|
} |
227 |
|
} |
228 |
|
|
|
|
| 86.8% |
Uncovered Elements: 7 (53) |
Complexity: 13 |
Complexity Density: 0.37 |
|
229 |
1364 |
public static final ProfilesI calculateSS(final SequenceI[] sequences,... |
230 |
|
int width, int start, int end, boolean saveFullProfile, |
231 |
|
String source) |
232 |
|
{ |
233 |
|
|
234 |
1364 |
int seqCount = sequences.length; |
235 |
|
|
236 |
1364 |
int seqWithSSCount = 0; |
237 |
|
|
238 |
1364 |
ProfileI[] result = new ProfileI[width]; |
239 |
1364 |
int maxSSannotcount=0; |
240 |
623126 |
for (int column = start; column < end; column++) |
241 |
|
{ |
242 |
|
|
243 |
621769 |
int ssCount = 0; |
244 |
|
|
245 |
621774 |
SecondaryStructureCount ssCounts = new SecondaryStructureCount(); |
246 |
|
|
247 |
11387151 |
for (int row = 0; row < seqCount; row++) |
248 |
|
{ |
249 |
10790449 |
if (sequences[row] == null) |
250 |
|
{ |
251 |
0 |
jalview.bin.Console.errPrintln( |
252 |
|
"WARNING: Consensus skipping null sequence - possible race condition."); |
253 |
0 |
continue; |
254 |
|
} |
255 |
|
|
256 |
10804126 |
char c = sequences[row].getCharAt(column); |
257 |
|
|
258 |
10699541 |
List<AlignmentAnnotation> annots = AlignmentUtils.getAlignmentAnnotationForSource(sequences[row], source); |
259 |
10794700 |
if(annots!=null) { |
260 |
100737 |
seqWithSSCount++; |
261 |
100737 |
for (AlignmentAnnotation aa : annots) |
262 |
|
{ |
263 |
112538 |
if (aa != null) |
264 |
|
{ |
265 |
112538 |
ssCount++; |
266 |
|
} |
267 |
|
|
268 |
112535 |
if (sequences[row].getLength() > column && !Comparison.isGap(c) |
269 |
|
&& aa != null) |
270 |
|
{ |
271 |
|
|
272 |
70728 |
int seqPosition = sequences[row].findPosition(column); |
273 |
|
|
274 |
70734 |
char ss = AlignmentUtils |
275 |
|
.findSSAnnotationForGivenSeqposition(aa, seqPosition); |
276 |
70727 |
if (ss == '*') |
277 |
|
{ |
278 |
0 |
continue; |
279 |
|
} |
280 |
70727 |
ssCounts.add(ss); |
281 |
|
} |
282 |
41806 |
else if (Comparison.isGap(c) && aa != null) |
283 |
|
{ |
284 |
41806 |
ssCounts.addGap(); |
285 |
|
} |
286 |
|
} |
287 |
|
} |
288 |
|
} |
289 |
|
|
290 |
621704 |
int maxSSCount = ssCounts.getModalCount(); |
291 |
621626 |
String maxSS = ssCounts.getSSForCount(maxSSCount); |
292 |
621566 |
int gapCount = ssCounts.getGapCount(); |
293 |
621578 |
ProfileI profile = new Profile(maxSS, ssCount, gapCount, maxSSCount, |
294 |
|
seqWithSSCount); |
295 |
|
|
296 |
621795 |
if (saveFullProfile) |
297 |
|
{ |
298 |
604016 |
profile.setSSCounts(ssCounts); |
299 |
|
} |
300 |
|
|
301 |
621741 |
result[column] = profile; |
302 |
621772 |
maxSSannotcount=Math.max(maxSSannotcount, ssCount); |
303 |
|
} |
304 |
1364 |
return new Profiles(maxSSannotcount,result); |
305 |
|
} |
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
|
311 |
|
|
312 |
|
|
313 |
|
@param |
314 |
|
|
315 |
|
@return |
316 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
317 |
0 |
static int estimateProfileSize(SparseIntArray profileSizes)... |
318 |
|
{ |
319 |
0 |
if (profileSizes.size() == 0) |
320 |
|
{ |
321 |
0 |
return 4; |
322 |
|
} |
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
|
327 |
|
|
328 |
0 |
return profileSizes.keyAt(profileSizes.size() - 1); |
329 |
|
} |
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
|
337 |
|
@param |
338 |
|
|
339 |
|
@param |
340 |
|
|
341 |
|
@param |
342 |
|
|
343 |
|
@param |
344 |
|
|
345 |
|
@param |
346 |
|
|
347 |
|
@param |
348 |
|
|
349 |
|
|
350 |
|
@param |
351 |
|
|
352 |
|
|
|
|
| 80.8% |
Uncovered Elements: 5 (26) |
Complexity: 8 |
Complexity Density: 0.5 |
|
353 |
1065 |
public static void completeConsensus(AlignmentAnnotation consensus,... |
354 |
|
ProfilesI profiles, int startCol, int endCol, boolean ignoreGaps, |
355 |
|
boolean showSequenceLogo, long nseq) |
356 |
|
{ |
357 |
|
|
358 |
1065 |
if (consensus == null || consensus.annotations == null |
359 |
|
|| consensus.annotations.length < endCol) |
360 |
|
{ |
361 |
|
|
362 |
|
|
363 |
|
|
364 |
|
|
365 |
0 |
return; |
366 |
|
} |
367 |
|
|
368 |
379870 |
for (int i = startCol; i < endCol; i++) |
369 |
|
{ |
370 |
378818 |
ProfileI profile = profiles.get(i); |
371 |
378819 |
if (profile == null) |
372 |
|
{ |
373 |
|
|
374 |
|
|
375 |
|
|
376 |
|
|
377 |
0 |
consensus.annotations[i] = null; |
378 |
0 |
return; |
379 |
|
} |
380 |
|
|
381 |
378818 |
final int dp = getPercentageDp(nseq); |
382 |
|
|
383 |
378806 |
float value = profile.getPercentageIdentity(ignoreGaps); |
384 |
|
|
385 |
378803 |
String description = getTooltip(profile, value, showSequenceLogo, |
386 |
|
ignoreGaps, dp); |
387 |
|
|
388 |
378817 |
String modalResidue = profile.getModalResidue(); |
389 |
378817 |
if ("".equals(modalResidue)) |
390 |
|
{ |
391 |
5910 |
modalResidue = "-"; |
392 |
|
} |
393 |
372906 |
else if (modalResidue.length() > 1) |
394 |
|
{ |
395 |
7685 |
modalResidue = "+"; |
396 |
|
} |
397 |
378817 |
consensus.annotations[i] = new Annotation(modalResidue, description, |
398 |
|
' ', value); |
399 |
|
} |
400 |
|
|
401 |
|
|
402 |
|
} |
403 |
|
|
|
|
| 85.3% |
Uncovered Elements: 5 (34) |
Complexity: 10 |
Complexity Density: 0.5 |
|
404 |
905 |
public static void completeSSConsensus(AlignmentAnnotation ssConsensus,... |
405 |
|
ProfilesI profiles, int startCol, int endCol, boolean ignoreGaps, |
406 |
|
boolean showSequenceLogo, long nseq) |
407 |
|
{ |
408 |
|
|
409 |
905 |
if (ssConsensus == null || ssConsensus.annotations == null |
410 |
|
|| ssConsensus.annotations.length < endCol) |
411 |
|
{ |
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
|
416 |
3 |
return; |
417 |
|
} |
418 |
|
|
419 |
521192 |
for (int i = startCol; i < endCol; i++) |
420 |
|
{ |
421 |
520290 |
ProfileI profile = profiles.get(i); |
422 |
520290 |
if (profile == null) |
423 |
|
{ |
424 |
|
|
425 |
|
|
426 |
|
|
427 |
|
|
428 |
0 |
ssConsensus.annotations[i] = null; |
429 |
0 |
return; |
430 |
|
} |
431 |
|
|
432 |
520290 |
if (ssConsensus.getNoOfSequencesIncluded() < 0) |
433 |
|
{ |
434 |
0 |
ssConsensus.setNoOfSequencesIncluded(profile.getSeqWithSSCount()); |
435 |
|
} |
436 |
|
|
437 |
520290 |
final int dp = getPercentageDp(nseq); |
438 |
|
|
439 |
520290 |
float value = profile.getSSPercentageIdentity(ignoreGaps); |
440 |
|
|
441 |
520290 |
String description = getSSTooltip(profile, value, showSequenceLogo, |
442 |
|
ignoreGaps, dp); |
443 |
|
|
444 |
520290 |
String modalSS = profile.getModalSS(); |
445 |
520290 |
if ("".equals(modalSS)) |
446 |
|
{ |
447 |
502133 |
modalSS = "-"; |
448 |
|
} |
449 |
18157 |
else if (modalSS.length() > 1) |
450 |
|
{ |
451 |
1068 |
modalSS = "+"; |
452 |
|
} |
453 |
520290 |
ssConsensus.annotations[i] = new Annotation(modalSS, description, |
454 |
|
' ', value); |
455 |
|
} |
456 |
|
|
457 |
|
|
458 |
902 |
if(ssConsensus.getNoOfSequencesIncluded()<1) |
459 |
816 |
ssConsensus.visible = false; |
460 |
|
|
461 |
|
|
462 |
|
|
463 |
|
} |
464 |
|
|
465 |
|
|
466 |
|
|
467 |
|
|
468 |
|
@param |
469 |
|
|
470 |
|
@param |
471 |
|
|
472 |
|
@param |
473 |
|
|
474 |
|
@param |
475 |
|
|
476 |
|
|
|
|
| 73.7% |
Uncovered Elements: 5 (19) |
Complexity: 6 |
Complexity Density: 0.46 |
|
477 |
1835 |
public static void completeGapAnnot(AlignmentAnnotation gaprow,... |
478 |
|
ProfilesI profiles, int startCol, int endCol, long nseq) |
479 |
|
{ |
480 |
1835 |
if (gaprow == null || gaprow.annotations == null |
481 |
|
|| gaprow.annotations.length < endCol) |
482 |
|
{ |
483 |
|
|
484 |
|
|
485 |
|
|
486 |
|
|
487 |
0 |
return; |
488 |
|
} |
489 |
|
|
490 |
1835 |
gaprow.graphMax = nseq; |
491 |
1835 |
gaprow.graphMin = 0; |
492 |
1835 |
double scale = 0.8 / nseq; |
493 |
880719 |
for (int i = startCol; i < endCol; i++) |
494 |
|
{ |
495 |
878890 |
ProfileI profile = profiles.get(i); |
496 |
878877 |
if (profile == null) |
497 |
|
{ |
498 |
|
|
499 |
|
|
500 |
|
|
501 |
|
|
502 |
0 |
gaprow.annotations[i] = null; |
503 |
0 |
return; |
504 |
|
} |
505 |
|
|
506 |
878885 |
final int gapped = profile.getNonGapped(); |
507 |
|
|
508 |
878838 |
String description = "" + gapped; |
509 |
|
|
510 |
878850 |
gaprow.annotations[i] = new Annotation("", description, '\0', gapped, |
511 |
|
jalview.util.ColorUtils.bleachColour(Color.DARK_GRAY, |
512 |
|
(float) scale * gapped)); |
513 |
|
} |
514 |
|
} |
515 |
|
|
516 |
|
|
517 |
|
|
518 |
|
|
519 |
|
|
520 |
|
|
521 |
|
|
522 |
|
|
523 |
|
|
524 |
|
|
525 |
|
|
526 |
|
|
527 |
|
@param |
528 |
|
@param |
529 |
|
@param |
530 |
|
@param |
531 |
|
@param |
532 |
|
|
533 |
|
@return |
534 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 6 |
Complexity Density: 0.38 |
|
535 |
378803 |
static String getTooltip(ProfileI profile, float pid,... |
536 |
|
boolean showSequenceLogo, boolean ignoreGaps, int dp) |
537 |
|
{ |
538 |
378804 |
ResidueCount counts = profile.getCounts(); |
539 |
|
|
540 |
378801 |
String description = null; |
541 |
378810 |
if (counts != null && showSequenceLogo) |
542 |
|
{ |
543 |
60652 |
int normaliseBy = ignoreGaps ? profile.getNonGapped() |
544 |
|
: profile.getHeight(); |
545 |
60652 |
description = counts.getTooltip(normaliseBy, dp); |
546 |
|
} |
547 |
|
else |
548 |
|
{ |
549 |
318159 |
StringBuilder sb = new StringBuilder(64); |
550 |
318160 |
String maxRes = profile.getModalResidue(); |
551 |
318157 |
if (maxRes.length() > 1) |
552 |
|
{ |
553 |
2744 |
sb.append("[").append(maxRes).append("]"); |
554 |
|
} |
555 |
|
else |
556 |
|
{ |
557 |
315412 |
sb.append(maxRes); |
558 |
|
} |
559 |
318160 |
if (maxRes.length() > 0) |
560 |
|
{ |
561 |
315191 |
sb.append(" "); |
562 |
315197 |
Format.appendPercentage(sb, pid, dp); |
563 |
315197 |
sb.append("%"); |
564 |
|
} |
565 |
318165 |
description = sb.toString(); |
566 |
|
} |
567 |
378817 |
return description; |
568 |
|
} |
569 |
|
|
|
|
| 95.8% |
Uncovered Elements: 1 (24) |
Complexity: 6 |
Complexity Density: 0.38 |
|
570 |
520290 |
static String getSSTooltip(ProfileI profile, float pid,... |
571 |
|
boolean showSequenceLogo, boolean ignoreGaps, int dp) |
572 |
|
{ |
573 |
520290 |
SecondaryStructureCount counts = profile.getSSCounts(); |
574 |
|
|
575 |
520290 |
String description = null; |
576 |
520290 |
if (counts != null && showSequenceLogo) |
577 |
|
{ |
578 |
45907 |
int normaliseBy = ignoreGaps ? profile.getNonGapped() |
579 |
|
: profile.getHeight(); |
580 |
45907 |
description = counts.getTooltip(normaliseBy, dp); |
581 |
|
} |
582 |
|
else |
583 |
|
{ |
584 |
474383 |
StringBuilder sb = new StringBuilder(64); |
585 |
474383 |
String maxSS = profile.getModalSS(); |
586 |
474383 |
if (maxSS.length() > 1) |
587 |
|
{ |
588 |
728 |
sb.append("[").append(maxSS).append("]"); |
589 |
|
} |
590 |
|
else |
591 |
|
{ |
592 |
473655 |
sb.append(maxSS); |
593 |
|
} |
594 |
474383 |
if (maxSS.length() > 0) |
595 |
|
{ |
596 |
12243 |
sb.append(" "); |
597 |
12243 |
Format.appendPercentage(sb, pid, dp); |
598 |
12243 |
sb.append("%"); |
599 |
|
} |
600 |
474383 |
description = sb.toString(); |
601 |
|
} |
602 |
520290 |
return description; |
603 |
|
} |
604 |
|
|
605 |
|
|
606 |
|
|
607 |
|
|
608 |
|
|
609 |
|
|
610 |
|
|
611 |
|
|
612 |
|
|
613 |
|
|
614 |
|
@param |
615 |
|
|
616 |
|
@param |
617 |
|
|
618 |
|
|
619 |
|
@return |
620 |
|
|
|
|
| 81.6% |
Uncovered Elements: 9 (49) |
Complexity: 7 |
Complexity Density: 0.19 |
|
621 |
100035 |
public static int[] extractProfile(ProfileI profile, boolean ignoreGaps)... |
622 |
|
{ |
623 |
100035 |
char[] symbols; |
624 |
100035 |
int[] values; |
625 |
|
|
626 |
100035 |
if (profile.getCounts() != null) |
627 |
|
{ |
628 |
100035 |
ResidueCount counts = profile.getCounts(); |
629 |
100035 |
SymbolCounts symbolCounts = counts.getSymbolCounts(); |
630 |
100036 |
symbols = symbolCounts.symbols; |
631 |
100036 |
values = symbolCounts.values; |
632 |
|
|
633 |
|
} |
634 |
0 |
else if (profile.getSSCounts() != null) |
635 |
|
{ |
636 |
0 |
SecondaryStructureCount counts = profile.getSSCounts(); |
637 |
|
|
638 |
0 |
SecondaryStructureCount.SymbolCounts symbolCounts = counts |
639 |
|
.getSymbolCounts(); |
640 |
0 |
symbols = symbolCounts.symbols; |
641 |
0 |
values = symbolCounts.values; |
642 |
|
} |
643 |
|
else |
644 |
|
{ |
645 |
0 |
return null; |
646 |
|
} |
647 |
|
|
648 |
100036 |
QuickSort.sort(values, symbols); |
649 |
100036 |
int totalPercentage = 0; |
650 |
100036 |
final int divisor = ignoreGaps ? profile.getNonGapped() |
651 |
|
: profile.getHeight(); |
652 |
|
|
653 |
|
|
654 |
|
|
655 |
|
|
656 |
100036 |
int[] result = new int[3 + 2 * symbols.length]; |
657 |
100036 |
int nextArrayPos = 3; |
658 |
100036 |
int nonZeroCount = 0; |
659 |
|
|
660 |
285005 |
for (int i = symbols.length - 1; i >= 0; i--) |
661 |
|
{ |
662 |
184970 |
int theChar = symbols[i]; |
663 |
184971 |
int charCount = values[i]; |
664 |
184971 |
final int percentage = (charCount * 100) / divisor; |
665 |
184971 |
if (percentage == 0) |
666 |
|
{ |
667 |
|
|
668 |
|
|
669 |
|
|
670 |
2 |
break; |
671 |
|
} |
672 |
184969 |
nonZeroCount++; |
673 |
184969 |
result[nextArrayPos++] = theChar; |
674 |
184969 |
result[nextArrayPos++] = percentage; |
675 |
184969 |
totalPercentage += percentage; |
676 |
|
} |
677 |
|
|
678 |
|
|
679 |
|
|
680 |
|
|
681 |
100035 |
if (nonZeroCount < symbols.length) |
682 |
|
{ |
683 |
2 |
int[] tmp = new int[3 + 2 * nonZeroCount]; |
684 |
2 |
System.arraycopy(result, 0, tmp, 0, tmp.length); |
685 |
2 |
result = tmp; |
686 |
|
} |
687 |
|
|
688 |
|
|
689 |
|
|
690 |
|
|
691 |
100035 |
result[0] = AlignmentAnnotation.SEQUENCE_PROFILE; |
692 |
100035 |
result[1] = nonZeroCount; |
693 |
100035 |
result[2] = totalPercentage; |
694 |
|
|
695 |
100036 |
return result; |
696 |
|
} |
697 |
|
|
698 |
|
|
699 |
|
|
700 |
|
|
701 |
|
|
702 |
|
|
703 |
|
|
704 |
|
|
705 |
|
|
706 |
|
|
707 |
|
@param |
708 |
|
@return |
709 |
|
|
|
|
| 91.9% |
Uncovered Elements: 3 (37) |
Complexity: 6 |
Complexity Density: 0.22 |
|
710 |
2 |
public static int[] extractCdnaProfile(... |
711 |
|
Hashtable<String, Object> hashtable, boolean ignoreGaps) |
712 |
|
{ |
713 |
|
|
714 |
|
|
715 |
2 |
int[] codonCounts = (int[]) hashtable.get(PROFILE); |
716 |
2 |
int[] sortedCounts = new int[codonCounts.length - 2]; |
717 |
2 |
System.arraycopy(codonCounts, 2, sortedCounts, 0, |
718 |
|
codonCounts.length - 2); |
719 |
|
|
720 |
2 |
int[] result = new int[3 + 2 * sortedCounts.length]; |
721 |
|
|
722 |
2 |
result[0] = AlignmentAnnotation.CDNA_PROFILE; |
723 |
|
|
724 |
2 |
char[] codons = new char[sortedCounts.length]; |
725 |
130 |
for (int i = 0; i < codons.length; i++) |
726 |
|
{ |
727 |
128 |
codons[i] = (char) i; |
728 |
|
} |
729 |
2 |
QuickSort.sort(sortedCounts, codons); |
730 |
2 |
int totalPercentage = 0; |
731 |
2 |
int distinctValuesCount = 0; |
732 |
2 |
int j = 3; |
733 |
2 |
int divisor = ignoreGaps ? codonCounts[1] : codonCounts[0]; |
734 |
8 |
for (int i = codons.length - 1; i >= 0; i--) |
735 |
|
{ |
736 |
8 |
final int codonCount = sortedCounts[i]; |
737 |
8 |
if (codonCount == 0) |
738 |
|
{ |
739 |
0 |
break; |
740 |
|
} |
741 |
8 |
final int percentage = codonCount * 100 / divisor; |
742 |
8 |
if (percentage == 0) |
743 |
|
{ |
744 |
|
|
745 |
|
|
746 |
|
|
747 |
2 |
break; |
748 |
|
} |
749 |
6 |
distinctValuesCount++; |
750 |
6 |
result[j++] = codons[i]; |
751 |
6 |
result[j++] = percentage; |
752 |
6 |
totalPercentage += percentage; |
753 |
|
} |
754 |
2 |
result[2] = totalPercentage; |
755 |
|
|
756 |
|
|
757 |
|
|
758 |
|
|
759 |
|
|
760 |
2 |
result[1] = distinctValuesCount; |
761 |
2 |
return Arrays.copyOfRange(result, 0, j); |
762 |
|
} |
763 |
|
|
764 |
|
|
765 |
|
|
766 |
|
|
767 |
|
@param |
768 |
|
|
769 |
|
|
770 |
|
@param |
771 |
|
|
772 |
|
|
|
|
| 90.3% |
Uncovered Elements: 3 (31) |
Complexity: 6 |
Complexity Density: 0.26 |
|
773 |
4 |
public static void calculateCdna(AlignmentI alignment,... |
774 |
|
Hashtable<String, Object>[] hconsensus) |
775 |
|
{ |
776 |
4 |
final char gapCharacter = alignment.getGapCharacter(); |
777 |
4 |
List<AlignedCodonFrame> mappings = alignment.getCodonFrames(); |
778 |
4 |
if (mappings == null || mappings.isEmpty()) |
779 |
|
{ |
780 |
0 |
return; |
781 |
|
} |
782 |
|
|
783 |
4 |
int cols = alignment.getWidth(); |
784 |
1928 |
for (int col = 0; col < cols; col++) |
785 |
|
{ |
786 |
|
|
787 |
1924 |
Hashtable<String, Object> columnHash = new Hashtable<>(); |
788 |
|
|
789 |
1924 |
int[] codonCounts = new int[66]; |
790 |
1924 |
codonCounts[0] = alignment.getSequences().size(); |
791 |
1924 |
int ungappedCount = 0; |
792 |
1924 |
for (SequenceI seq : alignment.getSequences()) |
793 |
|
{ |
794 |
20870 |
if (seq.getCharAt(col) == gapCharacter) |
795 |
|
{ |
796 |
10166 |
continue; |
797 |
|
} |
798 |
10704 |
List<char[]> codons = MappingUtils.findCodonsFor(seq, col, |
799 |
|
mappings); |
800 |
10704 |
for (char[] codon : codons) |
801 |
|
{ |
802 |
10657 |
int codonEncoded = CodingUtils.encodeCodon(codon); |
803 |
10657 |
if (codonEncoded >= 0) |
804 |
|
{ |
805 |
10657 |
codonCounts[codonEncoded + 2]++; |
806 |
10657 |
ungappedCount++; |
807 |
10657 |
break; |
808 |
|
} |
809 |
|
} |
810 |
|
} |
811 |
1924 |
codonCounts[1] = ungappedCount; |
812 |
|
|
813 |
1924 |
columnHash.put(PROFILE, codonCounts); |
814 |
1924 |
hconsensus[col] = columnHash; |
815 |
|
} |
816 |
|
} |
817 |
|
|
818 |
|
|
819 |
|
|
820 |
|
|
821 |
|
@param |
822 |
|
|
823 |
|
@param |
824 |
|
|
825 |
|
@param |
826 |
|
|
827 |
|
|
828 |
|
@param |
829 |
|
|
830 |
|
|
|
|
| 82.4% |
Uncovered Elements: 13 (74) |
Complexity: 18 |
Complexity Density: 0.36 |
|
831 |
4 |
public static void completeCdnaConsensus(... |
832 |
|
AlignmentAnnotation consensusAnnotation, |
833 |
|
Hashtable<String, Object>[] consensusData, |
834 |
|
boolean showProfileLogo, int nseqs) |
835 |
|
{ |
836 |
4 |
if (consensusAnnotation == null |
837 |
|
|| consensusAnnotation.annotations == null |
838 |
|
|| consensusAnnotation.annotations.length < consensusData.length) |
839 |
|
{ |
840 |
|
|
841 |
|
|
842 |
0 |
return; |
843 |
|
} |
844 |
|
|
845 |
|
|
846 |
4 |
consensusAnnotation.scaleColLabel = true; |
847 |
1928 |
for (int col = 0; col < consensusData.length; col++) |
848 |
|
{ |
849 |
1924 |
Hashtable<String, Object> hci = consensusData[col]; |
850 |
1924 |
if (hci == null) |
851 |
|
{ |
852 |
|
|
853 |
0 |
continue; |
854 |
|
} |
855 |
|
|
856 |
1924 |
final int[] codonCounts = (int[]) hci.get(PROFILE); |
857 |
1924 |
int totalCount = 0; |
858 |
|
|
859 |
|
|
860 |
|
|
861 |
|
|
862 |
1924 |
final char[] codons = new char[codonCounts.length - 2]; |
863 |
125060 |
for (int j = 2; j < codonCounts.length; j++) |
864 |
|
{ |
865 |
123136 |
final int codonCount = codonCounts[j]; |
866 |
123136 |
codons[j - 2] = (char) (j - 2); |
867 |
123136 |
totalCount += codonCount; |
868 |
|
} |
869 |
|
|
870 |
|
|
871 |
|
|
872 |
|
|
873 |
|
|
874 |
1924 |
int[] sortedCodonCounts = new int[codonCounts.length - 2]; |
875 |
1924 |
System.arraycopy(codonCounts, 2, sortedCodonCounts, 0, |
876 |
|
codonCounts.length - 2); |
877 |
1924 |
QuickSort.sort(sortedCodonCounts, codons); |
878 |
|
|
879 |
1924 |
int modalCodonEncoded = codons[codons.length - 1]; |
880 |
1924 |
int modalCodonCount = sortedCodonCounts[codons.length - 1]; |
881 |
1924 |
String modalCodon = String |
882 |
|
.valueOf(CodingUtils.decodeCodon(modalCodonEncoded)); |
883 |
1924 |
if (sortedCodonCounts.length > 1 && sortedCodonCounts[codons.length |
884 |
|
- 2] == sortedCodonCounts[codons.length - 1]) |
885 |
|
{ |
886 |
|
|
887 |
|
|
888 |
|
|
889 |
25 |
modalCodon = "+"; |
890 |
|
} |
891 |
1924 |
float pid = sortedCodonCounts[sortedCodonCounts.length - 1] * 100 |
892 |
|
/ (float) totalCount; |
893 |
|
|
894 |
|
|
895 |
|
|
896 |
|
|
897 |
|
|
898 |
|
|
899 |
|
|
900 |
|
|
901 |
|
|
902 |
|
|
903 |
1924 |
StringBuilder mouseOver = new StringBuilder(32); |
904 |
1924 |
StringBuilder samePercent = new StringBuilder(); |
905 |
1924 |
String percent = null; |
906 |
1924 |
String lastPercent = null; |
907 |
1924 |
int percentDecPl = getPercentageDp(nseqs); |
908 |
|
|
909 |
3823 |
for (int j = codons.length - 1; j >= 0; j--) |
910 |
|
{ |
911 |
3823 |
int codonCount = sortedCodonCounts[j]; |
912 |
3823 |
if (codonCount == 0) |
913 |
|
{ |
914 |
|
|
915 |
|
|
916 |
|
|
917 |
|
|
918 |
1924 |
if (samePercent.length() > 0) |
919 |
|
{ |
920 |
1899 |
mouseOver.append(samePercent).append(": ").append(percent) |
921 |
|
.append("% "); |
922 |
|
} |
923 |
1924 |
break; |
924 |
|
} |
925 |
1899 |
int codonEncoded = codons[j]; |
926 |
1899 |
final int pct = codonCount * 100 / totalCount; |
927 |
1899 |
String codon = String |
928 |
|
.valueOf(CodingUtils.decodeCodon(codonEncoded)); |
929 |
1899 |
StringBuilder sb = new StringBuilder(); |
930 |
1899 |
Format.appendPercentage(sb, pct, percentDecPl); |
931 |
1899 |
percent = sb.toString(); |
932 |
1899 |
if (showProfileLogo || codonCount == modalCodonCount) |
933 |
|
{ |
934 |
1899 |
if (percent.equals(lastPercent) && j > 0) |
935 |
|
{ |
936 |
0 |
samePercent.append(samePercent.length() == 0 ? "" : ", "); |
937 |
0 |
samePercent.append(codon); |
938 |
|
} |
939 |
|
else |
940 |
|
{ |
941 |
1899 |
if (samePercent.length() > 0) |
942 |
|
{ |
943 |
0 |
mouseOver.append(samePercent).append(": ").append(lastPercent) |
944 |
|
.append("% "); |
945 |
|
} |
946 |
1899 |
samePercent.setLength(0); |
947 |
1899 |
samePercent.append(codon); |
948 |
|
} |
949 |
1899 |
lastPercent = percent; |
950 |
|
} |
951 |
|
} |
952 |
|
|
953 |
1924 |
consensusAnnotation.annotations[col] = new Annotation(modalCodon, |
954 |
|
mouseOver.toString(), ' ', pid); |
955 |
|
} |
956 |
|
} |
957 |
|
|
958 |
|
|
959 |
|
|
960 |
|
|
961 |
|
|
962 |
|
|
963 |
|
@param |
964 |
|
@return |
965 |
|
|
|
|
| 57.1% |
Uncovered Elements: 3 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
966 |
900958 |
protected static int getPercentageDp(long nseq)... |
967 |
|
{ |
968 |
900975 |
int scale = 0; |
969 |
900999 |
while (nseq >= 100) |
970 |
|
{ |
971 |
0 |
scale++; |
972 |
0 |
nseq /= 10; |
973 |
|
} |
974 |
900980 |
return scale; |
975 |
|
} |
976 |
|
} |