Merge branch 'develop' into developtomchmmer
[jalview.git] / src / jalview / jbgui / GAlignFrame.java
index faa0d5d..c228c90 100755 (executable)
 package jalview.jbgui;
 
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
+import jalview.analysis.GeneticCodeI;
+import jalview.analysis.GeneticCodes;
 import jalview.api.SplitContainerI;
 import jalview.bin.Cache;
 import jalview.gui.JvSwingUtils;
 import jalview.gui.Preferences;
-import jalview.io.FileFormat;
+import jalview.hmmer.HmmerCommand;
+import jalview.io.FileFormatException;
+import jalview.io.FileFormats;
+import jalview.schemes.ResidueColourScheme;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
 
 import java.awt.BorderLayout;
 import java.awt.Color;
-import java.awt.Component;
 import java.awt.GridLayout;
-import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.FocusAdapter;
@@ -41,6 +44,7 @@ import java.awt.event.FocusEvent;
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -66,10 +70,10 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenuItem closeMenuItem = new JMenuItem();
 
-  protected JMenu colourMenu = new JMenu();
-
   protected JMenu webService = new JMenu();
 
+  protected JMenu hmmerMenu = new JMenu();
+
   protected JMenuItem webServiceNoServices;
 
   protected JCheckBoxMenuItem viewBoxesMenuItem = new JCheckBoxMenuItem();
@@ -78,14 +82,10 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenu sortByAnnotScore = new JMenu();
 
-  public JLabel statusBar = new JLabel();
+  protected JLabel statusBar = new JLabel();
 
   protected JMenu outputTextboxMenu = new JMenu();
 
-  protected JRadioButtonMenuItem textColour;
-
-  protected JRadioButtonMenuItem userDefinedColour;
-
   protected JCheckBoxMenuItem annotationPanelMenuItem = new JCheckBoxMenuItem();
 
   protected JCheckBoxMenuItem colourTextMenuItem = new JCheckBoxMenuItem();
@@ -96,16 +96,10 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenuItem redoMenuItem = new JMenuItem();
 
-  protected JCheckBoxMenuItem conservationMenuItem;
-
-  protected JRadioButtonMenuItem noColourmenuItem;
-
   protected JCheckBoxMenuItem wrapMenuItem = new JCheckBoxMenuItem();
 
   protected JCheckBoxMenuItem renderGapsMenuItem = new JCheckBoxMenuItem();
 
-  protected JCheckBoxMenuItem abovePIDThreshold;
-
   public JCheckBoxMenuItem showSeqFeatures = new JCheckBoxMenuItem();
 
   JMenuItem copy = new JMenuItem();
@@ -114,8 +108,6 @@ public class GAlignFrame extends JInternalFrame
 
   JMenu pasteMenu = new JMenu();
 
-  protected JCheckBoxMenuItem applyToAllGroups;
-
   protected JCheckBoxMenuItem seqLimits = new JCheckBoxMenuItem();
 
   protected JCheckBoxMenuItem scaleAbove = new JCheckBoxMenuItem();
@@ -124,17 +116,27 @@ public class GAlignFrame extends JInternalFrame
 
   protected JCheckBoxMenuItem scaleRight = new JCheckBoxMenuItem();
 
-  protected JMenuItem modifyPID;
+  protected JCheckBoxMenuItem applyToAllGroups;
+
+  protected JMenu colourMenu = new JMenu();
+
+  protected JMenuItem textColour;
+
+  protected JCheckBoxMenuItem conservationMenuItem;
 
   protected JMenuItem modifyConservation;
 
-  protected JMenuItem annotationColour;
+  protected JCheckBoxMenuItem abovePIDThreshold;
+
+  protected JMenuItem modifyPID;
+
+  protected JRadioButtonMenuItem annotationColour;
 
   protected JMenu sortByTreeMenu = new JMenu();
 
   protected JMenu sort = new JMenu();
 
-  protected JMenu calculateTree = new JMenu();
+  protected JMenuItem calculateTree = new JMenuItem();
 
   protected JCheckBoxMenuItem padGapsMenuitem = new JCheckBoxMenuItem();
 
@@ -142,7 +144,7 @@ public class GAlignFrame extends JInternalFrame
 
   protected JCheckBoxMenuItem showDbRefsMenuitem = new JCheckBoxMenuItem();
 
-  protected JMenuItem showTranslation = new JMenuItem();
+  protected JMenu showTranslation = new JMenu();
 
   protected JMenuItem showReverse = new JMenuItem();
 
@@ -152,6 +154,8 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenuItem runGroovy = new JMenuItem();
 
+  protected JMenuItem loadVcf;
+
   protected JCheckBoxMenuItem autoCalculate = new JCheckBoxMenuItem();
 
   protected JCheckBoxMenuItem sortByTree = new JCheckBoxMenuItem();
@@ -198,13 +202,19 @@ public class GAlignFrame extends JInternalFrame
 
   protected JCheckBoxMenuItem normaliseSequenceLogo = new JCheckBoxMenuItem();
 
+  protected JCheckBoxMenuItem showInformationHistogram = new JCheckBoxMenuItem();
+
+  protected JCheckBoxMenuItem showHMMSequenceLogo = new JCheckBoxMenuItem();
+
+  protected JCheckBoxMenuItem normaliseHMMSequenceLogo = new JCheckBoxMenuItem();
+
   protected JCheckBoxMenuItem applyAutoAnnotationSettings = new JCheckBoxMenuItem();
 
   private SequenceAnnotationOrder annotationSortOrder;
 
   private boolean showAutoCalculatedAbove = false;
 
-  private Map<KeyStroke, JMenuItem> accelerators = new HashMap<KeyStroke, JMenuItem>();
+  private Map<KeyStroke, JMenuItem> accelerators = new HashMap<>();
 
   private SplitContainerI splitFrame;
 
@@ -216,7 +226,7 @@ public class GAlignFrame extends JInternalFrame
       setJMenuBar(alignFrameMenuBar);
 
       // dynamically fill save as menu with available formats
-      for (String ff : FileFormat.getWritableFormats(true))
+      for (String ff : FileFormats.getInstance().getWritableFormats(true))
       {
         JMenuItem item = new JMenuItem(ff);
 
@@ -249,41 +259,10 @@ public class GAlignFrame extends JInternalFrame
     }
   }
 
-  /**
-   * Marks as selected the colour menu item matching the given name, or the
-   * first item ('None') if no match is found
-   * 
-   * @param colourName
-   */
-  protected void setColourSelected(String colourName)
-  {
-    noColourmenuItem.setSelected(true);
-    if (colourName == null)
-    {
-      return;
-    }
-
-    /*
-     * look for a radio button with a name that matches the colour name
-     * (note the button text may not as it may be internationalised)
-     */
-    for (Component menuItem : colourMenu.getMenuComponents())
-    {
-      if (menuItem instanceof JRadioButtonMenuItem)
-      {
-        if (colourName.equals(((JRadioButtonMenuItem) menuItem).getName()))
-        {
-          ((JRadioButtonMenuItem) menuItem).setSelected(true);
-          return;
-        }
-      }
-    }
-  }
-
   private void jbInit() throws Exception
   {
     initColourMenu();
-
+  
     JMenuItem saveAs = new JMenuItem(
             MessageManager.getString("action.save_as"));
     ActionListener al = new ActionListener()
@@ -294,16 +273,17 @@ public class GAlignFrame extends JInternalFrame
         saveAs_actionPerformed(e);
       }
     };
-
+  
     // FIXME getDefaultToolkit throws an exception in Headless mode
-    KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask()
-            | KeyEvent.SHIFT_MASK, false);
+    KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()
+                    | jalview.util.ShortcutKeyMaskExWrapper.SHIFT_DOWN_MASK,
+            false);
     addMenuActionAndAccelerator(keyStroke, saveAs, al);
-
+  
     closeMenuItem.setText(MessageManager.getString("action.close"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_W,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
@@ -313,7 +293,7 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, closeMenuItem, al);
-
+  
     JMenu editMenu = new JMenu(MessageManager.getString("action.edit"));
     JMenu viewMenu = new JMenu(MessageManager.getString("action.view"));
     JMenu annotationsMenu = new JMenu(
@@ -323,10 +303,13 @@ public class GAlignFrame extends JInternalFrame
     JMenu calculateMenu = new JMenu(
             MessageManager.getString("action.calculate"));
     webService.setText(MessageManager.getString("action.web_service"));
+
+    initHMMERMenu();
+
     JMenuItem selectAllSequenceMenuItem = new JMenuItem(
             MessageManager.getString("action.select_all"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_A,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
@@ -336,7 +319,7 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, selectAllSequenceMenuItem, al);
-
+  
     JMenuItem deselectAllSequenceMenuItem = new JMenuItem(
             MessageManager.getString("action.deselect_all"));
     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
@@ -349,11 +332,11 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, deselectAllSequenceMenuItem, al);
-
+  
     JMenuItem invertSequenceMenuItem = new JMenuItem(
             MessageManager.getString("action.invert_sequence_selection"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_I, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_I,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
@@ -363,7 +346,7 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, invertSequenceMenuItem, al);
-
+  
     JMenuItem grpsFromSelection = new JMenuItem(
             MessageManager.getString("action.make_groups_selection"));
     grpsFromSelection.addActionListener(new ActionListener()
@@ -376,8 +359,8 @@ public class GAlignFrame extends JInternalFrame
     });
     JMenuItem expandAlignment = new JMenuItem(
             MessageManager.getString("action.view_flanking_regions"));
-    expandAlignment.setToolTipText(MessageManager
-            .getString("label.view_flanking_regions"));
+    expandAlignment.setToolTipText(
+            MessageManager.getString("label.view_flanking_regions"));
     expandAlignment.addActionListener(new ActionListener()
     {
       @Override
@@ -388,8 +371,8 @@ public class GAlignFrame extends JInternalFrame
     });
     JMenuItem remove2LeftMenuItem = new JMenuItem(
             MessageManager.getString("action.remove_left"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_L, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_L,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
@@ -399,11 +382,11 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, remove2LeftMenuItem, al);
-
+  
     JMenuItem remove2RightMenuItem = new JMenuItem(
             MessageManager.getString("action.remove_right"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_R,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
@@ -413,11 +396,11 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, remove2RightMenuItem, al);
-
+  
     JMenuItem removeGappedColumnMenuItem = new JMenuItem(
             MessageManager.getString("action.remove_empty_columns"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_E, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_E,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
@@ -427,12 +410,13 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, removeGappedColumnMenuItem, al);
-
+  
     JMenuItem removeAllGapsMenuItem = new JMenuItem(
             MessageManager.getString("action.remove_all_gaps"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_E, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask()
-            | KeyEvent.SHIFT_MASK, false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_E,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()
+                    | jalview.util.ShortcutKeyMaskExWrapper.SHIFT_DOWN_MASK,
+            false);
     al = new ActionListener()
     {
       @Override
@@ -442,7 +426,7 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, removeAllGapsMenuItem, al);
-
+  
     JMenuItem justifyLeftMenuItem = new JMenuItem(
             MessageManager.getString("action.left_justify_alignment"));
     justifyLeftMenuItem.addActionListener(new ActionListener()
@@ -483,8 +467,8 @@ public class GAlignFrame extends JInternalFrame
         viewTextMenuItem_actionPerformed(e);
       }
     });
-    showNonconservedMenuItem.setText(MessageManager
-            .getString("label.show_non_conserved"));
+    showNonconservedMenuItem
+            .setText(MessageManager.getString("label.show_non_conserved"));
     showNonconservedMenuItem.setState(false);
     showNonconservedMenuItem.addActionListener(new ActionListener()
     {
@@ -534,11 +518,11 @@ public class GAlignFrame extends JInternalFrame
         sortGroupMenuItem_actionPerformed(e);
       }
     });
-
+  
     JMenuItem removeRedundancyMenuItem = new JMenuItem(
             MessageManager.getString("action.remove_redundancy"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_D,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
@@ -548,7 +532,7 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, removeRedundancyMenuItem, al);
-
+  
     JMenuItem pairwiseAlignmentMenuItem = new JMenuItem(
             MessageManager.getString("action.pairwise_alignment"));
     pairwiseAlignmentMenuItem.addActionListener(new ActionListener()
@@ -559,72 +543,23 @@ public class GAlignFrame extends JInternalFrame
         pairwiseAlignmentMenuItem_actionPerformed(e);
       }
     });
-    JMenuItem PCAMenuItem = new JMenuItem(
-            MessageManager.getString("label.principal_component_analysis"));
-    PCAMenuItem.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        PCAMenuItem_actionPerformed(e);
-      }
-    });
-    JMenuItem averageDistanceTreeMenuItem = new JMenuItem(
-            MessageManager.getString("label.average_distance_identity"));
-    averageDistanceTreeMenuItem.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        averageDistanceTreeMenuItem_actionPerformed(e);
-      }
-    });
-    JMenuItem neighbourTreeMenuItem = new JMenuItem(
-            MessageManager.getString("label.neighbour_joining_identity"));
-    neighbourTreeMenuItem.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        neighbourTreeMenuItem_actionPerformed(e);
-      }
-    });
-
+  
     this.getContentPane().setLayout(new BorderLayout());
     alignFrameMenuBar.setFont(new java.awt.Font("Verdana", 0, 11));
     statusBar.setBackground(Color.white);
     statusBar.setFont(new java.awt.Font("Verdana", 0, 11));
     statusBar.setBorder(BorderFactory.createLineBorder(Color.black));
     statusBar.setText(MessageManager.getString("label.status_bar"));
-    outputTextboxMenu.setText(MessageManager
-            .getString("label.out_to_textbox"));
+
+    outputTextboxMenu
+            .setText(MessageManager.getString("label.out_to_textbox"));
 
 
-    JMenuItem avDistanceTreeBlosumMenuItem = new JMenuItem(
-            MessageManager.getString("label.average_distance_blosum62"));
-    avDistanceTreeBlosumMenuItem.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        avTreeBlosumMenuItem_actionPerformed(e);
-      }
-    });
-    JMenuItem njTreeBlosumMenuItem = new JMenuItem(
-            MessageManager.getString("label.neighbour_blosum62"));
-    njTreeBlosumMenuItem.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        njTreeBlosumMenuItem_actionPerformed(e);
-      }
-    });
     annotationPanelMenuItem.setActionCommand("");
-    annotationPanelMenuItem.setText(MessageManager
-            .getString("label.show_annotations"));
-    annotationPanelMenuItem.setState(Cache.getDefault("SHOW_ANNOTATIONS",
-            true));
+    annotationPanelMenuItem
+            .setText(MessageManager.getString("label.show_annotations"));
+    annotationPanelMenuItem
+            .setState(Cache.getDefault("SHOW_ANNOTATIONS", true));
     annotationPanelMenuItem.addActionListener(new ActionListener()
     {
       @Override
@@ -633,8 +568,8 @@ public class GAlignFrame extends JInternalFrame
         annotationPanelMenuItem_actionPerformed(e);
       }
     });
-    showAllAlAnnotations.setText(MessageManager
-            .getString("label.show_all_al_annotations"));
+    showAllAlAnnotations.setText(
+            MessageManager.getString("label.show_all_al_annotations"));
     final boolean isAnnotationPanelShown = annotationPanelMenuItem
             .getState();
     showAllAlAnnotations.setEnabled(isAnnotationPanelShown);
@@ -646,8 +581,8 @@ public class GAlignFrame extends JInternalFrame
         showAllAnnotations_actionPerformed(false, true);
       }
     });
-    hideAllAlAnnotations.setText(MessageManager
-            .getString("label.hide_all_al_annotations"));
+    hideAllAlAnnotations.setText(
+            MessageManager.getString("label.hide_all_al_annotations"));
     hideAllAlAnnotations.setEnabled(isAnnotationPanelShown);
     hideAllAlAnnotations.addActionListener(new ActionListener()
     {
@@ -657,8 +592,8 @@ public class GAlignFrame extends JInternalFrame
         hideAllAnnotations_actionPerformed(false, true);
       }
     });
-    showAllSeqAnnotations.setText(MessageManager
-            .getString("label.show_all_seq_annotations"));
+    showAllSeqAnnotations.setText(
+            MessageManager.getString("label.show_all_seq_annotations"));
     showAllSeqAnnotations.setEnabled(isAnnotationPanelShown);
     showAllSeqAnnotations.addActionListener(new ActionListener()
     {
@@ -668,8 +603,8 @@ public class GAlignFrame extends JInternalFrame
         showAllAnnotations_actionPerformed(true, false);
       }
     });
-    hideAllSeqAnnotations.setText(MessageManager
-            .getString("label.hide_all_seq_annotations"));
+    hideAllSeqAnnotations.setText(
+            MessageManager.getString("label.hide_all_seq_annotations"));
     hideAllSeqAnnotations.setEnabled(isAnnotationPanelShown);
     hideAllSeqAnnotations.addActionListener(new ActionListener()
     {
@@ -687,8 +622,9 @@ public class GAlignFrame extends JInternalFrame
     final JCheckBoxMenuItem sortAnnByLabel = new JCheckBoxMenuItem(
             MessageManager.getString("label.sort_annotations_by_label"));
 
-    sortAnnBySequence
-            .setSelected(sortAnnotationsBy == SequenceAnnotationOrder.SEQUENCE_AND_LABEL);
+
+    sortAnnBySequence.setSelected(
+            sortAnnotationsBy == SequenceAnnotationOrder.SEQUENCE_AND_LABEL);
     sortAnnBySequence.addActionListener(new ActionListener()
     {
       @Override
@@ -696,13 +632,14 @@ public class GAlignFrame extends JInternalFrame
       {
         boolean newState = sortAnnBySequence.getState();
         sortAnnByLabel.setSelected(false);
-        setAnnotationSortOrder(newState ? SequenceAnnotationOrder.SEQUENCE_AND_LABEL
-                : SequenceAnnotationOrder.NONE);
+        setAnnotationSortOrder(
+                newState ? SequenceAnnotationOrder.SEQUENCE_AND_LABEL
+                        : SequenceAnnotationOrder.NONE);
         sortAnnotations_actionPerformed();
       }
     });
-    sortAnnByLabel
-            .setSelected(sortAnnotationsBy == SequenceAnnotationOrder.LABEL_AND_SEQUENCE);
+    sortAnnByLabel.setSelected(
+            sortAnnotationsBy == SequenceAnnotationOrder.LABEL_AND_SEQUENCE);
     sortAnnByLabel.addActionListener(new ActionListener()
     {
       @Override
@@ -710,14 +647,14 @@ public class GAlignFrame extends JInternalFrame
       {
         boolean newState = sortAnnByLabel.getState();
         sortAnnBySequence.setSelected(false);
-        setAnnotationSortOrder(newState ? SequenceAnnotationOrder.LABEL_AND_SEQUENCE
-                : SequenceAnnotationOrder.NONE);
+        setAnnotationSortOrder(
+                newState ? SequenceAnnotationOrder.LABEL_AND_SEQUENCE
+                        : SequenceAnnotationOrder.NONE);
         sortAnnotations_actionPerformed();
       }
     });
     colourTextMenuItem = new JCheckBoxMenuItem(
-            MessageManager
-            .getString("label.colour_text"));
+            MessageManager.getString("label.colour_text"));
     colourTextMenuItem.addActionListener(new ActionListener()
     {
       @Override
@@ -726,7 +663,7 @@ public class GAlignFrame extends JInternalFrame
         colourTextMenuItem_actionPerformed(e);
       }
     });
-
+  
     JMenuItem htmlMenuItem = new JMenuItem(
             MessageManager.getString("label.html"));
     htmlMenuItem.addActionListener(new ActionListener()
@@ -737,7 +674,7 @@ public class GAlignFrame extends JInternalFrame
         htmlMenuItem_actionPerformed(e);
       }
     });
-
+  
     JMenuItem createBioJS = new JMenuItem(
             MessageManager.getString("label.biojs_html_export"));
     createBioJS.addActionListener(new java.awt.event.ActionListener()
@@ -748,7 +685,7 @@ public class GAlignFrame extends JInternalFrame
         bioJSMenuItem_actionPerformed(e);
       }
     });
-
+  
     JMenuItem overviewMenuItem = new JMenuItem(
             MessageManager.getString("label.overview_window"));
     overviewMenuItem.addActionListener(new ActionListener()
@@ -759,11 +696,11 @@ public class GAlignFrame extends JInternalFrame
         overviewMenuItem_actionPerformed(e);
       }
     });
-
+  
     undoMenuItem.setEnabled(false);
     undoMenuItem.setText(MessageManager.getString("action.undo"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_Z,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
@@ -773,11 +710,11 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, undoMenuItem, al);
-
+  
     redoMenuItem.setEnabled(false);
     redoMenuItem.setText(MessageManager.getString("action.redo"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_Y, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_Y,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
@@ -787,7 +724,7 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, redoMenuItem, al);
-
+  
     wrapMenuItem.setText(MessageManager.getString("label.wrap"));
     wrapMenuItem.addActionListener(new ActionListener()
     {
@@ -797,11 +734,11 @@ public class GAlignFrame extends JInternalFrame
         wrapMenuItem_actionPerformed(e);
       }
     });
-
+  
     JMenuItem printMenuItem = new JMenuItem(
             MessageManager.getString("action.print"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_P,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
@@ -811,7 +748,7 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, printMenuItem, al);
-
+  
     renderGapsMenuItem
             .setText(MessageManager.getString("action.show_gaps"));
     renderGapsMenuItem.setState(true);
@@ -823,11 +760,11 @@ public class GAlignFrame extends JInternalFrame
         renderGapsMenuItem_actionPerformed(e);
       }
     });
-
+  
     JMenuItem findMenuItem = new JMenuItem(
             MessageManager.getString("action.find"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     findMenuItem.setToolTipText(JvSwingUtils.wrapTooltip(true,
             MessageManager.getString("label.find_tip")));
     al = new ActionListener()
@@ -840,8 +777,9 @@ public class GAlignFrame extends JInternalFrame
     };
     addMenuActionAndAccelerator(keyStroke, findMenuItem, al);
 
-    showSeqFeatures.setText(MessageManager
-            .getString("label.show_sequence_features"));
+    showSeqFeatures.setText(
+            MessageManager.getString("label.show_sequence_features"));
+
     showSeqFeatures.addActionListener(new ActionListener()
     {
       @Override
@@ -856,93 +794,93 @@ public class GAlignFrame extends JInternalFrame
      * void actionPerformed(ActionEvent actionEvent) {
      * showSeqFeaturesHeight_actionPerformed(actionEvent); } });
      */
-    showDbRefsMenuitem.setText(MessageManager
-            .getString("label.show_database_refs"));
+    showDbRefsMenuitem
+            .setText(MessageManager.getString("label.show_database_refs"));
     showDbRefsMenuitem.addActionListener(new ActionListener()
     {
-
+  
       @Override
       public void actionPerformed(ActionEvent e)
       {
         showDbRefs_actionPerformed(e);
       }
-
+  
     });
-    showNpFeatsMenuitem.setText(MessageManager
-            .getString("label.show_non_positional_features"));
+    showNpFeatsMenuitem.setText(
+            MessageManager.getString("label.show_non_positional_features"));
     showNpFeatsMenuitem.addActionListener(new ActionListener()
     {
-
+  
       @Override
       public void actionPerformed(ActionEvent e)
       {
         showNpFeats_actionPerformed(e);
       }
-
+  
     });
-    showGroupConservation.setText(MessageManager
-            .getString("label.group_conservation"));
+    showGroupConservation
+            .setText(MessageManager.getString("label.group_conservation"));
     showGroupConservation.addActionListener(new ActionListener()
     {
-
+  
       @Override
       public void actionPerformed(ActionEvent e)
       {
         showGroupConservation_actionPerformed(e);
       }
-
+  
     });
 
-    showGroupConsensus.setText(MessageManager
-            .getString("label.group_consensus"));
+    showGroupConsensus
+            .setText(MessageManager.getString("label.group_consensus"));
     showGroupConsensus.addActionListener(new ActionListener()
     {
-
+  
       @Override
       public void actionPerformed(ActionEvent e)
       {
         showGroupConsensus_actionPerformed(e);
       }
-
+  
     });
-    showConsensusHistogram.setText(MessageManager
-            .getString("label.show_consensus_histogram"));
+    showConsensusHistogram.setText(
+            MessageManager.getString("label.show_consensus_histogram"));
     showConsensusHistogram.addActionListener(new ActionListener()
     {
-
+  
       @Override
       public void actionPerformed(ActionEvent e)
       {
         showConsensusHistogram_actionPerformed(e);
       }
-
+  
     });
-    showSequenceLogo.setText(MessageManager
-            .getString("label.show_consensus_logo"));
+    showSequenceLogo
+            .setText(MessageManager.getString("label.show_consensus_logo"));
     showSequenceLogo.addActionListener(new ActionListener()
     {
-
+  
       @Override
       public void actionPerformed(ActionEvent e)
       {
         showSequenceLogo_actionPerformed(e);
       }
-
+  
     });
-    normaliseSequenceLogo.setText(MessageManager
-            .getString("label.norm_consensus_logo"));
+    normaliseSequenceLogo
+            .setText(MessageManager.getString("label.norm_consensus_logo"));
     normaliseSequenceLogo.addActionListener(new ActionListener()
     {
-
+  
       @Override
       public void actionPerformed(ActionEvent e)
       {
         normaliseSequenceLogo_actionPerformed(e);
       }
-
+  
     });
-    applyAutoAnnotationSettings.setText(MessageManager
-            .getString("label.apply_all_groups"));
+    applyAutoAnnotationSettings
+            .setText(MessageManager.getString("label.apply_all_groups"));
     applyAutoAnnotationSettings.setState(false);
     applyAutoAnnotationSettings.setVisible(true);
     applyAutoAnnotationSettings.addActionListener(new ActionListener()
@@ -953,7 +891,7 @@ public class GAlignFrame extends JInternalFrame
         applyAutoAnnotationSettings_actionPerformed(e);
       }
     });
-
+  
     ButtonGroup buttonGroup = new ButtonGroup();
     final JRadioButtonMenuItem showAutoFirst = new JRadioButtonMenuItem(
             MessageManager.getString("label.show_first"));
@@ -961,8 +899,8 @@ public class GAlignFrame extends JInternalFrame
             MessageManager.getString("label.show_last"));
     buttonGroup.add(showAutoFirst);
     buttonGroup.add(showAutoLast);
-    final boolean autoFirst = Cache.getDefault(
-            Preferences.SHOW_AUTOCALC_ABOVE, false);
+    final boolean autoFirst = Cache
+            .getDefault(Preferences.SHOW_AUTOCALC_ABOVE, false);
     showAutoFirst.setSelected(autoFirst);
     setShowAutoCalculatedAbove(autoFirst);
     showAutoFirst.addActionListener(new ActionListener()
@@ -984,11 +922,11 @@ public class GAlignFrame extends JInternalFrame
         sortAnnotations_actionPerformed();
       }
     });
-
+  
     JMenuItem deleteGroups = new JMenuItem(
             MessageManager.getString("action.undefine_groups"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_U, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_U,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
@@ -998,7 +936,7 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, deleteGroups, al);
-
+  
     JMenuItem annotationColumn = new JMenuItem(
             MessageManager.getString("action.select_by_annotation"));
     annotationColumn.addActionListener(new ActionListener()
@@ -1009,11 +947,11 @@ public class GAlignFrame extends JInternalFrame
         annotationColumn_actionPerformed(e);
       }
     });
-
+  
     JMenuItem createGroup = new JMenuItem(
-            MessageManager.getString("action.create_groups"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+            MessageManager.getString("action.create_group"));
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
@@ -1023,12 +961,13 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, createGroup, al);
-
+  
     JMenuItem unGroup = new JMenuItem(
             MessageManager.getString("action.remove_group"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask()
-            | KeyEvent.SHIFT_MASK, false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()
+                    | jalview.util.ShortcutKeyMaskExWrapper.SHIFT_DOWN_MASK,
+            false);
     al = new ActionListener()
     {
       @Override
@@ -1038,10 +977,10 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, unGroup, al);
-
+  
     copy.setText(MessageManager.getString("action.copy"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_C,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
 
     al = new ActionListener()
     {
@@ -1052,10 +991,10 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, copy, al);
-
+  
     cut.setText(MessageManager.getString("action.cut"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_X,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
@@ -1065,7 +1004,7 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, cut, al);
-
+  
     JMenuItem delete = new JMenuItem(
             MessageManager.getString("action.delete"));
     delete.addActionListener(new ActionListener()
@@ -1076,37 +1015,52 @@ public class GAlignFrame extends JInternalFrame
         delete_actionPerformed(e);
       }
     });
-
+  
     pasteMenu.setText(MessageManager.getString("action.paste"));
     JMenuItem pasteNew = new JMenuItem(
             MessageManager.getString("label.to_new_alignment"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask()
-            | KeyEvent.SHIFT_MASK, false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()
+                    | jalview.util.ShortcutKeyMaskExWrapper.SHIFT_DOWN_MASK,
+            false);
     al = new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        pasteNew_actionPerformed(e);
+        try
+        {
+          pasteNew_actionPerformed(e);
+        } catch (IOException | InterruptedException e1)
+        {
+          // TODO Auto-generated catch block
+          e1.printStackTrace();
+        }
       }
     };
     addMenuActionAndAccelerator(keyStroke, pasteNew, al);
-
+  
     JMenuItem pasteThis = new JMenuItem(
             MessageManager.getString("label.to_this_alignment"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        pasteThis_actionPerformed(e);
+        try
+        {
+          pasteThis_actionPerformed(e);
+        } catch (IOException | InterruptedException e1)
+        {
+          // TODO Auto-generated catch block
+          e1.printStackTrace();
+        }
       }
     };
     addMenuActionAndAccelerator(keyStroke, pasteThis, al);
-
+  
     JMenuItem createPNG = new JMenuItem("PNG");
     createPNG.addActionListener(new ActionListener()
     {
@@ -1116,9 +1070,8 @@ public class GAlignFrame extends JInternalFrame
         createPNG(null);
       }
     });
-    createPNG.setActionCommand(MessageManager
-            .getString("label.save_png_image"));
-
+    createPNG.setActionCommand(
+            MessageManager.getString("label.save_png_image"));
     JMenuItem font = new JMenuItem(MessageManager.getString("action.font"));
     font.addActionListener(new ActionListener()
     {
@@ -1128,8 +1081,8 @@ public class GAlignFrame extends JInternalFrame
         font_actionPerformed(e);
       }
     });
-    seqLimits.setText(MessageManager
-            .getString("label.show_sequence_limits"));
+    seqLimits.setText(
+            MessageManager.getString("label.show_sequence_limits"));
     seqLimits.setState(jalview.bin.Cache.getDefault("SHOW_JVSUFFIX", true));
     seqLimits.addActionListener(new ActionListener()
     {
@@ -1148,7 +1101,7 @@ public class GAlignFrame extends JInternalFrame
         createEPS(null);
       }
     });
-
+  
     JMenuItem createSVG = new JMenuItem("SVG");
     createSVG.addActionListener(new ActionListener()
     {
@@ -1158,11 +1111,11 @@ public class GAlignFrame extends JInternalFrame
         createSVG(null);
       }
     });
-
+  
     JMenuItem loadTreeMenuItem = new JMenuItem(
             MessageManager.getString("label.load_associated_tree"));
-    loadTreeMenuItem.setActionCommand(MessageManager
-            .getString("label.load_tree_for_sequence_set"));
+    loadTreeMenuItem.setActionCommand(
+            MessageManager.getString("label.load_tree_for_sequence_set"));
     loadTreeMenuItem.addActionListener(new ActionListener()
     {
       @Override
@@ -1171,7 +1124,7 @@ public class GAlignFrame extends JInternalFrame
         loadTreeMenuItem_actionPerformed(e);
       }
     });
-
+  
     scaleAbove.setVisible(false);
     scaleAbove.setText(MessageManager.getString("action.scale_above"));
     scaleAbove.addActionListener(new ActionListener()
@@ -1206,8 +1159,8 @@ public class GAlignFrame extends JInternalFrame
     });
     centreColumnLabelsMenuItem.setVisible(true);
     centreColumnLabelsMenuItem.setState(false);
-    centreColumnLabelsMenuItem.setText(MessageManager
-            .getString("label.centre_column_labels"));
+    centreColumnLabelsMenuItem.setText(
+            MessageManager.getString("label.centre_column_labels"));
     centreColumnLabelsMenuItem.addActionListener(new ActionListener()
     {
       @Override
@@ -1218,19 +1171,19 @@ public class GAlignFrame extends JInternalFrame
     });
     followHighlightMenuItem.setVisible(true);
     followHighlightMenuItem.setState(true);
-    followHighlightMenuItem.setText(MessageManager
-            .getString("label.automatic_scrolling"));
+    followHighlightMenuItem
+            .setText(MessageManager.getString("label.automatic_scrolling"));
     followHighlightMenuItem.addActionListener(new ActionListener()
     {
-
+  
       @Override
       public void actionPerformed(ActionEvent e)
       {
         followHighlight_actionPerformed();
       }
-
+  
     });
-
+  
     sortByTreeMenu
             .setText(MessageManager.getString("action.by_tree_order"));
     sort.setText(MessageManager.getString("action.sort"));
@@ -1239,35 +1192,35 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void menuSelected(MenuEvent e)
       {
-        buildTreeMenu();
+        buildTreeSortMenu();
       }
-
+  
       @Override
       public void menuDeselected(MenuEvent e)
       {
       }
-
+  
       @Override
       public void menuCanceled(MenuEvent e)
       {
       }
     });
-    sortByAnnotScore.setText(MessageManager
-            .getString("label.sort_by_score"));
+    sortByAnnotScore
+            .setText(MessageManager.getString("label.sort_by_score"));
     sort.add(sortByAnnotScore);
     sort.addMenuListener(new javax.swing.event.MenuListener()
     {
-
+  
       @Override
       public void menuCanceled(MenuEvent e)
       {
       }
-
+  
       @Override
       public void menuDeselected(MenuEvent e)
       {
       }
-
+  
       @Override
       public void menuSelected(MenuEvent e)
       {
@@ -1277,11 +1230,11 @@ public class GAlignFrame extends JInternalFrame
     sortByAnnotScore.setVisible(false);
 
     calculateTree
-            .setText(MessageManager.getString("action.calculate_tree"));
+            .setText(MessageManager.getString("action.calculate_tree_pca"));
 
     padGapsMenuitem.setText(MessageManager.getString("label.pad_gaps"));
-    padGapsMenuitem.setState(jalview.bin.Cache
-            .getDefault("PAD_GAPS", false));
+    padGapsMenuitem
+            .setState(jalview.bin.Cache.getDefault("PAD_GAPS", false));
     padGapsMenuitem.addActionListener(new ActionListener()
     {
       @Override
@@ -1301,16 +1254,33 @@ public class GAlignFrame extends JInternalFrame
         vamsasStore_actionPerformed(e);
       }
     });
+
+    /*
+     * Translate as cDNA with sub-menu of translation tables
+     */
     showTranslation.setText(MessageManager
             .getString("label.translate_cDNA"));
-    showTranslation.addActionListener(new ActionListener()
+    boolean first = true;
+    for (final GeneticCodeI table : GeneticCodes.getInstance()
+            .getCodeTables())
     {
-      @Override
-      public void actionPerformed(ActionEvent e)
+      JMenuItem item = new JMenuItem(table.getId() + " " + table.getName());
+      showTranslation.add(item);
+      item.addActionListener(new ActionListener()
+      {
+        @Override
+        public void actionPerformed(ActionEvent e)
+        {
+          showTranslation_actionPerformed(table);
+        }
+      });
+      if (first)
       {
-        showTranslation_actionPerformed(e);
+        showTranslation.addSeparator();
       }
-    });
+      first = false;
+    }
+
     showReverse.setText(MessageManager.getString("label.reverse"));
     showReverse.addActionListener(new ActionListener()
     {
@@ -1320,8 +1290,8 @@ public class GAlignFrame extends JInternalFrame
         showReverse_actionPerformed(false);
       }
     });
-    showReverseComplement.setText(MessageManager
-            .getString("label.reverse_complement"));
+    showReverseComplement
+            .setText(MessageManager.getString("label.reverse_complement"));
     showReverseComplement.addActionListener(new ActionListener()
     {
       @Override
@@ -1330,7 +1300,7 @@ public class GAlignFrame extends JInternalFrame
         showReverse_actionPerformed(true);
       }
     });
-
+  
     JMenuItem extractScores = new JMenuItem(
             MessageManager.getString("label.extract_scores"));
     extractScores.addActionListener(new ActionListener()
@@ -1343,13 +1313,13 @@ public class GAlignFrame extends JInternalFrame
     });
     extractScores.setVisible(true);
     // JBPNote: TODO: make gui for regex based score extraction
-
+  
     // for show products actions see AlignFrame.canShowProducts
     showProducts.setText(MessageManager.getString("label.get_cross_refs"));
-
+  
     runGroovy.setText(MessageManager.getString("label.run_groovy"));
-    runGroovy.setToolTipText(MessageManager
-            .getString("label.run_groovy_tip"));
+    runGroovy.setToolTipText(
+            MessageManager.getString("label.run_groovy_tip"));
     runGroovy.addActionListener(new ActionListener()
     {
       @Override
@@ -1358,7 +1328,7 @@ public class GAlignFrame extends JInternalFrame
         runGroovy_actionPerformed();
       }
     });
-
+  
     JMenuItem openFeatureSettings = new JMenuItem(
             MessageManager.getString("action.feature_settings"));
     openFeatureSettings.addActionListener(new ActionListener()
@@ -1379,7 +1349,7 @@ public class GAlignFrame extends JInternalFrame
         fetchSequence_actionPerformed(e);
       }
     });
-
+  
     JMenuItem associatedData = new JMenuItem(
             MessageManager.getString("label.load_features_annotations"));
     associatedData.addActionListener(new ActionListener()
@@ -1387,13 +1357,30 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        associatedData_actionPerformed(e);
+        try
+        {
+          associatedData_actionPerformed(e);
+        } catch (IOException | InterruptedException e1)
+        {
+          // TODO Auto-generated catch block
+          e1.printStackTrace();
+        }
+      }
+    });
+    loadVcf = new JMenuItem(MessageManager.getString("label.load_vcf_file"));
+    loadVcf.setToolTipText(MessageManager.getString("label.load_vcf"));
+    loadVcf.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        loadVcf_actionPerformed();
       }
     });
-    autoCalculate.setText(MessageManager
-            .getString("label.autocalculate_consensus"));
-    autoCalculate.setState(jalview.bin.Cache.getDefault(
-            "AUTO_CALC_CONSENSUS", true));
+    autoCalculate.setText(
+            MessageManager.getString("label.autocalculate_consensus"));
+    autoCalculate.setState(
+            jalview.bin.Cache.getDefault("AUTO_CALC_CONSENSUS", true));
     autoCalculate.addActionListener(new ActionListener()
     {
       @Override
@@ -1402,12 +1389,10 @@ public class GAlignFrame extends JInternalFrame
         autoCalculate_actionPerformed(e);
       }
     });
-    sortByTree.setText(MessageManager
-            .getString("label.sort_alignment_new_tree"));
-    sortByTree
-            .setToolTipText("<html>"
-                    + MessageManager
-                            .getString("label.enable_automatically_sort_alignment_when_open_new_tree"));
+    sortByTree.setText(
+            MessageManager.getString("label.sort_alignment_new_tree"));
+    sortByTree.setToolTipText("<html>" + MessageManager.getString(
+            "label.enable_automatically_sort_alignment_when_open_new_tree"));
     sortByTree
             .setState(jalview.bin.Cache.getDefault("SORT_BY_TREE", false));
     sortByTree.addActionListener(new ActionListener()
@@ -1419,12 +1404,11 @@ public class GAlignFrame extends JInternalFrame
       }
     });
 
-    listenToViewSelections.setText(MessageManager
-            .getString("label.listen_for_selections"));
+    listenToViewSelections.setText(
+            MessageManager.getString("label.listen_for_selections"));
     listenToViewSelections
-            .setToolTipText("<html>"
-                    + MessageManager
-                            .getString("label.selections_mirror_selections_made_same_sequences_other_views"));
+            .setToolTipText("<html>" + MessageManager.getString(
+                    "label.selections_mirror_selections_made_same_sequences_other_views"));
     listenToViewSelections.setState(false);
     listenToViewSelections.addActionListener(new ActionListener()
     {
@@ -1434,7 +1418,7 @@ public class GAlignFrame extends JInternalFrame
         listenToViewSelections_actionPerformed(e);
       }
     });
-
+  
     JMenu addSequenceMenu = new JMenu(
             MessageManager.getString("label.add_sequences"));
     JMenuItem addFromFile = new JMenuItem(
@@ -1490,8 +1474,8 @@ public class GAlignFrame extends JInternalFrame
     statusPanel.setLayout(new GridLayout());
     JMenuItem showAllSeqs = new JMenuItem(
             MessageManager.getString("label.all_sequences"));
-    showAllSeqs.setToolTipText(MessageManager
-            .getString("label.toggle_sequence_visibility"));
+    showAllSeqs.setToolTipText(
+            MessageManager.getString("label.toggle_sequence_visibility"));
     showAllSeqs.addActionListener(new ActionListener()
     {
       @Override
@@ -1502,8 +1486,8 @@ public class GAlignFrame extends JInternalFrame
     });
     JMenuItem showAllColumns = new JMenuItem(
             MessageManager.getString("label.all_columns"));
-    showAllColumns.setToolTipText(MessageManager
-            .getString("label.toggle_columns_visibility"));
+    showAllColumns.setToolTipText(
+            MessageManager.getString("label.toggle_columns_visibility"));
     showAllColumns.addActionListener(new ActionListener()
     {
       @Override
@@ -1515,8 +1499,8 @@ public class GAlignFrame extends JInternalFrame
     JMenu hideMenu = new JMenu(MessageManager.getString("action.hide"));
     JMenuItem hideSelSequences = new JMenuItem(
             MessageManager.getString("label.selected_sequences"));
-    hideSelSequences.setToolTipText(MessageManager
-            .getString("label.toggle_sequence_visibility"));
+    hideSelSequences.setToolTipText(
+            MessageManager.getString("label.toggle_sequence_visibility"));
     hideSelSequences.addActionListener(new ActionListener()
     {
       @Override
@@ -1527,8 +1511,8 @@ public class GAlignFrame extends JInternalFrame
     });
     JMenuItem hideSelColumns = new JMenuItem(
             MessageManager.getString("label.selected_columns"));
-    hideSelColumns.setToolTipText(MessageManager
-            .getString("label.toggle_columns_visibility"));
+    hideSelColumns.setToolTipText(
+            MessageManager.getString("label.toggle_columns_visibility"));
     hideSelColumns.addActionListener(new ActionListener()
     {
       @Override
@@ -1570,8 +1554,8 @@ public class GAlignFrame extends JInternalFrame
         showAllhidden_actionPerformed(e);
       }
     });
-    hiddenMarkers.setText(MessageManager
-            .getString("action.show_hidden_markers"));
+    hiddenMarkers.setText(
+            MessageManager.getString("action.show_hidden_markers"));
     hiddenMarkers.addActionListener(new ActionListener()
     {
       @Override
@@ -1580,12 +1564,13 @@ public class GAlignFrame extends JInternalFrame
         hiddenMarkers_actionPerformed(e);
       }
     });
-
+  
     JMenuItem invertColSel = new JMenuItem(
             MessageManager.getString("action.invert_column_selection"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_I, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask()
-            | KeyEvent.ALT_MASK, false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_I,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()
+                    | jalview.util.ShortcutKeyMaskExWrapper.ALT_DOWN_MASK,
+            false);
     al = new ActionListener()
     {
       @Override
@@ -1595,7 +1580,7 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, invertColSel, al);
-
+  
     showComplementMenuItem.setVisible(false);
     showComplementMenuItem.addActionListener(new ActionListener()
     {
@@ -1605,7 +1590,7 @@ public class GAlignFrame extends JInternalFrame
         showComplement_actionPerformed(showComplementMenuItem.getState());
       }
     });
-
+  
     tabbedPane.addChangeListener(new javax.swing.event.ChangeListener()
     {
       @Override
@@ -1626,7 +1611,7 @@ public class GAlignFrame extends JInternalFrame
           tabbedPane_mousePressed(e);
         }
       }
-
+  
       @Override
       public void mouseReleased(MouseEvent e)
       {
@@ -1644,10 +1629,10 @@ public class GAlignFrame extends JInternalFrame
         tabbedPane_focusGained(e);
       }
     });
-
+  
     JMenuItem save = new JMenuItem(MessageManager.getString("action.save"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
@@ -1657,7 +1642,7 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, save, al);
-
+  
     reload.setEnabled(false);
     reload.setText(MessageManager.getString("action.reload"));
     reload.addActionListener(new ActionListener()
@@ -1668,11 +1653,11 @@ public class GAlignFrame extends JInternalFrame
         reload_actionPerformed(e);
       }
     });
-
+  
     JMenuItem newView = new JMenuItem(
             MessageManager.getString("action.new_view"));
-    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_T, Toolkit
-            .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_T,
+            jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx(), false);
     al = new ActionListener()
     {
       @Override
@@ -1682,15 +1667,16 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, newView, al);
-
+  
     tabbedPane.setToolTipText("<html><i>"
             + MessageManager.getString("label.rename_tab_eXpand_reGroup")
             + "</i></html>");
-
+  
     formatMenu.setText(MessageManager.getString("action.format"));
     JMenu selectMenu = new JMenu(MessageManager.getString("action.select"));
-    idRightAlign.setText(MessageManager
-            .getString("label.right_align_sequence_id"));
+
+    idRightAlign.setText(
+            MessageManager.getString("label.right_align_sequence_id"));
     idRightAlign.addActionListener(new ActionListener()
     {
       @Override
@@ -1699,7 +1685,7 @@ public class GAlignFrame extends JInternalFrame
         idRightAlign_actionPerformed(e);
       }
     });
-
+  
     gatherViews.setEnabled(false);
     gatherViews.setText(MessageManager.getString("action.gather_views"));
     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G, 0, false);
@@ -1712,7 +1698,7 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, gatherViews, al);
-
+  
     expandViews.setEnabled(false);
     expandViews.setText(MessageManager.getString("action.expand_views"));
     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_X, 0, false);
@@ -1725,7 +1711,7 @@ public class GAlignFrame extends JInternalFrame
       }
     };
     addMenuActionAndAccelerator(keyStroke, expandViews, al);
-
+  
     JMenuItem pageSetup = new JMenuItem(
             MessageManager.getString("action.page_setup"));
     pageSetup.addActionListener(new ActionListener()
@@ -1748,8 +1734,8 @@ public class GAlignFrame extends JInternalFrame
     });
     JMenuItem selectHighlighted = new JMenuItem(
             MessageManager.getString("action.select_highlighted_columns"));
-    selectHighlighted.setToolTipText(MessageManager
-            .getString("tooltip.select_highlighted_columns"));
+    selectHighlighted.setToolTipText(
+            MessageManager.getString("tooltip.select_highlighted_columns"));
     al = new ActionListener()
     {
       @Override
@@ -1763,7 +1749,7 @@ public class GAlignFrame extends JInternalFrame
             MessageManager.getString("label.sequence_id_tooltip"));
     JMenu autoAnnMenu = new JMenu(
             MessageManager.getString("label.autocalculated_annotation"));
-
+  
     JMenu exportImageMenu = new JMenu(
             MessageManager.getString("label.export_image"));
     JMenu fileMenu = new JMenu(MessageManager.getString("action.file"));
@@ -1776,7 +1762,8 @@ public class GAlignFrame extends JInternalFrame
     alignFrameMenuBar.add(colourMenu);
     alignFrameMenuBar.add(calculateMenu);
     alignFrameMenuBar.add(webService);
-
+    alignFrameMenuBar.add(hmmerMenu);
+  
     fileMenu.add(fetchSequence);
     fileMenu.add(addSequenceMenu);
     fileMenu.add(reload);
@@ -1793,9 +1780,10 @@ public class GAlignFrame extends JInternalFrame
     fileMenu.add(exportAnnotations);
     fileMenu.add(loadTreeMenuItem);
     fileMenu.add(associatedData);
+    fileMenu.add(loadVcf);
     fileMenu.addSeparator();
     fileMenu.add(closeMenuItem);
-
+  
     pasteMenu.add(pasteNew);
     pasteMenu.add(pasteThis);
     editMenu.add(undoMenuItem);
@@ -1817,7 +1805,7 @@ public class GAlignFrame extends JInternalFrame
     // editMenu.add(justifyRightMenuItem);
     // editMenu.addSeparator();
     editMenu.add(padGapsMenuitem);
-
+  
     showMenu.add(showAllColumns);
     showMenu.add(showAllSeqs);
     showMenu.add(showAllhidden);
@@ -1845,7 +1833,7 @@ public class GAlignFrame extends JInternalFrame
     viewMenu.add(alignmentProperties);
     viewMenu.addSeparator();
     viewMenu.add(overviewMenuItem);
-
+  
     annotationsMenu.add(annotationPanelMenuItem);
     annotationsMenu.addSeparator();
     annotationsMenu.add(showAllAlAnnotations);
@@ -1868,7 +1856,6 @@ public class GAlignFrame extends JInternalFrame
     autoAnnMenu.add(showGroupConsensus);
     annotationsMenu.add(autoAnnMenu);
 
-
     sort.add(sortIDMenuItem);
     sort.add(sortLengthMenuItem);
     sort.add(sortGroupMenuItem);
@@ -1878,7 +1865,6 @@ public class GAlignFrame extends JInternalFrame
     calculateMenu.add(calculateTree);
     calculateMenu.addSeparator();
     calculateMenu.add(pairwiseAlignmentMenuItem);
-    calculateMenu.add(PCAMenuItem);
     calculateMenu.addSeparator();
     calculateMenu.add(showTranslation);
     calculateMenu.add(showReverse);
@@ -1891,7 +1877,7 @@ public class GAlignFrame extends JInternalFrame
     calculateMenu.add(extractScores);
     calculateMenu.addSeparator();
     calculateMenu.add(runGroovy);
-
+  
     webServiceNoServices = new JMenuItem(
             MessageManager.getString("label.no_services"));
     webService.add(webServiceNoServices);
@@ -1906,7 +1892,7 @@ public class GAlignFrame extends JInternalFrame
     this.getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH);
     statusPanel.add(statusBar, null);
     this.getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER);
-
+  
     formatMenu.add(font);
     formatMenu.addSeparator();
     formatMenu.add(wrapMenuItem);
@@ -1941,66 +1927,161 @@ public class GAlignFrame extends JInternalFrame
   }
 
   /**
-   * Constructs the entries on the Colour menu (but does not add them to the
-   * menu). The 'name' property of each item is set to the canonical name of the
-   * corresponding colour scheme (may not match the display name), to allow
-   * selection of items by colour scheme name.
+   * Constructs the entries on the HMMER menu
    */
-  protected void initColourMenu()
+  protected void initHMMERMenu()
   {
-    applyToAllGroups = new JCheckBoxMenuItem(
-            MessageManager.getString("label.apply_colour_to_all_groups"));
-    applyToAllGroups.addActionListener(new ActionListener()
+    /*
+     * hmmbuild
+     */
+    JMenu hmmBuild = new JMenu(MessageManager.getString("label.hmmbuild"));
+    JMenuItem hmmBuildSettings = new JMenuItem(
+            MessageManager.getString("label.edit_settings_and_run"));
+    hmmBuildSettings.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        applyToAllGroups_actionPerformed();
+        hmmBuild_actionPerformed(false);
       }
     });
+    JMenuItem hmmBuildRun = new JMenuItem(MessageManager.formatMessage(
+            "label.action_with_default_settings", "hmmbuild"));
+    hmmBuildRun.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        hmmBuild_actionPerformed(true);
+      }
+    });
+    hmmBuild.add(hmmBuildRun);
+    hmmBuild.add(hmmBuildSettings);
 
-    textColour = new JRadioButtonMenuItem(
-            MessageManager.getString("action.set_text_colour"));
-    textColour.addActionListener(new ActionListener()
+    /*
+     * hmmalign
+     */
+    JMenu hmmAlign = new JMenu(MessageManager.getString("label.hmmalign"));
+    JMenuItem hmmAlignRun = new JMenuItem(MessageManager.formatMessage(
+            "label.action_with_default_settings", "hmmalign"));
+    hmmAlignRun.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        textColour_actionPerformed();
+        hmmAlign_actionPerformed(true);
+      }
+    });
+    JMenuItem hmmAlignSettings = new JMenuItem(
+            MessageManager.getString("label.edit_settings_and_run"));
+    hmmAlignSettings.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        hmmAlign_actionPerformed(false);
       }
     });
+    hmmAlign.add(hmmAlignRun);
+    hmmAlign.add(hmmAlignSettings);
 
-    userDefinedColour = new JRadioButtonMenuItem(
-            MessageManager
-            .getString("action.user_defined"));
-    userDefinedColour.addActionListener(new ActionListener()
+    /*
+     * hmmsearch
+     */
+    JMenu hmmSearch = new JMenu(
+            MessageManager.getString("label.hmmsearch"));
+    JMenuItem hmmSearchSettings = new JMenuItem(
+            MessageManager.getString("label.edit_settings_and_run"));
+    hmmSearchSettings.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        hmmSearch_actionPerformed(false);
+      }
+    });
+    JMenuItem hmmSearchRun = new JMenuItem(MessageManager.formatMessage(
+            "label.action_with_default_settings", "hmmsearch"));
+    hmmSearchRun.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        hmmSearch_actionPerformed(true);
+      }
+    });
+    JMenuItem addDatabase = new JMenuItem(
+            MessageManager.getString("label.add_database"));
+    addDatabase.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        userDefinedColour_actionPerformed(e);
+        try
+        {
+          addDatabase_actionPerformed();
+        } catch (IOException e1)
+        {
+          e1.printStackTrace();
+        }
       }
     });
+    hmmSearch.add(hmmSearchRun);
+    hmmSearch.add(hmmSearchSettings);
+    // hmmSearch.add(addDatabase);
 
-    conservationMenuItem = new JCheckBoxMenuItem(
-            MessageManager.getString("action.by_conservation"));
-    conservationMenuItem.addActionListener(new ActionListener()
+    /*
+     * top level menu
+     */
+    hmmerMenu.setText(MessageManager.getString("action.hmmer"));
+    hmmerMenu.setEnabled(HmmerCommand.isHmmerAvailable());
+    hmmerMenu.add(hmmBuild);
+    hmmerMenu.add(hmmAlign);
+    hmmerMenu.add(hmmSearch);
+
+  }
+
+  protected void loadVcf_actionPerformed()
+  {
+  }
+
+  /**
+   * Constructs the entries on the Colour menu (but does not add them to the
+   * menu).
+   */
+  protected void initColourMenu()
+  {
+    applyToAllGroups = new JCheckBoxMenuItem(
+            MessageManager.getString("label.apply_colour_to_all_groups"));
+    applyToAllGroups.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        conservationMenuItem_actionPerformed();
+        applyToAllGroups_actionPerformed(applyToAllGroups.isSelected());
       }
     });
-    noColourmenuItem = new JRadioButtonMenuItem(
-            MessageManager.getString("label.none"));
-    noColourmenuItem.setName("None");
-    noColourmenuItem.addActionListener(new ActionListener()
+
+    textColour = new JMenuItem(
+            MessageManager.getString("label.text_colour"));
+    textColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        textColour_actionPerformed();
+      }
+    });
+
+    conservationMenuItem = new JCheckBoxMenuItem(
+            MessageManager.getString("action.by_conservation"));
+    conservationMenuItem.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        noColourmenuItem_actionPerformed();
+        conservationMenuItem_actionPerformed(
+                conservationMenuItem.isSelected());
       }
     });
 
@@ -2011,7 +2092,7 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        abovePIDThreshold_actionPerformed();
+        abovePIDThreshold_actionPerformed(abovePIDThreshold.isSelected());
       }
     });
     modifyPID = new JMenuItem(
@@ -2024,8 +2105,7 @@ public class GAlignFrame extends JInternalFrame
         modifyPID_actionPerformed();
       }
     });
-    modifyConservation = new JMenuItem(
-            MessageManager
+    modifyConservation = new JMenuItem(MessageManager
             .getString("label.modify_conservation_threshold"));
     modifyConservation.addActionListener(new ActionListener()
     {
@@ -2036,8 +2116,9 @@ public class GAlignFrame extends JInternalFrame
       }
     });
 
-    annotationColour = new JMenuItem(
+    annotationColour = new JRadioButtonMenuItem(
             MessageManager.getString("action.by_annotation"));
+    annotationColour.setName(ResidueColourScheme.ANNOTATION_COLOUR);
     annotationColour.addActionListener(new ActionListener()
     {
       @Override
@@ -2383,41 +2464,11 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void PCAMenuItem_actionPerformed(ActionEvent e)
-  {
-  }
-
-  protected void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e)
-  {
-  }
-
   protected void neighbourTreeMenuItem_actionPerformed(ActionEvent e)
   {
   }
 
-  protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e)
-  {
-  }
-
-  protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e)
-  {
-  }
-
-  protected void userDefinedColour_actionPerformed(ActionEvent e)
-  {
-  }
-
-  
-
-  /*
-   * protected void covariationColour_actionPerformed() { }
-   */
-
-  protected void noColourmenuItem_actionPerformed()
-  {
-  }
-
-  protected void conservationMenuItem_actionPerformed()
+  protected void conservationMenuItem_actionPerformed(boolean selected)
   {
   }
 
@@ -2433,7 +2484,7 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void abovePIDThreshold_actionPerformed()
+  protected void abovePIDThreshold_actionPerformed(boolean selected)
   {
   }
 
@@ -2466,14 +2517,33 @@ public class GAlignFrame extends JInternalFrame
   }
 
   protected void pasteNew_actionPerformed(ActionEvent e)
+          throws IOException, InterruptedException
   {
   }
 
   protected void pasteThis_actionPerformed(ActionEvent e)
+          throws IOException, InterruptedException
+  {
+  }
+
+  protected void applyToAllGroups_actionPerformed(boolean selected)
+  {
+  }
+
+  protected void hmmBuild_actionPerformed(boolean withDefaults)
+  {
+  }
+
+  protected void hmmSearch_actionPerformed(boolean withDefaults)
+  {
+  }
+
+  protected void addDatabase_actionPerformed()
+          throws FileFormatException, IOException
   {
   }
 
-  protected void applyToAllGroups_actionPerformed()
+  protected void hmmAlign_actionPerformed(boolean withDefaults)
   {
   }
 
@@ -2563,7 +2633,7 @@ public class GAlignFrame extends JInternalFrame
 
   }
 
-  public void showTranslation_actionPerformed(ActionEvent e)
+  public void showTranslation_actionPerformed(GeneticCodeI codeTable)
   {
 
   }
@@ -2592,6 +2662,7 @@ public class GAlignFrame extends JInternalFrame
   }
 
   public void associatedData_actionPerformed(ActionEvent e)
+          throws IOException, InterruptedException
   {
 
   }
@@ -2701,7 +2772,7 @@ public class GAlignFrame extends JInternalFrame
 
   }
 
-  public void buildTreeMenu()
+  public void buildTreeSortMenu()
   {
 
   }