Percentage precalculated in aafrequency
[jalview.git] / src / jalview / schemes / ResidueColourScheme.java
index 9c10e7d..3181cf4 100755 (executable)
@@ -34,8 +34,11 @@ public class ResidueColourScheme implements ColourSchemeI
     Color[] colors;\r
     int threshold = 0;\r
 \r
+    /* Set when threshold colouring to either pid_gaps or pid_nogaps*/\r
+    protected String ignoreGaps = "pid_gaps";\r
+\r
     /** DOCUMENT ME!! */\r
-    public Vector consensus;\r
+    public Hashtable [] consensus;\r
 \r
     /**\r
      * Creates a new ResidueColourScheme object.\r
@@ -61,9 +64,12 @@ public class ResidueColourScheme implements ColourSchemeI
      *\r
      * @param consensus DOCUMENT ME!\r
      */\r
-    public void setConsensus(Vector consensus)\r
+    public void setConsensus(Vector vconsensus)\r
     {\r
-        this.consensus = consensus;\r
+       int i, iSize=vconsensus.size();\r
+       consensus = new Hashtable[iSize];\r
+       for(i=0; i<iSize; i++)\r
+        consensus[i] = (Hashtable)vconsensus.elementAt(i);\r
     }\r
 \r
     /**\r
@@ -113,9 +119,13 @@ public class ResidueColourScheme implements ColourSchemeI
      *\r
      * @param ct DOCUMENT ME!\r
      */\r
-    public void setThreshold(int ct)\r
+    public void setThreshold(int ct, boolean ignoreGaps)\r
     {\r
         threshold = ct;\r
+        if(ignoreGaps)\r
+          this.ignoreGaps = "pid_nogaps";\r
+        else\r
+          this.ignoreGaps = "pid_gaps";\r
     }\r
 \r
     /**\r
@@ -128,16 +138,14 @@ public class ResidueColourScheme implements ColourSchemeI
      */\r
     public boolean aboveThreshold(String s, int j)\r
     {\r
-        Hashtable hash = (Hashtable) consensus.elementAt(j);\r
-\r
-        if ((((Integer) hash.get("maxCount")).intValue() != -1) &&\r
-                hash.contains(s))\r
+      if(consensus==null)\r
+        System.out.println("its null");\r
+        if ((((Integer) consensus[j].get("maxCount")).intValue() != -1) &&\r
+                consensus[j].contains(s))\r
         {\r
-            ////  resCount////////////////////                  ///////////////seq count////////////\r
-            double sc = (((Integer) hash.get(s)).intValue() * 100.0) / ((Integer) hash.get(\r
-                    "size")).intValue();\r
+            float ratio =  ((Float)consensus[j].get(ignoreGaps)).floatValue();\r
 \r
-            if (sc >= threshold)\r
+            if (ratio >= threshold)\r
             {\r
                 return true;\r
             }\r