formatting
[jalview.git] / src / jalview / analysis / AAFrequency.java
index c1c4f71..4a68f81 100755 (executable)
@@ -53,6 +53,11 @@ public class AAFrequency
 \r
      Hashtable [] reply = new Hashtable[width];\r
 \r
+     if(end>=width)\r
+     {\r
+       end = width;\r
+     }\r
+\r
      calculate(seqs, start, end, reply);\r
 \r
      return reply;\r
@@ -68,24 +73,24 @@ public static final void calculate(SequenceI[] sequences,
   char c;\r
   float percentage;\r
 \r
-  int[] values = new int[132];\r
+  int[] values = new int[255];\r
 \r
-  String seq;\r
+  char [] seq;\r
 \r
   for (i = start; i < end; i++)\r
   {\r
     residueHash = new Hashtable();\r
     maxCount = 0;\r
-    maxResidue = "-";\r
+    maxResidue = "";\r
     nongap = 0;\r
-    values = new int[132];\r
+    values = new int[255];\r
 \r
     for (j = 0; j < jSize; j++)\r
     {\r
       seq = sequences[j].getSequence();\r
-      if (seq.length() > i)\r
+      if (seq.length > i)\r
       {\r
-        c = seq.charAt(i);\r
+        c = seq[i];\r
 \r
         if(c == '.' || c==' ')\r
           c = '-';\r
@@ -112,7 +117,7 @@ public static final void calculate(SequenceI[] sequences,
 \r
     for (v = 'A'; v < 'Z'; v++)\r
     {\r
-      if (values[v] == 0 || values[v] < maxCount)\r
+      if (values[v] < 2 || values[v] < maxCount)\r
         continue;\r
 \r
       if (values[v] > maxCount)\r
@@ -126,6 +131,8 @@ public static final void calculate(SequenceI[] sequences,
       maxCount = values[v];\r
     }\r
 \r
+    if(maxResidue.length()==0)\r
+      maxResidue = "-";\r
 \r
     residueHash.put(MAXCOUNT, new Integer(maxCount));\r
     residueHash.put(MAXRESIDUE, maxResidue);\r