remove gaps applies to selected area
authoramwaterhouse <Andrew Waterhouse>
Thu, 16 Jun 2005 09:34:31 +0000 (09:34 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 16 Jun 2005 09:34:31 +0000 (09:34 +0000)
src/jalview/appletgui/AlignFrame.java
src/jalview/gui/AlignFrame.java

index b314854..bb4b58a 100755 (executable)
@@ -544,16 +544,32 @@ public class AlignFrame
 \r
   public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)\r
   {\r
-    addHistoryItem(new HistoryItem("Remove Gaps",\r
-                                   viewport.alignment,\r
+    addHistoryItem(new HistoryItem("Remove Gaps", viewport.alignment,\r
                                    HistoryItem.HIDE));\r
+\r
     SequenceI current;\r
     int jSize;\r
-    for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)\r
+\r
+    Vector seqs=null;\r
+\r
+    int start=0, end = viewport.alignment.getWidth();\r
+\r
+    if(viewport.getSelectionGroup()!=null)\r
     {\r
-      current = viewport.getAlignment().getSequenceAt(i);\r
+      seqs = viewport.getSelectionGroup().sequences;\r
+      start = viewport.getSelectionGroup().getStartRes();\r
+      end = viewport.getSelectionGroup().getEndRes();\r
+    }\r
+    else\r
+      seqs = viewport.alignment.getSequences();\r
+\r
+    for (int i = 0; i <seqs.size(); i++)\r
+    {\r
+      current = (SequenceI)seqs.elementAt(i);\r
       jSize = current.getLength();\r
-      for (int j = 0; j < jSize; j++)\r
+\r
+      int j = start;\r
+      do\r
       {\r
         if (jalview.util.Comparison.isGap(current.getCharAt(j)))\r
         {\r
@@ -561,13 +577,17 @@ public class AlignFrame
           j--;\r
           jSize--;\r
         }\r
+        j++;\r
       }\r
+      while(j < end);\r
     }\r
+\r
     viewport.updateConservation();\r
     viewport.updateConsensus();\r
     alignPanel.repaint();\r
   }\r
 \r
+\r
   public void findMenuItem_actionPerformed(ActionEvent e)\r
   {\r
     Finder finder = new Finder(alignPanel);\r
index 484b8cd..cc7ce48 100755 (executable)
@@ -679,13 +679,26 @@ public class AlignFrame
     SequenceI current;\r
     int jSize;\r
 \r
-    for (int i = 0; i < viewport.getAlignment().getSequences().size();\r
-         i++)\r
+    Vector seqs=null;\r
+\r
+    int start=0, end = viewport.alignment.getWidth();\r
+\r
+    if(viewport.getSelectionGroup()!=null)\r
     {\r
-      current = viewport.getAlignment().getSequenceAt(i);\r
+      seqs = viewport.getSelectionGroup().sequences;\r
+      start = viewport.getSelectionGroup().getStartRes();\r
+      end = viewport.getSelectionGroup().getEndRes();\r
+    }\r
+    else\r
+      seqs = viewport.alignment.getSequences();\r
+\r
+    for (int i = 0; i <seqs.size(); i++)\r
+    {\r
+      current = (SequenceI)seqs.elementAt(i);\r
       jSize = current.getLength();\r
 \r
-      for (int j = 0; j < jSize; j++)\r
+      int j = start;\r
+      do\r
       {\r
         if (jalview.util.Comparison.isGap(current.getCharAt(j)))\r
         {\r
@@ -693,7 +706,9 @@ public class AlignFrame
           j--;\r
           jSize--;\r
         }\r
+        j++;\r
       }\r
+      while(j < end);\r
     }\r
 \r
     viewport.updateConservation();\r