Cannot delete residues
authoramwaterhouse <Andrew Waterhouse>
Fri, 24 Feb 2006 11:47:03 +0000 (11:47 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 24 Feb 2006 11:47:03 +0000 (11:47 +0000)
src/jalview/gui/AlignFrame.java

index 35ac570..e500422 100755 (executable)
@@ -803,24 +803,50 @@ public class AlignFrame
       return;\r
     }\r
 \r
-    addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment,\r
-                                   HistoryItem.HIDE));\r
 \r
     SequenceGroup sg = viewport.getSelectionGroup();\r
-    boolean allSequences = false;\r
-    if (sg.sequences.size() == viewport.alignment.getHeight())\r
+\r
+\r
+\r
+    //Jalview no longer allows deletion of residues.\r
+    //Check here whether any residues are in selection area\r
+    if( sg.getEndRes()-sg.getStartRes() < viewport.alignment.getWidth()-1)\r
     {\r
-      allSequences = true;\r
+      for (int i = 0; i < sg.sequences.size(); i++)\r
+      {\r
+        SequenceI seq = sg.getSequenceAt(i);\r
+        int j = sg.getStartRes();\r
+        do\r
+        {\r
+          if (!jalview.util.Comparison.isGap(seq.getCharAt(j)))\r
+          {\r
+            JOptionPane.showInternalMessageDialog(\r
+                Desktop.desktop, "Cannot delete residues from alignment!\n"\r
+                + "Try hiding columns instead.",\r
+                "Deletion of residues not permitted",\r
+                JOptionPane.WARNING_MESSAGE);\r
+\r
+            return;\r
+          }\r
+          j++;\r
+        }while(j<=sg.getEndRes());\r
+      }\r
     }\r
 \r
+\r
+    addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment,\r
+                                   HistoryItem.HIDE));\r
+\r
+\r
     for (int i = 0; i < sg.sequences.size(); i++)\r
     {\r
       SequenceI seq = sg.getSequenceAt(i);\r
       int index = viewport.getAlignment().findIndex(seq);\r
+\r
       seq.deleteChars(sg.getStartRes(), sg.getEndRes() + 1);\r
 \r
       // If the cut affects all sequences, remove highlighted columns\r
-      if (allSequences)\r
+      if (sg.sequences.size() == viewport.alignment.getHeight())\r
       {\r
         viewport.getColumnSelection().removeElements(sg.getStartRes(),\r
             sg.getEndRes() + 1);\r
@@ -1194,8 +1220,8 @@ public class AlignFrame
     JInternalFrame frame = new JInternalFrame();\r
     Finder finder = new Finder(viewport, alignPanel, frame);\r
     frame.setContentPane(finder);\r
-    Desktop.addInternalFrame(frame, "Find", 340, 110);\r
     frame.setLayer(JLayeredPane.PALETTE_LAYER);\r
+    Desktop.addInternalFrame(frame, "Find", 340, 110);\r
   }\r
 \r
   /**\r
@@ -1329,7 +1355,7 @@ public class AlignFrame
       new SequenceFeatureFetcher(viewport.\r
                                  alignment,\r
                                  alignPanel);\r
-      viewport.showSequenceFeatures(true);\r
+      viewport.setShowSequenceFeatures(true);\r
       showSeqFeatures.setSelected(true);\r
     }\r
   }\r
@@ -1347,8 +1373,12 @@ public class AlignFrame
    */\r
   public void showSeqFeatures_actionPerformed(ActionEvent evt)\r
   {\r
-    viewport.showSequenceFeatures(showSeqFeatures.isSelected());\r
+    viewport.setShowSequenceFeatures(showSeqFeatures.isSelected());\r
     alignPanel.repaint();\r
+    if (alignPanel.getOverviewPanel() != null)\r
+    {\r
+      alignPanel.getOverviewPanel().updateOverviewImage();\r
+    }\r
   }\r
 \r
   /**\r
@@ -2627,6 +2657,7 @@ public boolean parseGroupsFile(String file)
     }\r
 \r
     viewport.showSequenceFeatures = true;\r
+    showSeqFeatures.setSelected(true);\r
     alignPanel.repaint();\r
     return true;\r
 }\r