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