Update spike branch to latest
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 23 May 2018 14:05:50 +0000 (15:05 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 23 May 2018 14:05:50 +0000 (15:05 +0100)
src/jalview/analysis/AlignmentUtils.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/OptsAndParamsPage.java
src/jalview/hmmer/HMMSearch.java
src/jalview/jbgui/GAlignFrame.java

index d1217bf..87aaf08 100644 (file)
@@ -1461,28 +1461,31 @@ public class AlignmentUtils
       final List<AlignmentAnnotation> result = new ArrayList<>();
       for (AlignmentAnnotation dsann : datasetAnnotations)
       {
-        /*
-         * Find matching annotations on the alignment. If none is found, then
-         * add this annotation to the list of 'addable' annotations for this
-         * sequence.
-         */
-        final Iterable<AlignmentAnnotation> matchedAlignmentAnnotations = al
-                .findAnnotations(seq, dsann.getCalcId(), dsann.label);
-        if (!matchedAlignmentAnnotations.iterator().hasNext())
+        if (dsann.annotations != null) // ignore non-positional annotation
         {
-          result.add(dsann);
-          if (labelForCalcId != null)
+          /*
+           * Find matching annotations on the alignment. If none is found, then
+           * add this annotation to the list of 'addable' annotations for this
+           * sequence.
+           */
+          final Iterable<AlignmentAnnotation> matchedAlignmentAnnotations = al
+                  .findAnnotations(seq, dsann.getCalcId(), dsann.label);
+          if (!matchedAlignmentAnnotations.iterator().hasNext())
           {
-            labelForCalcId.put(dsann.getCalcId(), dsann.label);
+            result.add(dsann);
+            if (labelForCalcId != null)
+            {
+              labelForCalcId.put(dsann.getCalcId(), dsann.label);
+            }
           }
         }
-      }
-      /*
-       * Save any addable annotations for this sequence
-       */
-      if (!result.isEmpty())
-      {
-        candidates.put(seq, result);
+        /*
+         * Save any addable annotations for this sequence
+         */
+        if (!result.isEmpty())
+        {
+          candidates.put(seq, result);
+        }
       }
     }
   }
index 89066cb..be765ec 100644 (file)
@@ -139,9 +139,9 @@ import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Deque;
-import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import java.util.Vector;
 
 import javax.swing.JCheckBoxMenuItem;
@@ -3903,35 +3903,33 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
 
     if (viewport.getAlignment().getAlignmentAnnotation()
-            .hashCode() != _annotationScoreVectorHash)
+            .hashCode() == _annotationScoreVectorHash)
     {
-      sortByAnnotScore.removeAll();
-      // almost certainly a quicker way to do this - but we keep it simple
-      Hashtable scoreSorts = new Hashtable();
-      AlignmentAnnotation aann[];
-      for (SequenceI sqa : viewport.getAlignment().getSequences())
+      return;
+    }
+
+    sortByAnnotScore.removeAll();
+    Set<String> scoreSorts = new HashSet<>();
+    for (SequenceI sqa : viewport.getAlignment().getSequences())
+    {
+      AlignmentAnnotation[] anns = sqa.getAnnotation();
+      for (int i = 0; anns != null && i < anns.length; i++)
       {
-        aann = sqa.getAnnotation();
-        for (int i = 0; aann != null && i < aann.length; i++)
+        AlignmentAnnotation aa = anns[i];
+        if (aa != null && aa.hasScore() && aa.sequenceRef != null)
         {
-          if (aann[i].hasScore() && aann[i].sequenceRef != null)
-          {
-            scoreSorts.put(aann[i].label, aann[i].label);
-          }
+          scoreSorts.add(aa.label);
         }
       }
-      Enumeration labels = scoreSorts.keys();
-      while (labels.hasMoreElements())
-      {
-        addSortByAnnotScoreMenuItem(sortByAnnotScore,
-                (String) labels.nextElement());
-      }
-      sortByAnnotScore.setVisible(scoreSorts.size() > 0);
-      scoreSorts.clear();
-
-      _annotationScoreVectorHash = viewport.getAlignment()
-              .getAlignmentAnnotation().hashCode();
     }
+    for (String label : scoreSorts)
+    {
+      addSortByAnnotScoreMenuItem(sortByAnnotScore, label);
+    }
+    sortByAnnotScore.setVisible(!scoreSorts.isEmpty());
+
+    _annotationScoreVectorHash = viewport.getAlignment()
+            .getAlignmentAnnotation().hashCode();
   }
 
   /**
@@ -5798,22 +5796,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   }
 
   @Override
-  public void hmmerMenu_actionPerformed(ActionEvent e)
-  {
-    SequenceGroup grp = getViewport().getSelectionGroup();
-    if (grp != null)
-    {
-      hmmBuild.setText(MessageManager.getString("label.hmmbuild") + " from "
-              + grp.getName());
-    }
-    else
-    {
-      hmmBuild.setText(MessageManager.getString("label.hmmbuild")
-              + " from Alignment");
-    }
-  }
-
-  @Override
   protected void loadVcf_actionPerformed()
   {
     JalviewFileChooser chooser = new JalviewFileChooser(
index 298057f..4cac990 100644 (file)
@@ -574,23 +574,13 @@ public class OptsAndParamsPage
      */
     private void checkIfModified()
     {
-      if (!adjusting)
+      Object newValue = updateSliderFromValueField();
+      boolean modified = true;
+      if (newValue.getClass() == lastVal.getClass())
       {
-        try
-        {
-          adjusting = true;
-          Object newValue = updateSliderFromValueField();
-          boolean modified = true;
-          if (newValue.getClass() == lastVal.getClass())
-          {
-            modified = !newValue.equals(lastVal);
-          }
-          pmdialogbox.argSetModified(this, modified);
-        } finally
-        {
-          adjusting = false;
-        }
+        modified = !newValue.equals(lastVal);
       }
+      pmdialogbox.argSetModified(this, modified);
     }
 
     @Override
@@ -734,6 +724,7 @@ public class OptsAndParamsPage
         if (isChoiceParameter)
         {
           choicebox = buildComboBox(parm);
+          choicebox.addActionListener(this);
           controlsPanel.add(choicebox, BorderLayout.CENTER);
         }
         else
@@ -765,9 +756,17 @@ public class OptsAndParamsPage
         }
       }
 
-      if (!isChoiceParameter && parm != null)
+      String value = parm.getValue();
+      if (value != null)
       {
-        valueField.setText(parm.getValue());
+        if (isChoiceParameter)
+        {
+          choicebox.setSelectedItem(value);
+        }
+        else
+        {
+          valueField.setText(value);
+        }
       }
       lastVal = updateSliderFromValueField();
       adjusting = false;
index efc34ae..a58b949 100644 (file)
@@ -4,10 +4,10 @@ import jalview.bin.Cache;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
-import jalview.datamodel.Annotation;
 import jalview.datamodel.HiddenMarkovModel;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
 import jalview.gui.JvOptionPane;
 import jalview.io.DataSourceType;
 import jalview.io.FileParse;
@@ -72,6 +72,8 @@ public class HMMSearch extends HmmerCommand
 
   SequenceI[] seqs;
 
+  private String databaseName;
+
   /**
    * Constructor for the HMMSearchThread
    * 
@@ -99,7 +101,7 @@ public class HMMSearch extends HmmerCommand
       return;
     }
 
-    SequenceI hmmSeq = hmm.getConsensusSequence();// af.getSelectedHMMSequence();
+    SequenceI hmmSeq = hmm.getConsensusSequence();
     long msgId = System.currentTimeMillis();
     af.setProgressBar(MessageManager.getString("status.running_hmmsearch"),
             msgId);
@@ -158,6 +160,25 @@ public class HMMSearch extends HmmerCommand
 
     List<String> args = new ArrayList<>();
     args.add(command);
+    buildArguments(args, searchOutputFile, hitsAlignmentFile, hmmFile);
+
+    return runCommand(args);
+  }
+
+  /**
+   * Appends command line arguments to the given list, to specify input and
+   * output files for the search, and any additional options that may have been
+   * passed from the parameters dialog
+   * 
+   * @param args
+   * @param searchOutputFile
+   * @param hitsAlignmentFile
+   * @param hmmFile
+   * @throws IOException
+   */
+  protected void buildArguments(List<String> args, File searchOutputFile,
+          File hitsAlignmentFile, File hmmFile) throws IOException
+  {
     args.add("-o");
     args.add(getFilePath(searchOutputFile));
     args.add("-A");
@@ -173,6 +194,7 @@ public class HMMSearch extends HmmerCommand
     String domEvalueCutoff = null;
     String seqScoreCutoff = null;
     String domScoreCutoff = null;
+    databaseName = "Alignment";
 
     if (params != null)
     {
@@ -187,7 +209,7 @@ public class HMMSearch extends HmmerCommand
         else if (MessageManager.getString(AUTO_ALIGN_SEQS_KEY)
                 .equals(name))
         {
-          realign = true; // TODO: not used
+          realign = true;
         }
         else if (MessageManager.getString(USE_ACCESSIONS_KEY)
                 .equals(name))
@@ -235,6 +257,8 @@ public class HMMSearch extends HmmerCommand
           if (!MessageManager.getString(THIS_ALIGNMENT_KEY)
                   .equals(dbPath))
           {
+            int pos = dbPath.lastIndexOf(File.separator);
+            databaseName = dbPath.substring(pos + 1);
             databaseFile = new File(dbPath);
           }
         }
@@ -277,13 +301,11 @@ public class HMMSearch extends HmmerCommand
 
     args.add(getFilePath(hmmFile));
     args.add(getFilePath(databaseFile));
-
-    return runCommand(args);
   }
 
   /**
    * Imports the data from the temporary file to which the output of hmmsearch
-   * is directed.
+   * was directed. The results are optionally realigned using hmmalign.
    * 
    * @param hmmSeq
    */
@@ -312,27 +334,21 @@ public class HMMSearch extends HmmerCommand
       hmmAndSeqs[0] = hmmSeq;
       System.arraycopy(seqs, 0, hmmAndSeqs, 1, seqCount);
 
-      /*
-       * and align the search results to the HMM profile
-       */
-      AlignmentI al = new Alignment(hmmAndSeqs);
-      AlignFrame frame = new AlignFrame(al, 1, 1);
-      List<ArgumentI> alignArgs = new ArrayList<>();
-      String defSeq = hmmSeq.getName();
-      List<String> options = Collections.singletonList(defSeq);
-      Option option = new Option(MessageManager.getString("label.use_hmm"),
-              "", true, defSeq, defSeq, options, null);
-      alignArgs.add(option);
-      if (trim)
+      if (realign)
       {
-        alignArgs.add(new BooleanOption(
-                MessageManager.getString(TRIM_TERMINI_KEY),
-                MessageManager.getString("label.trim_termini_desc"), true,
-                true, true, null));
+        realignResults(hmmAndSeqs);
       }
-      HmmerCommand hmmalign = new HMMAlign(frame, alignArgs);
-      hmmalign.run();
-      frame = null;
+      else
+      {
+        AlignmentI al = new Alignment(hmmAndSeqs);
+        AlignFrame alignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
+                AlignFrame.DEFAULT_HEIGHT);
+        String ttl = "hmmSearch of " + databaseName + " using "
+                + hmmSeq.getName();
+        Desktop.addInternalFrame(alignFrame, ttl, AlignFrame.DEFAULT_WIDTH,
+                AlignFrame.DEFAULT_HEIGHT);
+      }
+
       hmmTemp.delete();
       inputAlignmentTemp.delete();
       searchOutputFile.delete();
@@ -345,6 +361,43 @@ public class HMMSearch extends HmmerCommand
     }
   }
 
+  /**
+   * Realigns the given sequences using hmmalign, to the HMM profile sequence
+   * which is the first in the array, and opens the results in a new frame
+   * 
+   * @param hmmAndSeqs
+   */
+  protected void realignResults(SequenceI[] hmmAndSeqs)
+  {
+    /*
+     * and align the search results to the HMM profile
+     */
+    AlignmentI al = new Alignment(hmmAndSeqs);
+    AlignFrame frame = new AlignFrame(al, 1, 1);
+    List<ArgumentI> alignArgs = new ArrayList<>();
+    String alignTo = hmmAndSeqs[0].getName();
+    List<String> options = Collections.singletonList(alignTo);
+    Option option = new Option(MessageManager.getString("label.use_hmm"),
+            "", true, alignTo, alignTo, options, null);
+    alignArgs.add(option);
+    if (trim)
+    {
+      alignArgs.add(new BooleanOption(
+              MessageManager.getString(TRIM_TERMINI_KEY),
+              MessageManager.getString("label.trim_termini_desc"), true,
+              true, true, null));
+    }
+    HmmerCommand hmmalign = new HMMAlign(frame, alignArgs);
+    hmmalign.run();
+  }
+
+  /**
+   * Reads in the scores table output by hmmsearch and adds annotation to
+   * sequences for E-value and bit score
+   * 
+   * @param inputTableTemp
+   * @throws IOException
+   */
   void readTable(File inputTableTemp) throws IOException
   {
     BufferedReader br = new BufferedReader(new FileReader(inputTableTemp));
@@ -362,22 +415,14 @@ public class HMMSearch extends HmmerCommand
     while (!"  ------ inclusion threshold ------".equals(line)
             && !"".equals(line))
     {
+      SequenceI seq = seqs[index];
       Scanner scanner = new Scanner(line);
-
-      String str = scanner.next(); // full sequence eValue score
-      float eValue = Float.parseFloat(str);
-      int seqLength = seqs[index].getLength();
-      Annotation[] annots = new Annotation[seqLength];
-      for (int j = 0; j < seqLength; j++)
-      {
-        annots[j] = new Annotation(eValue);
-      }
-      AlignmentAnnotation annot = new AlignmentAnnotation("E-value",
-              "Score", annots);
-      annot.setScore(Double.parseDouble(str));
-      annot.setSequenceRef(seqs[index]);
-      seqs[index].addAlignmentAnnotation(annot);
-
+      String str = scanner.next();
+      addScoreAnnotation(str, seq, "hmmsearch E-value",
+              "Full sequence E-value");
+      str = scanner.next();
+      addScoreAnnotation(str, seq, "hmmsearch Score",
+              "Full sequence bit score");
       scanner.close();
       line = br.readLine();
       index++;
@@ -386,4 +431,31 @@ public class HMMSearch extends HmmerCommand
     br.close();
   }
 
+  /**
+   * A helper method that adds one score-only (non-positional) annotation to a
+   * sequence
+   * 
+   * @param value
+   * @param seq
+   * @param label
+   * @param description
+   */
+  protected void addScoreAnnotation(String value, SequenceI seq,
+          String label, String description)
+  {
+    try
+    {
+      AlignmentAnnotation annot = new AlignmentAnnotation(label,
+              description, null);
+      annot.setCalcId(HMMSEARCH);
+      double eValue = Double.parseDouble(value);
+      annot.setScore(eValue);
+      annot.setSequenceRef(seq);
+      seq.addAlignmentAnnotation(annot);
+    } catch (NumberFormatException e)
+    {
+      System.err.println("Error parsing " + label + " from " + value);
+    }
+  }
+
 }
index 8226cee..bc71566 100755 (executable)
@@ -72,26 +72,6 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenu hmmerMenu = new JMenu();
 
-  protected JMenu hmmAlign = new JMenu();
-
-  protected JMenuItem hmmAlignRun = new JMenuItem();
-
-  protected JMenuItem hmmAlignSettings = new JMenuItem();
-
-  protected JMenu hmmSearch = new JMenu();
-
-  protected JMenuItem hmmSearchRun = new JMenuItem();
-
-  protected JMenuItem hmmSearchSettings = new JMenuItem();
-
-  protected JMenuItem addDatabase = new JMenuItem();
-
-  protected JMenu hmmBuild = new JMenu();
-
-  protected JMenuItem hmmBuildRun = new JMenuItem();
-
-  protected JMenuItem hmmBuildSettings = new JMenuItem();
-
   protected JMenuItem webServiceNoServices;
 
   protected JCheckBoxMenuItem viewBoxesMenuItem = new JCheckBoxMenuItem();
@@ -280,7 +260,6 @@ public class GAlignFrame extends JInternalFrame
   private void jbInit() throws Exception
   {
     initColourMenu();
-    initHMMERMenu();
   
     JMenuItem saveAs = new JMenuItem(
             MessageManager.getString("action.save_as"));
@@ -322,19 +301,8 @@ public class GAlignFrame extends JInternalFrame
     JMenu calculateMenu = new JMenu(
             MessageManager.getString("action.calculate"));
     webService.setText(MessageManager.getString("action.web_service"));
-    hmmerMenu.setText(MessageManager.getString("action.hmmer"));
-    hmmerMenu.setEnabled(HmmerCommand.isHmmerAvailable());
-    hmmerMenu.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        hmmerMenu_actionPerformed(e);
-      }
-    });
-    hmmerMenu.add(hmmBuild);
-    hmmerMenu.add(hmmAlign);
-    hmmerMenu.add(hmmSearch);
+
+    initHMMERMenu();
 
     JMenuItem selectAllSequenceMenuItem = new JMenuItem(
             MessageManager.getString("action.select_all"));
@@ -1757,81 +1725,6 @@ public class GAlignFrame extends JInternalFrame
         selectHighlightedColumns_actionPerformed(actionEvent);
       }
     };
-    hmmBuildRun.setText(MessageManager.formatMessage(
-            "label.action_with_default_settings", "hmmbuild"));
-    hmmBuildRun.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        hmmBuild_actionPerformed(true);
-      }
-    });
-    hmmBuildSettings.setText(
-            MessageManager.getString("label.edit_settings_and_run"));
-    hmmBuildSettings.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        hmmBuild_actionPerformed(false);
-      }
-    });
-    hmmAlignRun.setText(MessageManager.formatMessage(
-            "label.action_with_default_settings", "hmmalign"));
-    hmmAlignRun.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        hmmAlign_actionPerformed(true);
-      }
-    });
-    hmmAlignSettings.setText(
-            MessageManager.getString("label.edit_settings_and_run"));
-    hmmAlignSettings.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        hmmAlign_actionPerformed(false);
-      }
-    });
-    hmmSearchRun.setText(MessageManager.formatMessage(
-            "label.action_with_default_settings", "hmmsearch"));
-    hmmSearchRun.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        hmmSearch_actionPerformed(true);
-      }
-    });
-    hmmSearchSettings.setText(
-            MessageManager.getString("label.edit_settings_and_run"));
-    hmmSearchSettings.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        hmmSearch_actionPerformed(false);
-      }
-    });
-    addDatabase.setText(MessageManager.getString("label.add_database"));
-    addDatabase.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        try
-        {
-          addDatabase_actionPerformed();
-        } catch (IOException e1)
-        {
-          e1.printStackTrace();
-        }
-      }
-    });
     selectHighlighted.addActionListener(al);
     JMenu tooltipSettingsMenu = new JMenu(
             MessageManager.getString("label.sequence_id_tooltip"));
@@ -2014,40 +1907,119 @@ public class GAlignFrame extends JInternalFrame
     // selectMenu.add(listenToViewSelections);
   }
 
-  public void hmmerMenu_actionPerformed(ActionEvent e)
-  {
-
-  }
-
   /**
-   * Constructs the entries on the HMMER menu (does not add them to the menu).
+   * Constructs the entries on the HMMER menu
    */
   protected void initHMMERMenu()
   {
-    hmmAlign = new JMenu(MessageManager.getString("label.hmmalign"));
-    hmmAlignSettings = new JMenuItem(
-            MessageManager.getString("label.edit_settings_and_run"));
-    hmmAlignRun = new JMenuItem(MessageManager.formatMessage(
-            "label.action_with_default_settings", "hmmalign"));
-    hmmAlign.add(hmmAlignSettings);
-    hmmAlign.add(hmmAlignRun);
-    hmmBuild = new JMenu(MessageManager.getString("label.hmmbuild"));
-    hmmBuildSettings = new JMenuItem(
+    /*
+     * hmmbuild
+     */
+    JMenu hmmBuild = new JMenu(MessageManager.getString("label.hmmbuild"));
+    JMenuItem hmmBuildSettings = new JMenuItem(
             MessageManager.getString("label.edit_settings_and_run"));
-    hmmBuildRun = new JMenuItem(MessageManager.formatMessage(
+    hmmBuildSettings.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        hmmBuild_actionPerformed(false);
+      }
+    });
+    JMenuItem hmmBuildRun = new JMenuItem(MessageManager.formatMessage(
             "label.action_with_default_settings", "hmmbuild"));
-    hmmBuild.add(hmmBuildSettings);
+    hmmBuildRun.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        hmmBuild_actionPerformed(true);
+      }
+    });
     hmmBuild.add(hmmBuildRun);
-    hmmSearch = new JMenu(MessageManager.getString("label.hmmsearch"));
-    hmmSearchSettings = new JMenuItem(
+    hmmBuild.add(hmmBuildSettings);
+
+    /*
+     * 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)
+      {
+        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);
+
+    /*
+     * hmmsearch
+     */
+    JMenu hmmSearch = new JMenu(
+            MessageManager.getString("label.hmmsearch"));
+    JMenuItem hmmSearchSettings = new JMenuItem(
             MessageManager.getString("label.edit_settings_and_run"));
-    hmmSearchRun = new JMenuItem(MessageManager.formatMessage(
+    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"));
-    addDatabase = new JMenuItem(
+    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)
+      {
+        try
+        {
+          addDatabase_actionPerformed();
+        } catch (IOException e1)
+        {
+          e1.printStackTrace();
+        }
+      }
+    });
     hmmSearch.add(hmmSearchSettings);
     hmmSearch.add(hmmSearchRun);
     hmmSearch.add(addDatabase);
+
+    /*
+     * 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()