X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FResidueColourScheme.java;h=64fd62e1cb2c921ddaaf9de7519c94fd0ec31d01;hb=bc39ee8df9694f820a8a8bd2430f527b87c07f31;hp=0d2db232b6f5724aadfbb50c62a1c78cd73c906a;hpb=174230b4233d9ce80f94527768d2cd2f76da11ab;p=jalview.git diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index 0d2db23..64fd62e 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -41,7 +41,7 @@ public class ResidueColourScheme implements ColourSchemeI int threshold = 0; /* Set when threshold colouring to either pid_gaps or pid_nogaps*/ - protected String ignoreGaps = "pid_gaps"; + protected String ignoreGaps = AAFrequency.PID_GAPS; /** Consenus as a hashtable array */ Hashtable [] consensus; @@ -83,7 +83,7 @@ public class ResidueColourScheme implements ColourSchemeI */ public Color findColour(String aa) { - return colors[((Integer) (ResidueProperties.aaHash.get(aa))).intValue()]; + return colors[ResidueProperties.aaIndex[aa.charAt(0)]]; } @@ -91,7 +91,7 @@ public class ResidueColourScheme implements ColourSchemeI public Color findColour(String s, int j) { - int index = ((Integer) (ResidueProperties.aaHash.get(s))).intValue(); + int index = ResidueProperties.aaIndex[s.charAt(0)]; if ((threshold == 0) || aboveThreshold(ResidueProperties.aa[index], j)) { @@ -129,9 +129,9 @@ public class ResidueColourScheme implements ColourSchemeI { threshold = ct; if(ignoreGaps) - this.ignoreGaps = "pid_nogaps"; + this.ignoreGaps = AAFrequency.PID_NOGAPS; else - this.ignoreGaps = "pid_gaps"; + this.ignoreGaps = AAFrequency.PID_GAPS; } /** @@ -144,13 +144,25 @@ public class ResidueColourScheme implements ColourSchemeI */ public boolean aboveThreshold(String s, int j) { - if ((((Integer) consensus[j].get("maxCount")).intValue() != -1) && - consensus[j].contains(s)) + char c = s.charAt(0); + if ('a' <= c && c <= 'z') { - if (((Float)consensus[j].get(ignoreGaps)).floatValue() >= threshold) - { - return true; - } + // TO UPPERCASE !!! + //Faster than toUpperCase + c -= ('a' - 'A'); + s = String.valueOf(c); + } + + if (consensus == null || consensus[j] == null) + return false; + + if ( ( ( (Integer) consensus[j].get(AAFrequency.MAXCOUNT)).intValue() != -1) && + consensus[j].contains(s)) + { + if ( ( (Float) consensus[j].get(ignoreGaps)).floatValue() >= threshold) + { + return true; + } } return false; @@ -177,18 +189,16 @@ public class ResidueColourScheme implements ColourSchemeI * * @param consensus DOCUMENT ME! */ - public void setConsensus(Vector vconsensus) + public void setConsensus(Hashtable [] consensus) { - if(vconsensus==null) + if(consensus==null) return; - int i, iSize=vconsensus.size(); - consensus = new Hashtable[iSize]; - for(i=0; i