check conservation length
authoramwaterhouse <Andrew Waterhouse>
Tue, 27 Feb 2007 13:38:40 +0000 (13:38 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 27 Feb 2007 13:38:40 +0000 (13:38 +0000)
src/jalview/schemes/ResidueColourScheme.java

index 67828ce..f43aa02 100755 (executable)
@@ -47,6 +47,7 @@ public class ResidueColourScheme
 \r
   /** Conservation string as a char array */\r
   char[] conservation;\r
+  int conservationLength=0;\r
 \r
   /** DOCUMENT ME!! */\r
   int inc = 30;\r
@@ -144,7 +145,7 @@ public class ResidueColourScheme
       c -= ('a' - 'A');\r
     }\r
 \r
-    if (consensus == null || consensus[j] == null)\r
+    if (consensus == null || consensus.length<j || consensus[j] == null)\r
     {\r
       return false;\r
     }\r
@@ -207,6 +208,7 @@ public class ResidueColourScheme
       {\r
         conservation[i] = cons.getConsSequence().getCharAt(i);\r
       }\r
+      conservationLength = conservation.length;\r
     }\r
 \r
   }\r
@@ -223,9 +225,9 @@ public class ResidueColourScheme
   Color applyConservation(Color currentColour, int i)\r
   {\r
 \r
-    if ( (conservation[i] != '*') && (conservation[i] != '+'))\r
+    if ((conservationLength>i) && (conservation[i] != '*') && (conservation[i] != '+'))\r
     {\r
-      if (jalview.util.Comparison.isGap(conservation[i]))\r
+      if ( jalview.util.Comparison.isGap(conservation[i]))\r
       {\r
         currentColour = Color.white;\r
       }\r