/*\r
* Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
*\r
* This program is free software; you can redistribute it and/or\r
* modify it under the terms of the GNU General Public License\r
*/\r
package jalview.schemes;\r
\r
-import java.util.*;\r
-\r
import java.awt.*;\r
\r
+import jalview.analysis.*;\r
+\r
public class Blosum62ColourScheme\r
extends ResidueColourScheme\r
{\r
super();\r
}\r
\r
- public Color findColour(String s, int j)\r
+ public Color findColour(char res, int j)\r
{\r
- if ( (threshold != 0) && !aboveThreshold(s, j))\r
+ if ('a' <= res && res <= 'z')\r
+ {\r
+ // TO UPPERCASE !!!\r
+ res -= ('a' - 'A');\r
+ }\r
+\r
+ if (consensus == null ||\r
+ j >= consensus.length ||\r
+ consensus[j] == null ||\r
+ (threshold != 0 && !aboveThreshold(res, j)))\r
{\r
return Color.white;\r
}\r
\r
- Hashtable hash = (Hashtable) consensus.elementAt(j);\r
+ Color currentColour;\r
\r
- if (!jalview.util.Comparison.isGap( (s.charAt(0))))\r
+ if (!jalview.util.Comparison.isGap(res))\r
{\r
- String max = (String) hash.get("maxResidue");\r
+ String max = (String) consensus[j].get(AAFrequency.MAXRESIDUE);\r
\r
- if (max.indexOf(s) > -1)\r
+ if (max.indexOf(res) > -1)\r
{\r
- return new Color(154, 154, 255);\r
+ currentColour = new Color(154, 154, 255);\r
}\r
else\r
{\r
\r
do\r
{\r
- c += ResidueProperties.getBLOSUM62(max.substring(max_aa,\r
- max_aa + 1), s);\r
+ c += ResidueProperties.getBLOSUM62(\r
+ max.charAt(max_aa), res);\r
}\r
while (++max_aa < n);\r
\r
if (c > 0)\r
{\r
- return new Color(204, 204, 255);\r
+ currentColour = new Color(204, 204, 255);\r
}\r
else\r
{\r
- return Color.white;\r
+ currentColour = Color.white;\r
}\r
}\r
+\r
+ if (conservationColouring)\r
+ {\r
+ currentColour = applyConservation(currentColour, j);\r
+ }\r
}\r
else\r
{\r
return Color.white;\r
}\r
+\r
+ return currentColour;\r
}\r
}\r