JAL-2629 selected HMM name now shown in HMMER menu
authorTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Tue, 15 Aug 2017 11:21:15 +0000 (12:21 +0100)
committerTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Tue, 15 Aug 2017 11:21:15 +0000 (12:21 +0100)
resources/lang/Messages.properties
src/jalview/gui/AlignFrame.java
src/jalview/gui/PopupMenu.java
src/jalview/hmmer/HMMAlignThread.java
src/jalview/io/FileLoader.java
src/jalview/jbgui/GAlignFrame.java
src/jalview/viewmodel/AlignmentViewport.java

index a03ab7f..891a8ac 100644 (file)
@@ -1315,11 +1315,11 @@ label.occupancy_descr = Number of aligned positions
 label.show_experimental = Enable experimental features
 label.show_experimental_tip = Enable any new and currently 'experimental' features (see Latest Release Notes for details)
 label.warning_hidden = Warning: {0} {1} is currently hidden
-label.hmmalign = Align Sequences to HMM
-label.hmmbuild = Build HMM from Alignment
+label.hmmalign = hmmalign
+label.hmmbuild = hmmbuild
 label.hmmbuild_group = Build HMM from Selected Group
 label.group_hmmbuild = Build HMM from Group
-label.hmmsearch = Search for Related Sequences
+label.hmmsearch = hmmsearch
 label.change_hmmer_location = HMMER Installation Location
 warn.null_hmm = Please ensure the alignment contains a hidden Markov model.
 label.ignore_below_background_frequency = Ignore Below Background Frequency
index 9c4a75c..ed26833 100644 (file)
@@ -54,6 +54,7 @@ import jalview.datamodel.AlignmentOrder;
 import jalview.datamodel.AlignmentView;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.HiddenMarkovModel;
 import jalview.datamodel.HiddenSequences;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SeqCigar;
@@ -178,6 +179,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
   public AlignViewControllerI avc;
 
+  HiddenMarkovModel selectedHMM = null;
+
   List<AlignmentPanel> alignPanels = new ArrayList<>();
 
   /**
@@ -5698,6 +5701,42 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   {
     hmmerMenu.setEnabled(status);
   }
+
+  public HiddenMarkovModel getSelectedHMM()
+  {
+    return selectedHMM;
+  }
+
+  /**
+   * Sets the selected hidden Markov model
+   * 
+   * @param selectedHMM
+   */
+  public void setSelectedHMM(HiddenMarkovModel selectedHMM)
+  {
+    this.selectedHMM = selectedHMM;
+    hmmAlign.setText(MessageManager.getString("label.hmmalign") + " to "
+            + selectedHMM.getName() + "_HMM");
+    hmmSearch.setText(MessageManager.getString("label.hmmsearch") + " with "
+            + selectedHMM.getName() + "_HMM");
+  }
+
+  @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");
+    }
+  }
+
 }
 
 class PrintThread extends Thread
@@ -5736,6 +5775,4 @@ class PrintThread extends Thread
       }
     }
   }
-
-
 }
index fd652b2..73d7941 100644 (file)
@@ -1295,12 +1295,12 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
   protected void selectHMM_actionPerformed(ActionEvent e)
   {
     HiddenMarkovModel hmm = ap.av.getSequenceSelection()[0].getHMM();
-    ap.av.setSelectedHMM(hmm);
+    ap.alignFrame.setSelectedHMM(hmm);
   }
 
   protected void hmmAlign_actionPerformed(ActionEvent e)
   {
-    ap.av.setSelectedHMM(this.sequence.getHMM());
+    ap.alignFrame.setSelectedHMM(this.sequence.getHMM());
     new Thread(new HMMAlignThread(ap.alignFrame, true)).start();
     ap.repaint();
   }
index a778e14..d94ce97 100644 (file)
@@ -80,7 +80,7 @@ public class HMMAlignThread implements Runnable
   @Override
   public void run()
   {
-         if (af.getViewport().getSelectedHMM() == null)
+    if (af.getSelectedHMM() == null)
     {
       JOptionPane.showMessageDialog(af,
               MessageManager.getString("warn.no_selected_hmm"));
@@ -88,7 +88,7 @@ public class HMMAlignThread implements Runnable
     }
     else
     {
-       hmm = af.getViewport().getSelectedHMM();
+      hmm = af.getSelectedHMM();
     }
     barID = System.currentTimeMillis();
     af.setProgressBar(MessageManager.getString("status.running_hmmalign"),
index b861c07..f04b88d 100755 (executable)
@@ -413,7 +413,7 @@ public class FileLoader implements Runnable
               }
               else
               {
-                 for (int i = 0; i < alignment.getAbsoluteHeight(); i++)
+                  for (int i = 0; i < alignment.getAbsoluteHeight(); i++)
                   {
                     if (!alignment.getSequenceAt(i).isHMMConsensusSequence())
                     {
@@ -427,8 +427,16 @@ public class FileLoader implements Runnable
               viewport.updateInformation(viewport.getAlignPanel());
               viewport.getAlignPanel().adjustAnnotationHeight();
               viewport.updateSequenceIdColours();
-              viewport.getAlignPanel().paintAlignment(true);
+              if (viewport.getAlignPanel().alignFrame
+                      .getSelectedHMM() == null)
+              {
+                viewport.getAlignPanel().alignFrame
+                        .setSelectedHMM(seq.getHMM());
+              }
+              viewport.getAlignPanel().repaint();
               viewport.alignmentChanged(viewport.getAlignPanel());
+
+
             }
           }
           else
index e9dd53b..738d98f 100755 (executable)
@@ -313,7 +313,15 @@ public class GAlignFrame extends JInternalFrame
     {
       hmmerMenu.setEnabled(true);
     }
+    hmmerMenu.addActionListener(new ActionListener()
+    {
 
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        hmmerMenu_actionPerformed(e);
+      }
+    });
     JMenuItem selectAllSequenceMenuItem = new JMenuItem(
             MessageManager.getString("action.select_all"));
     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit
@@ -1946,6 +1954,11 @@ public class GAlignFrame extends JInternalFrame
     // selectMenu.add(listenToViewSelections);
   }
 
+  public void hmmerMenu_actionPerformed(ActionEvent e)
+  {
+
+  }
+
   /**
    * Constructs the entries on the Colour menu (but does not add them to the
    * menu).
index aa3a22d..0eb13df 100644 (file)
@@ -36,7 +36,6 @@ import jalview.datamodel.Annotation;
 import jalview.datamodel.CigarArray;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.HiddenColumns;
-import jalview.datamodel.HiddenMarkovModel;
 import jalview.datamodel.HiddenSequences;
 import jalview.datamodel.ProfileI;
 import jalview.datamodel.Profiles;
@@ -100,7 +99,6 @@ public abstract class AlignmentViewport
 
   protected Deque<CommandI> redoList = new ArrayDeque<>();
 
-  HiddenMarkovModel selectedHMM;
 
   /**
    * alignment displayed in the viewport. Please use get/setter
@@ -3057,19 +3055,6 @@ public abstract class AlignmentViewport
    * 
    * @return
    */
-  public HiddenMarkovModel getSelectedHMM()
-  {
-    return selectedHMM;
-  }
 
-  /**
-   * Sets the selected hidden Markov model
-   * 
-   * @param selectedHMM
-   */
-  public void setSelectedHMM(HiddenMarkovModel selectedHMM)
-  {
-    this.selectedHMM = selectedHMM;
-  }
 
 }