}
else
{
+ // FIXME iterate over values keys instead
for (v = 'A'; v <= 'Z'; v++)
{
// TODO why ignore values[v] == 1?
{
mouseOver.append(hci.get(AAFrequency.MAXRESIDUE) + " ");
}
- int[][] profile = (int[][]) hci.get(AAFrequency.PROFILE);
+ // int[][] profile = (int[][]) hci.get(AAFrequency.PROFILE);
+ Profile profile = (Profile) hci.get(AAFrequency.PROFILE);
if (profile != null && includeAllConsSymbols)
{
- int sequenceCount = profile[1][0];
- int nonGappedCount = profile[1][1];
+ int sequenceCount = profile.height;// profile[1][0];
+ int nonGappedCount = profile.nonGapped;// [1][1];
int normalisedBy = ignoreGapsInConsensusCalculation ? nonGappedCount
: sequenceCount;
mouseOver.setLength(0);
- if (alphabet != null)
+ // TODO do this sort once only in calculate()?
+ // char[][] ca = new char[profile[0].length][];
+ // /int length = profile[0].length;
+ int length = profile.profile.size();
+ char[] ca = new char[length];
+ // float[] vl = new float[length];
+ int[] vl = new int[length];
+ for (int c = 0; c < ca.length; c++)
{
- for (int c = 0; c < alphabet.length; c++)
+ int theChar = profile.profile.keyAt(c);
+ ca[c] = (char) theChar;// c;
+ // ca[c] = new char[]
+ // { (char) c };
+ vl[c] = profile.profile.get(theChar);// profile[0][c];
+ }
+
+ /*
+ * sort characters into ascending order of their counts
+ */
+ QuickSort.sort(vl, ca);
+
+ /*
+ * traverse in reverse order (highest count first) to build tooltip
+ */
+ // for (int p = 0, c = ca.length - 1; profile[0][ca[c]] > 0; c--)
+ for (int p = 0, c = ca.length - 1; c >= 0; c--)
+ {
+ final char residue = ca[c];
+ if (residue != '-')
{
- float tval = profile[0][alphabet[c]] * 100f / normalisedBy;
+ // float tval = profile[0][residue] * 100f / normalisedBy;
+ // float tval = profile[0][residue] * 100f / normalisedBy;
+ float tval = (vl[c] * 100f) / normalisedBy;
mouseOver
- .append(((c == 0) ? "" : "; "))
- .append(alphabet[c])
+ .append((((p == 0) ? "" : "; ")))
+ .append(residue)
.append(" ")
.append(((fmt != null) ? fmt.form(tval) : ((int) tval)))
.append("%");
- }
- }
- else
- {
- // TODO do this sort once only in calculate()?
- // char[][] ca = new char[profile[0].length][];
- char[] ca = new char[profile[0].length];
- float[] vl = new float[profile[0].length];
- for (int c = 0; c < ca.length; c++)
- {
- ca[c] = (char) c;
- // ca[c] = new char[]
- // { (char) c };
- vl[c] = profile[0][c];
- }
- QuickSort.sort(vl, ca);
- for (int p = 0, c = ca.length - 1; profile[0][ca[c]] > 0; c--)
- {
- final char residue = ca[c];
- if (residue != '-')
- {
- float tval = profile[0][residue] * 100f / normalisedBy;
- mouseOver
- .append((((p == 0) ? "" : "; ")))
- .append(residue)
- .append(" ")
- .append(((fmt != null) ? fmt.form(tval)
- : ((int) tval))).append("%");
- p++;
- }
+ p++;
}
}
}
int nextArrayPos = 2;
int totalPercentage = 0;
int distinctValuesCount = 0;
- final int divisor = profile[1][ignoreGaps ? 1 : 0];
- for (int c = ca.length - 1; profile[0][ca[c]] > 0; c--)
+ final int divisor = ignoreGaps ? profile.nonGapped : profile.height;
+ // final int divisor = profile[1][ignoreGaps ? 1 : 0];
+ int j = profile.profile.size();
+ for (int i = 0; i < j; i++)
+// for (int c = ca.length - 1; profile[0][ca[c]] > 0; c--)
{
- if (ca[c] != '-')
+ int theChar = profile.profile.keyAt(i);
+ int charCount = profile.profile.get(theChar);
+
+// if (ca[c] != '-')
+ if (theChar != '-')
{
- rtnval[nextArrayPos++] = ca[c];
- final int percentage = (int) (profile[0][ca[c]] * 100f / divisor);
+// rtnval[nextArrayPos++] = ca[c];
+ rtnval[nextArrayPos++] = theChar;
+// final int percentage = (int) (profile[0][ca[c]] * 100f / divisor);
+ final int percentage = (charCount * 100) / divisor;
rtnval[nextArrayPos++] = percentage;
totalPercentage += percentage;
distinctValuesCount++;