createColourFromName if not specified
[jalview.git] / src / jalview / analysis / Conservation.java
index 0bfb636..0aa9805 100755 (executable)
@@ -123,7 +123,7 @@ public class Conservation
 \r
                 for (j = 1; j <= len; j++)\r
                 {\r
-                    sqnum[j] = ((Integer) jalview.schemes.ResidueProperties.aaHash.get(Character.toString(\r
+                    sqnum[j] = ((Integer) jalview.schemes.ResidueProperties.aaHash.get(String.valueOf(\r
                                 sq.charAt(j - 1)))).intValue(); // yuk - JBPNote - case taken care of in aaHash\r
                 }\r
 \r
@@ -145,7 +145,9 @@ public class Conservation
     {\r
       Hashtable resultHash, residueHash, ht;\r
       int count, thresh, j, jSize = sequences.size();\r
-      String sequence, res, type;\r
+      String type, res=null;\r
+      SequenceI sequence;\r
+      char c;\r
       Enumeration enumeration, enumeration2;\r
 \r
       for (int i = start; i <= end; i++)\r
@@ -157,13 +159,25 @@ public class Conservation
             {\r
                 // JBPNote - have to make sure elements of the sequences vector\r
                 //  are tested like this everywhere...\r
-                if (sequences.elementAt(j) instanceof Sequence)\r
-                {\r
-                    sequence = ((Sequence) sequences.elementAt(j)).getSequence();\r
+                    sequence = (Sequence) sequences.elementAt(j);\r
 \r
-                    if (sequence.length() > i)\r
+                    if (sequence.getLength() > i)\r
                     {\r
-                        res = Character.toString(Character.toUpperCase(sequence.charAt(i)));\r
+                        c = sequence.getCharAt(i);\r
+\r
+                        // No need to check if its a '-'\r
+                        if(c == '.' || c==' ')\r
+                          c = '-';\r
+\r
+                        if ('a' <= c && c <= 'z')\r
+                        {\r
+                          // TO UPPERCASE !!!\r
+                          //Faster than toUpperCase\r
+                          c -= ('a' - 'A') ;\r
+                        }\r
+\r
+                        res = String.valueOf( c );\r
+\r
 \r
                         if (residueHash.containsKey(res))\r
                         {\r
@@ -189,7 +203,6 @@ public class Conservation
                             residueHash.put("-", new Integer(1));\r
                         }\r
                     }\r
-                }\r
             }\r
 \r
             //What is the count threshold to count the residues in residueHash()\r