mouseOver.append(hci.get(AAFrequency.MAXRESIDUE) + " ");
}
int[][] profile = (int[][]) hci.get(AAFrequency.PROFILE);
- int sequenceCount = profile[1][0];
- int nonGappedCount = profile[1][1];
- int normalisedBy = ignoreGapsInConsensusCalculation ? nonGappedCount
- : sequenceCount;
if (profile != null && includeAllConsSymbols)
{
+ int sequenceCount = profile[1][0];
+ int nonGappedCount = profile[1][1];
+ int normalisedBy = ignoreGapsInConsensusCalculation ? nonGappedCount
+ : sequenceCount;
mouseOver.setLength(0);
if (alphabet != null)
{
.append(((c == 0) ? "" : "; "))
.append(alphabet[c])
.append(" ")
- .append(((fmt != null) ? fmt.form(tval) : ((int) tval)))
+ .append(((fmt != null) ? fmt.formDouble(tval) : ((int) tval)))
.append("%");
}
}
// { (char) c };
vl[c] = profile[0][c];
}
- QuickSort.sort(vl, ca);
+ QuickSort.sortFloat(vl, ca);
for (int p = 0, c = ca.length - 1; profile[0][ca[c]] > 0; c--)
{
final char residue = ca[c];
.append((((p == 0) ? "" : "; ")))
.append(residue)
.append(" ")
- .append(((fmt != null) ? fmt.form(tval)
+ .append(((fmt != null) ? fmt.formDouble(tval)
: ((int) tval))).append("%");
p++;
}
else
{
mouseOver.append(
- (((fmt != null) ? fmt.form(value) : ((int) value))))
+ (((fmt != null) ? fmt.formDouble(value) : ((int) value))))
.append("%");
}
consensus.annotations[i] = new Annotation(maxRes,
ca[c] = (char) c;
vl[c] = profile[0][c];
}
- QuickSort.sort(vl, ca);
+ QuickSort.sortFloat(vl, ca);
int nextArrayPos = 2;
int totalPercentage = 0;
int distinctValuesCount = 0;
{
codons[i] = (char) i;
}
- QuickSort.sort(sortedCounts, codons);
+ QuickSort.sortInt(sortedCounts, codons);
int totalPercentage = 0;
int distinctValuesCount = 0;
int j = 3;
// array holds #seqs, #ungapped, then codon counts indexed by codon
final int[] codonCounts = (int[]) hci.get(PROFILE);
int totalCount = 0;
- StringBuilder mouseOver = new StringBuilder(32);
/*
* First pass - get total count and find the highest
int[] sortedCodonCounts = new int[codonCounts.length - 2];
System.arraycopy(codonCounts, 2, sortedCodonCounts, 0,
codonCounts.length - 2);
- QuickSort.sort(sortedCodonCounts, codons);
+ QuickSort.sortInt(sortedCodonCounts, codons);
int modalCodonEncoded = codons[codons.length - 1];
int modalCodonCount = sortedCodonCounts[codons.length - 1];
*/
/*
- * Scan sorted array backwards for most frequent values first.
+ * Scan sorted array backwards for most frequent values first. Show
+ * repeated values compactly.
*/
+ StringBuilder mouseOver = new StringBuilder(32);
+ StringBuilder samePercent = new StringBuilder();
+ String percent = null;
+ String lastPercent = null;
+ Format fmt = getPercentageFormat(nseqs);
+
for (int j = codons.length - 1; j >= 0; j--)
{
int codonCount = sortedCodonCounts[j];
if (codonCount == 0)
{
+ /*
+ * remaining codons are 0% - ignore, but finish off the last one if
+ * necessary
+ */
+ if (samePercent.length() > 0)
+ {
+ mouseOver.append(samePercent).append(": ").append(percent)
+ .append("% ");
+ }
break;
}
int codonEncoded = codons[j];
final int pct = codonCount * 100 / totalCount;
String codon = String
.valueOf(CodingUtils.decodeCodon(codonEncoded));
- Format fmt = getPercentageFormat(nseqs);
- String formatted = fmt == null ? Integer.toString(pct) : fmt
- .form(pct);
+ percent = fmt == null ? Integer.toString(pct) : fmt
+ .formLong(pct);
if (showProfileLogo || codonCount == modalCodonCount)
{
- mouseOver.append(codon).append(": ").append(formatted)
- .append("% ");
+ if (percent.equals(lastPercent) && j > 0)
+ {
+ samePercent.append(samePercent.length() == 0 ? "" : ", ");
+ samePercent.append(codon);
+ }
+ else
+ {
+ if (samePercent.length() > 0)
+ {
+ mouseOver.append(samePercent).append(": ")
+ .append(lastPercent)
+ .append("% ");
+ }
+ samePercent.setLength(0);
+ samePercent.append(codon);
+ }
+ lastPercent = percent;
}
}