import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
import jalview.datamodel.SequenceI;
+import jalview.ext.android.SparseIntArray;
import jalview.util.Format;
import jalview.util.MappingUtils;
import jalview.util.QuickSort;
char c = '-';
float percentage;
- int[] values = new int[255];
+ // int[] values = new int[255];
char[] seq;
maxCount = 0;
maxResidue = "";
nongap = 0;
- values = new int[255];
+ // values = new int[255];
+ SparseIntArray values = new SparseIntArray();
for (j = 0; j < jSize; j++)
{
if (c == '-')
{
- values['-']++;
+ // values['-']++;
+ values.put('-', values.get('-') + 1);
continue;
}
else if ('a' <= c && c <= 'z')
}
nongap++;
- values[c]++;
+ // values[c]++;
+ values.put(c, values.get(c) + 1);
}
else
{
- values['-']++;
+ // values['-']++;
+ values.put('-', values.get('-') + 1);
}
}
if (jSize == 1)
for (v = 'A'; v <= 'Z'; v++)
{
// TODO why ignore values[v] == 1?
- if (values[v] < 1 /* 2 */|| values[v] < maxCount)
+ int count = values.get(v); // values[v];
+ if (count < 1 /* 2 */|| count < maxCount)
{
continue;
}
- if (values[v] > maxCount)
+ if (count > maxCount)
{
maxResidue = CHARS[v - 'A'];
}
- else if (values[v] == maxCount)
+ else if (count == maxCount)
{
maxResidue += CHARS[v - 'A'];
}
- maxCount = values[v];
+ maxCount = count;
}
}
if (maxResidue.length() == 0)
if (profile)
{
// TODO use a 1-dimensional array with jSize, nongap in [0] and [1]
- residueHash.put(PROFILE, new int[][] { values,
- new int[] { jSize, nongap } });
+ // residueHash.put(PROFILE, new int[][] { values,
+ // new int[] { jSize, nongap } });
+ residueHash.put(PROFILE, new Profile(values, jSize, nongap));
}
residueHash.put(MAXCOUNT, new Integer(maxCount));
residueHash.put(MAXRESIDUE, maxResidue);
boolean ignoreGaps)
{
int[] rtnval = new int[64];
- int[][] profile = (int[][]) hconsensus.get(AAFrequency.PROFILE);
+ // int[][] profile = (int[][]) hconsensus.get(AAFrequency.PROFILE);
+ Profile profile = (Profile) hconsensus.get(AAFrequency.PROFILE);
if (profile == null)
{
return null;
}
- char[] ca = new char[profile[0].length];
- float[] vl = new float[profile[0].length];
- for (int c = 0; c < ca.length; c++)
+ // int profileLength = profile[0].length;
+ int profileLength = profile.profile.size();
+ char[] ca = new char[profileLength];
+ float[] vl = new float[profileLength];
+ // for (int c = 0; c < ca.length; c++)
+ // {
+ // ca[c] = (char) c;
+ // vl[c] = profile[0][c];
+ // }
+ for (int i = 0; i < profileLength; i++)
{
- ca[c] = (char) c;
- vl[c] = profile[0][c];
+ int c = profile.profile.keyAt(i);
+ ca[i] = (char) c;
+ vl[i] = profile.profile.get(c);
}
QuickSort.sort(vl, ca);
int nextArrayPos = 2;
import jalview.datamodel.Annotation;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
+import jalview.ext.android.SparseIntArray;
import jalview.schemes.ResidueProperties;
import java.awt.Color;
public void calculate()
{
int thresh, j, jSize = sequences.length;
- int[] values; // Replaces residueHash
+ // int[] values; // Replaces residueHash
+ SparseIntArray values = new SparseIntArray();
char c;
total = new Hashtable[maxLength];
for (int i = start; i <= end; i++)
{
- values = new int[255];
+ // values = new int[255];
for (j = 0; j < jSize; j++)
{
c = toUpperCase(c);
}
- values[c]++;
+ // values[c]++;
+ values.put(c, values.get(c) + 1);
}
else
{
- values['-']++;
+ // values['-']++;
+ values.put('-', values.get('-') + 1);
}
}
for (char v = '-'; v < 'Z'; v++)
{
- if (values[v] > thresh)
+ // if (values[v] > thresh)
+ if (values.get(v) > thresh)
{
String res = String.valueOf(v);
--- /dev/null
+package jalview.analysis;
+
+import jalview.ext.android.SparseIntArray;
+
+public class Profile
+{
+ /*
+ * array of keys (chars) and values (counts)
+ */
+ public final SparseIntArray profile;
+
+ /*
+ * the number of sequences in the profile
+ */
+ public final int ht;
+
+ /*
+ * the number of non-gapped sequences in the profile
+ */
+ public final int nonGapped;
+
+ public Profile(SparseIntArray counts, int height, int nongappedCount)
+ {
+ this.profile = counts;
+ this.ht = height;
+ this.nonGapped = nongappedCount;
+ }
+
+ public SparseIntArray getProfile()
+ {
+ return profile;
+ }
+}