Set all gaps to - symbol
authoramwaterhouse <Andrew Waterhouse>
Fri, 7 Apr 2006 13:48:39 +0000 (13:48 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 7 Apr 2006 13:48:39 +0000 (13:48 +0000)
src/jalview/analysis/Conservation.java

index b9b68ce..b914108 100755 (executable)
@@ -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,24 @@ 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 = String.valueOf(Character.toUpperCase(sequence.charAt(i)));\r
+                        c = sequence.getCharAt(i);\r
+\r
+                        if(jalview.util.Comparison.isGap(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 +202,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