JAL-2629 add basic parameter adjustment to hmmsearch/align
authorTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Thu, 24 Aug 2017 09:20:28 +0000 (10:20 +0100)
committerTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Fri, 25 Aug 2017 16:20:54 +0000 (17:20 +0100)
13 files changed:
resources/lang/Messages.properties
src/jalview/gui/AlignFrame.java
src/jalview/gui/OptsAndParamsPage.java
src/jalview/gui/WsJobParameters.java
src/jalview/hmmer/HMMAlignThread.java
src/jalview/hmmer/HMMBuildThread.java
src/jalview/hmmer/HMMERParamStore.java [new file with mode: 0644]
src/jalview/hmmer/HMMERPreset.java [new file with mode: 0644]
src/jalview/hmmer/HMMSearchThread.java
src/jalview/jbgui/GAlignFrame.java
src/jalview/viewmodel/AlignmentViewport.java
src/jalview/ws/params/simple/DoubleParameter.java [new file with mode: 0644]
test/jalview/hmmer/HMMERTest.java

index 570c7e0..0749a23 100644 (file)
@@ -1331,6 +1331,7 @@ label.select_hmm = Select HMM
 warn.no_sequence_data = No sequence data found.
 label.hmmer = HMMER
 label.trim_termini = Trim Non-Matching Termini
+label.trim_termini_desc = If true, non-matching regions on either end of the resulting alignment are removed.
 label.no_of_sequences = Sequences Returned
 label.freq_alignment = Use Alignment Background Frequencies
 label.freq_uniprot = Use Uniprot Background Frequencies
@@ -1343,4 +1344,20 @@ warn.hmmbuild_failed = hmmbuild was not found.
 warn.align_failed = hmmalign was not found.
 label.invalid_folder = Invalid Folder
 label.folder_not_exists = HMMER binaries not found. \n Please enter the path to the HMMER binaries (if installed).
-label.hmmer_installed = HMMER installed
\ No newline at end of file
+label.hmmer_installed = HMMER installed
+label.hmmer_no_sequences_found = No sequences found.
+label.number_of_results = Number of Results to Return
+label.auto_align_seqs = Automatically Align Fetched Sequences
+label.use_accessions = Return Accessions
+label.seq_e_value = Sequence E-value Cutoff
+label.seq_score = Sequence Score Threshold
+label.dom_e_value = Domain E-value Cutoff
+label.dom_score = Domain Score Threshold
+label.number_of_results_desc = The maximum number of results that hmmsearch will return.
+label.auto_align_seqs_desc = If true, all fetched sequences will be aligned to the hidden Markov model with which the search was performed.
+label.use_accessions_desc = If true, the accession number of each sequence is returned, rather than that sequences name.
+label.seq_e_value_desc = The E-value cutoff for returned sequences.
+label.seq_score_desc = The score threshold for returned sequences.
+label.dom_e_value_desc = The E-value cutoff for returned domains.
+label.dom_score_desc = The score threshold for returned domains.
+label.not_enough_sequences = There are not enough sequences to run {0}
\ No newline at end of file
index abecd10..85e3db5 100644 (file)
@@ -65,6 +65,9 @@ import jalview.gui.ColourMenuHelper.ColourChangeListener;
 import jalview.gui.ViewSelectionMenu.ViewSetProvider;
 import jalview.hmmer.HMMAlignThread;
 import jalview.hmmer.HMMBuildThread;
+import jalview.hmmer.HMMERParamStore;
+import jalview.hmmer.HMMERPreset;
+import jalview.hmmer.HMMSearchThread;
 import jalview.io.AlignmentProperties;
 import jalview.io.AnnotationFile;
 import jalview.io.BioJsHTMLOutput;
@@ -97,6 +100,9 @@ import jalview.ws.DBRefFetcher.FetchFinishedListenerI;
 import jalview.ws.jws1.Discoverer;
 import jalview.ws.jws2.Jws2Discoverer;
 import jalview.ws.jws2.jabaws2.Jws2Instance;
+import jalview.ws.params.ArgumentI;
+import jalview.ws.params.ParamDatastoreI;
+import jalview.ws.params.WsParamSetI;
 import jalview.ws.seqfetcher.DbSourceProxy;
 
 import java.awt.BorderLayout;
@@ -141,6 +147,7 @@ import java.util.Vector;
 
 import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JEditorPane;
+import javax.swing.JFrame;
 import javax.swing.JInternalFrame;
 import javax.swing.JLayeredPane;
 import javax.swing.JMenu;
@@ -1029,36 +1036,132 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   }
 
   @Override
-  public void hmmBuild_actionPerformed(ActionEvent e)
+  public void hmmBuildSettings_actionPerformed(ActionEvent e)
           throws IOException, InterruptedException
   {
-    new Thread(new HMMBuildThread(this)).start();
+    if (!(alignmentIsSufficient(1)))
+    {
+      return;
+    }
+    WsParamSetI set = new HMMERPreset();
+    List<ArgumentI> args = new ArrayList<>();
+    ParamDatastoreI store = new HMMERParamStore("hmmalign");
+    WsJobParameters params = new WsJobParameters(new JFrame(), store, set,
+            args);
+    params.showRunDialog();
+    new Thread(new HMMBuildThread(this, params.getJobParams())).start();
     alignPanel.repaint();
 
   }
 
   @Override
-  public void hmmAlign_actionPerformed(ActionEvent e)
+  public void hmmAlignSettings_actionPerformed(ActionEvent e)
           throws IOException, InterruptedException
   {
-    new Thread(new HMMAlignThread(this, true)).start();
+    if (!(checkForHMM() && alignmentIsSufficient(2)))
+    {
+      return;
+    }
+    WsParamSetI set = new HMMERPreset();
+    List<ArgumentI> args = new ArrayList<>();
+    ParamDatastoreI store = new HMMERParamStore("hmmalign");
+    WsJobParameters params = new WsJobParameters(new JFrame(), store, set,
+            args);
+    params.showRunDialog();
+    new Thread(new HMMAlignThread(this, true, params.getJobParams()))
+            .start();
     alignPanel.repaint();
   }
 
   @Override
-  public void changeHMMERLocation_actionPerformed(ActionEvent e)
+  public void hmmSearchSettings_actionPerformed(ActionEvent e)
   {
-    String location = JOptionPane.showInputDialog(
-            MessageManager.getString("label.enter_location"));
-    Cache.setProperty(Preferences.HMMER_PATH, location);
+    if (!checkForHMM())
+    {
+      return;
+    }
+    WsParamSetI set = new HMMERPreset();
+    List<ArgumentI> args = new ArrayList<>();
+    ParamDatastoreI store = new HMMERParamStore("hmmsearch");
+    WsJobParameters params = new WsJobParameters(new JFrame(), store, set,
+            args);
+    params.showRunDialog();
+    new Thread(new HMMSearchThread(this, true, params.getJobParams()))
+            .start();
+    alignPanel.repaint();
+  }
+
+  @Override
+  public void hmmBuildRun_actionPerformed(ActionEvent e)
+          throws IOException, InterruptedException
+  {
+    if (!alignmentIsSufficient(1))
+    {
+      return;
+    }
+    new Thread(new HMMBuildThread(this, null)).start();
+    alignPanel.repaint();
+
+  }
+
+  @Override
+  public void hmmAlignRun_actionPerformed(ActionEvent e)
+          throws IOException, InterruptedException
+  {
+    if (!(checkForHMM() && alignmentIsSufficient(2)))
+    {
+      return;
+    }
+    new Thread(new HMMAlignThread(this, true, null))
+            .start();
+    alignPanel.repaint();
   }
 
   @Override
-  public void hmmSearch_actionPerformed(ActionEvent e)
+  public void hmmSearchRun_actionPerformed(ActionEvent e)
   {
+    if (!checkForHMM())
+    {
+      return;
+    }
+    new Thread(new HMMSearchThread(this, true, null))
+            .start();
     alignPanel.repaint();
   }
 
+  /**
+   * Checks if the frame has a selected hidden Markov model
+   * 
+   * @return
+   */
+  private boolean checkForHMM()
+  {
+    if (getSelectedHMM() == null)
+    {
+      JOptionPane.showMessageDialog(this,
+              MessageManager.getString("warn.no_selected_hmm"));
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * Checks if the alignment contains the required number of sequences.
+   * 
+   * @param required
+   * @return
+   */
+  public boolean alignmentIsSufficient(int required)
+  {
+    if (getViewport().getAlignment().getSequences().size() < required)
+    {
+      JOptionPane.showMessageDialog(this,
+              MessageManager.getString("warn.not_enough_sequences"));
+      return false;
+    }
+    return true;
+  }
+
   @Override
   public void reload_actionPerformed(ActionEvent e)
   {
index 59e7049..424d561 100644 (file)
@@ -600,7 +600,7 @@ public class OptsAndParamsPage
     public String formatDouble(Double value)
     {
       String string = "";
-      if (value < 0.0000001)
+      if (value < 0.0001)
       {
         string = String.format("%3.3e", value);
       }
index 10798f6..addda39 100644 (file)
@@ -69,14 +69,13 @@ import javax.swing.border.TitledBorder;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 
-import net.miginfocom.swing.MigLayout;
-
 import compbio.metadata.Argument;
 import compbio.metadata.Option;
 import compbio.metadata.Parameter;
 import compbio.metadata.Preset;
 import compbio.metadata.PresetManager;
 import compbio.metadata.RunnerConfig;
+import net.miginfocom.swing.MigLayout;
 
 /**
  * job parameter editing/browsing dialog box. User can browse existing settings
@@ -159,6 +158,21 @@ public class WsJobParameters extends JPanel implements ItemListener,
     this(service, null);
   }
 
+  public WsJobParameters(JFrame parent, ParamDatastoreI store,
+          WsParamSetI preset,
+          List<ArgumentI> args)
+  {
+    super();
+    jbInit();
+    this.paramStore = store;
+    this.service = null;
+    // argSetModified(false);
+    // populate parameter table
+    init(preset, args);
+    // display in new JFrame attached to parent.
+    validate();
+  }
+
   public WsJobParameters(Jws2Instance service, WsParamSetI preset)
   {
     this(null, service, preset, null);
@@ -217,10 +231,13 @@ public class WsJobParameters extends JPanel implements ItemListener,
   {
 
     frame = new JDialog(Desktop.instance, true);
+    if (service != null)
+    {
+      frame.setTitle(MessageManager.formatMessage("label.edit_params_for",
+              new String[]
+      { service.getActionText() }));
+    }
 
-    frame.setTitle(MessageManager.formatMessage("label.edit_params_for",
-            new String[]
-            { service.getActionText() }));
     Rectangle deskr = Desktop.instance.getBounds();
     Dimension pref = this.getPreferredSize();
     frame.setBounds(
@@ -541,6 +558,12 @@ public class WsJobParameters extends JPanel implements ItemListener,
                  // null;
     }
 
+    init(p, jobArgset);
+
+  }
+
+  void init(WsParamSetI p, List<ArgumentI> jobArgset)
+  {
     Hashtable exnames = new Hashtable();
     for (int i = 0, iSize = setName.getItemCount(); i < iSize; i++)
     {
@@ -594,7 +617,6 @@ public class WsJobParameters extends JPanel implements ItemListener,
       }
     }
     settingDialog = false;
-
   }
 
   @SuppressWarnings("unchecked")
@@ -967,7 +989,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
     int p = 0;
     if (args.length > 0)
     {
-      Vector<String> services = new Vector<String>();
+      Vector<String> services = new Vector<>();
       services.addElement(args[p++]);
       Jws2Discoverer.getDiscoverer().setServiceUrls(services);
     }
index 1c2450c..532271b 100644 (file)
@@ -17,6 +17,7 @@ import jalview.io.DataSourceType;
 import jalview.io.StockholmFile;
 import jalview.util.MessageManager;
 import jalview.viewmodel.seqfeatures.FeatureRendererSettings;
+import jalview.ws.params.ArgumentI;
 
 import java.io.File;
 import java.io.IOException;
@@ -25,7 +26,6 @@ import java.util.List;
 import java.util.Map;
 
 import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
 
 public class HMMAlignThread implements Runnable
 {
@@ -52,6 +52,8 @@ public class HMMAlignThread implements Runnable
 
   HiddenMarkovModel hmm;
 
+  List<ArgumentI> args;
+
   boolean newFrame;
 
   long barID;
@@ -75,7 +77,8 @@ public class HMMAlignThread implements Runnable
    * @param af
    * @param createNewFrame
    */
-  public HMMAlignThread(AlignFrame af, boolean createNewFrame)
+  public HMMAlignThread(AlignFrame af, boolean createNewFrame,
+          List<ArgumentI> args)
   {
     this.af = af;
     alignment = af.getViewport().getAlignment();
@@ -85,6 +88,7 @@ public class HMMAlignThread implements Runnable
     }
     newFrame = createNewFrame;
     featureSettings = af.getFeatureRenderer().getSettings();
+    this.args = args;
   }
 
   /**
@@ -96,71 +100,60 @@ public class HMMAlignThread implements Runnable
   @Override
   public void run()
   {
-    if (af.getSelectedHMM() == null)
-    {
-      JOptionPane.showMessageDialog(af,
-              MessageManager.getString("warn.no_selected_hmm"));
-      return;
-    }
-    else
-    {
-      hmm = af.getSelectedHMM();
-    }
+
+    hmm = af.getSelectedHMM();
+
     barID = System.currentTimeMillis();
     af.setProgressBar(MessageManager.getString("status.running_hmmalign"),
             barID);
     cmds.HMMERFOLDER = Cache.getProperty(Preferences.HMMER_PATH);
-
-    // if (!alignment.isAligned())
-    // {
-    // alignment.padGaps();
-    // }
-    prepareAlignment();
-    SequenceI[][] subAlignments = msa.getVisibleContigs('-');
-    allOrders = new ArrayList<>();
-    allResults = new SequenceI[subAlignments.length][];
-    int job = 0;
-    for (SequenceI[] seqs : subAlignments)
-    {
-      cmds.uniquifySequences(seqs);
-      try
-      {
-        createTemporaryFiles();
-      } catch (IOException e2)
+      prepareAlignment();
+      SequenceI[][] subAlignments = msa.getVisibleContigs('-');
+      allOrders = new ArrayList<>();
+      allResults = new SequenceI[subAlignments.length][];
+      int job = 0;
+      for (SequenceI[] seqs : subAlignments)
       {
-        e2.printStackTrace();
-      }
-      try
-      {
-        cmds.exportData(seqs, outTemp.getAbsoluteFile(), hmm,
-                hmmTemp.getAbsoluteFile());
-      } catch (IOException e1)
-      {
-        e1.printStackTrace();
-      }
-      try
-      {
-        boolean ran = runCommand();
-        if (!ran)
+        cmds.uniquifySequences(seqs);
+        try
+        {
+          createTemporaryFiles();
+        } catch (IOException e2)
         {
-          JvOptionPane.showInternalMessageDialog(af,
-                  MessageManager.getString("warn.hmmalign_failed"));
-          return;
+          e2.printStackTrace();
         }
-      } catch (IOException | InterruptedException e)
-      {
-        e.printStackTrace();
-      }
-      try
-      {
-        importData(job);
-      } catch (IOException | InterruptedException e)
-      {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        try
+        {
+          cmds.exportData(seqs, outTemp.getAbsoluteFile(), hmm,
+                  hmmTemp.getAbsoluteFile());
+        } catch (IOException e1)
+        {
+          e1.printStackTrace();
+        }
+        try
+        {
+          boolean ran = runCommand();
+          if (!ran)
+          {
+            JvOptionPane.showInternalMessageDialog(af,
+                    MessageManager.getString("warn.hmmalign_failed"));
+            return;
+          }
+        } catch (IOException | InterruptedException e)
+        {
+          e.printStackTrace();
+        }
+        try
+        {
+          importData(job);
+        } catch (IOException | InterruptedException e)
+        {
+          // TODO Auto-generated catch block
+          e.printStackTrace();
+        }
+        job++;
       }
-      job++;
-    }
+
 
     displayResults(newFrame);
 
@@ -176,10 +169,16 @@ public class HMMAlignThread implements Runnable
    */
   private void createTemporaryFiles() throws IOException
   {
-    hmmTemp = File.createTempFile("hmm", ".hmm");
-    hmmTemp.deleteOnExit();
-    outTemp = File.createTempFile("output", ".sto");
-    outTemp.deleteOnExit();
+    if (hmmTemp == null)
+    {
+      hmmTemp = File.createTempFile("hmm", ".hmm");
+      hmmTemp.deleteOnExit();
+    }
+    if (outTemp == null)
+    {
+      outTemp = File.createTempFile("output", ".sto");
+      outTemp.deleteOnExit();
+    }
     inputTemp = File.createTempFile("input", ".sto");
     inputTemp.deleteOnExit();
   }
@@ -210,15 +209,17 @@ public class HMMAlignThread implements Runnable
     {
       command += cmds.ALLCOL;
     }
-    boolean trim = true;
-    String bool = Cache.getProperty("TRIM_TERMINI");
-    if ("false".equals(bool))
+    if (args != null)
     {
-      trim = false;
-    }
-    if (trim)
-    {
-      command += cmds.TRIM;
+      for (ArgumentI arg : args)
+      {
+        String name = arg.getName();
+        switch (name)
+        {
+        case "Trim Non-Matching Termini":
+          command += "--trim";
+        }
+      }
     }
     command += " -o " + inputTemp.getAbsolutePath() + cmds.SPACE
             + hmmTemp.getAbsolutePath() + cmds.SPACE
@@ -228,7 +229,7 @@ public class HMMAlignThread implements Runnable
 
   /**
    * Imports the data from the temporary file to which the output of hmmalign is
-   * directed.
+   * directed. this is used for an internal job.
    * 
    * @param index
    *          The index of the 'job' (or region of an alignment).
index 8bdb008..eb9fc2a 100644 (file)
@@ -16,6 +16,7 @@ import jalview.io.FileLoader;
 import jalview.io.FileParse;
 import jalview.io.HMMFile;
 import jalview.util.MessageManager;
+import jalview.ws.params.ArgumentI;
 
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -33,6 +34,8 @@ public class HMMBuildThread implements Runnable
   AlignmentI alignment;
   SequenceGroup group;
 
+  List<ArgumentI> params;
+
 
   boolean forGroup = false;
 
@@ -53,7 +56,7 @@ public class HMMBuildThread implements Runnable
     forGroup = false;
   }
 
-  public HMMBuildThread(AlignFrame af)
+  public HMMBuildThread(AlignFrame af, List<ArgumentI> args)
   {
     this.af = af;
     if (af.getViewport().getSelectionGroup() != null)
@@ -63,6 +66,7 @@ public class HMMBuildThread implements Runnable
     }
     viewport = af.getViewport();
     alignment = viewport.getAlignment();
+    params = args;
 
   }
 
@@ -215,7 +219,8 @@ public class HMMBuildThread implements Runnable
       String name = null;
       if (af != null)
       {
-        name = af.getTitle();
+        // name = af.getTitle();
+        name = "replace";
       }
       if (name == null || name == "" || name == " " || name == "  ")
       {
diff --git a/src/jalview/hmmer/HMMERParamStore.java b/src/jalview/hmmer/HMMERParamStore.java
new file mode 100644 (file)
index 0000000..1bfc72f
--- /dev/null
@@ -0,0 +1,156 @@
+package jalview.hmmer;
+
+
+import jalview.util.MessageManager;
+import jalview.ws.params.ArgumentI;
+import jalview.ws.params.ParamDatastoreI;
+import jalview.ws.params.WsParamSetI;
+import jalview.ws.params.simple.BooleanOption;
+import jalview.ws.params.simple.IntegerParameter;
+import jalview.ws.params.simple.LogarithmicParameter;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class HMMERParamStore implements ParamDatastoreI
+{
+
+  String name;
+
+  List<WsParamSetI> presets = new ArrayList<>();
+
+  public HMMERParamStore(String name)
+  {
+    this.name = name;
+  }
+
+  @Override
+  public List<WsParamSetI> getPresets()
+  {
+    // TODO Auto-generated method stub
+    return presets;
+  }
+
+  @Override
+  public WsParamSetI getPreset(String name)
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public List<ArgumentI> getServiceParameters()
+  {
+    List<ArgumentI> args = new ArrayList<>();
+    if ("hmmsearch".equals(name))
+    {
+      args.add(new IntegerParameter(
+              MessageManager.getString("label.number_of_results"),
+              MessageManager
+                      .getString("label.number_of_results_desc"),
+              true, 100, 0, 100000));
+      args.add(new BooleanOption(
+              MessageManager.getString("label.auto_align_seqs"),
+              MessageManager.getString("label.auto_align_seqs_desc"),
+              false, false, true, null));
+      args.add(new BooleanOption(
+              MessageManager.getString("label.use_accessions"),
+              MessageManager.getString("label.use_accessions_desc"),
+              false, false, true, null));
+      args.add(new BooleanOption(
+              MessageManager.getString("label.trim_termini"),
+              MessageManager.getString("label.trim_termini_desc"), false,
+              false, true, null));
+      args.add(new LogarithmicParameter(
+              MessageManager.getString("label.seq_e_value"),
+              MessageManager.getString("label.seq_e_value_desc"), false,
+              0.001d, -63d, 9d, 4d));
+      /*
+      args.add(new DoubleParameter(
+              MessageManager.getString("label.seq_score"),
+              MessageManager.getString("label.seq_score_desc"), false,
+              0d, 0d, 10000d));
+         */
+      args.add(new LogarithmicParameter(
+              MessageManager.getString("label.dom_e_value_desc"),
+              MessageManager.getString("label.dom_e_value_desc"), false,
+              0.001d, -63d, 9d, 4d));
+      /*
+      args.add(new DoubleParameter(
+              MessageManager.getString("label.dom_score"),
+              MessageManager.getString("label.dom_score_desc"), false, 0d,
+              0d,
+              10000d));
+              */
+    }
+    if ("hmmalign".equals(name))
+    {
+      args.add(new BooleanOption(
+              MessageManager.getString("label.trim_termini"),
+              MessageManager.getString(
+                      "label.trim_termini = Trim Non-Matching Termini_desc"),
+              false, false, true, null));
+
+    }
+    if ("hmmbuild".equals(name))
+    {
+      args.add(new BooleanOption(
+              MessageManager.getString("label.trim_termini"),
+              MessageManager.getString(
+                      "label.trim_termini = Trim Non-Matching Termini_desc"),
+              false, false, true, null));
+
+    }
+    return args;
+  }
+
+  @Override
+  public boolean presetExists(String name)
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  @Override
+  public void deletePreset(String name)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
+  public void storePreset(String presetName, String text,
+          List<ArgumentI> jobParams)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
+  public void updatePreset(String oldName, String presetName, String text,
+          List<ArgumentI> jobParams)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
+  public WsParamSetI parseServiceParameterFile(String name,
+          String description, String[] serviceURL, String parameters)
+          throws IOException
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public String generateServiceParameterFile(WsParamSetI pset)
+          throws IOException
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+}
diff --git a/src/jalview/hmmer/HMMERPreset.java b/src/jalview/hmmer/HMMERPreset.java
new file mode 100644 (file)
index 0000000..b7cd29a
--- /dev/null
@@ -0,0 +1,67 @@
+package jalview.hmmer;
+
+import jalview.ws.params.ArgumentI;
+import jalview.ws.params.WsParamSetI;
+
+import java.util.List;
+
+public class HMMERPreset implements WsParamSetI
+{
+
+  @Override
+  public String getName()
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public String getDescription()
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public String[] getApplicableUrls()
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public String getSourceFile()
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public void setSourceFile(String newfile)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
+  public boolean isModifiable()
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  @Override
+  public List<ArgumentI> getArguments()
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public void setArguments(List<ArgumentI> args)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+}
index 0052dc2..c723d2f 100644 (file)
@@ -15,9 +15,11 @@ import jalview.io.StockholmFile;
 import jalview.util.MessageManager;
 import jalview.viewmodel.seqfeatures.FeatureRendererSettings;
 import jalview.ws.params.ArgumentI;
+import jalview.ws.params.simple.BooleanOption;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.swing.JOptionPane;
@@ -38,7 +40,9 @@ public class HMMSearchThread implements Runnable
 
   HiddenMarkovModel hmm;
 
-  boolean newFrame;
+  boolean newFrame, realign = false, trim = false;
+
+  Integer numberOfSequences = null;
 
   long barID;
 
@@ -54,6 +58,8 @@ public class HMMSearchThread implements Runnable
 
   File databaseFile = null;
 
+
+
   SequenceI[] seqs;
 
 
@@ -175,10 +181,55 @@ public class HMMSearchThread implements Runnable
         }
       }
     }
+
     String command = cmds.HMMERFOLDER + "/hmmsearch -o "
             + inputTableTemp.getAbsolutePath() + " -A "
-            + inputAlignmentTemp.getAbsolutePath() + cmds.SPACE
-            + hmmTemp.getAbsolutePath() + cmds.SPACE
+            + inputAlignmentTemp.getAbsolutePath() + cmds.SPACE;
+    if (params != null)
+    {
+      for (ArgumentI arg : params)
+      {
+        String name = arg.getName();
+        switch (name)
+        {
+        case "Number of Results to Return":
+          numberOfSequences = Integer.parseInt(arg.getValue());
+          break;
+        case "Automatically Align Fetched Sequences":
+          if ("Automatically Align Fetched Sequences"
+                  .equals(arg.getValue()))
+          {
+            realign = true;
+          }
+          break;
+        case "Return Accessions":
+          if ("Return Accessions".equals(arg.getValue()))
+          {
+            command += "--acc ";
+          }
+          break;
+        case "Sequence E-value Cutoff":
+          command += "--incE " + arg.getValue() + cmds.SPACE;
+          break;
+        case "Sequence Score Threshold":
+          command += "-incT " + arg.getValue() + cmds.SPACE;
+          break;
+        case "Domain E-value Threshold":
+          command += "--incdomE " + arg.getValue() + cmds.SPACE;
+          break;
+        case "Domain Score Threshold":
+          command += "--incdomT " + arg.getValue() + cmds.SPACE;
+          break;
+        case "Trim Non-Matching Termini":
+          trim = true;
+
+        }
+        
+
+      }
+    }
+
+    command += hmmTemp.getAbsolutePath() + cmds.SPACE
             + databaseFile.getAbsolutePath();
     return cmds.runCommand(command);
   }
@@ -195,23 +246,49 @@ public class HMMSearchThread implements Runnable
 
     readTable();
 
-    SequenceI[] hmmAndSeqs = new SequenceI[seqs.length + 1];
+    SequenceI[] hmmAndSeqs;
+    if (numberOfSequences != null && numberOfSequences < seqs.length)
+    {
+      hmmAndSeqs = new SequenceI[numberOfSequences + 1];
+    }
+    else
+    {
+      hmmAndSeqs = new SequenceI[seqs.length + 1];
+    }
+
     AlignmentAnnotation[] list = hmmSeq.getAnnotation();
     for (AlignmentAnnotation annot : list)
     {
-      if ("HMM annotation".equals(annot.getCalcId()))
+      if ("HMM".equals(annot.getCalcId()))
       {
         hmmSeq.removeAlignmentAnnotation(annot);
       }
     }
     hmmSeq.setHasInfo(false);
     hmmAndSeqs[0] = hmmSeq;
-    System.arraycopy(seqs, 0, hmmAndSeqs, 1, seqs.length);
+
+    if (numberOfSequences != null && seqs.length > numberOfSequences)
+    {
+      System.arraycopy(seqs, 0, hmmAndSeqs, 1, numberOfSequences);
+    }
+    else
+    {
+      System.arraycopy(seqs, 0, hmmAndSeqs, 1, seqs.length);
+    }
+
     AlignmentI alignment = new Alignment(hmmAndSeqs);
     AlignFrame frame = new AlignFrame(alignment, 1, 1);
     frame.setSelectedHMMSequence(hmmSeq);
     frame.getViewport().initInformation();
-    HMMAlignThread hmmalign = new HMMAlignThread(frame, true);
+    List<ArgumentI> alignArgs = new ArrayList<>();
+    if (trim)
+    {
+      alignArgs.add(new BooleanOption(
+              MessageManager.getString("label.trim_termini"),
+              MessageManager.getString("label.trim_termini_desc"), true,
+              true, true, null));
+    }
+    HMMAlignThread hmmalign = new HMMAlignThread(frame, true, alignArgs);
     hmmalign.hmmalignWaitTillComplete();
     frame = null;
     hmmTemp.delete();
index eef6ee8..cf6c487 100755 (executable)
@@ -70,11 +70,23 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenu hmmerMenu = new JMenu();
 
-  protected JMenuItem hmmAlign = new JMenuItem();
+  protected JMenu hmmAlign = new JMenu();
 
-  protected JMenuItem hmmSearch = new JMenuItem();
+  protected JMenuItem hmmAlignRun = new JMenuItem();
 
-  protected JMenuItem hmmBuild = new JCheckBoxMenuItem();
+  protected JMenuItem hmmAlignSettings = new JMenuItem();
+
+  protected JMenu hmmSearch = new JMenu();
+
+  protected JMenuItem hmmSearchRun = new JMenuItem();
+
+  protected JMenuItem hmmSearchSettings = new JMenuItem();
+
+  protected JMenu hmmBuild = new JMenu();
+
+  protected JMenuItem hmmBuildRun = new JMenuItem();
+
+  protected JMenuItem hmmBuildSettings = new JMenuItem();
 
   protected JMenuItem webServiceNoServices;
 
@@ -1733,49 +1745,105 @@ public class GAlignFrame extends JInternalFrame
         selectHighlightedColumns_actionPerformed(actionEvent);
       }
     };
-    hmmBuild.setText(MessageManager.getString("label.hmmbuild"));
-    hmmBuild.addActionListener(new ActionListener()
+    hmmBuildRun.setText(MessageManager.formatMessage(
+            "label.action_with_default_settings", "hmmbuild"));
+    hmmBuildRun.addActionListener(new ActionListener()
     {
-  
+
       @Override
       public void actionPerformed(ActionEvent e)
       {
         try
         {
-          hmmBuild_actionPerformed(e);
-        } catch (IOException e1)
+          hmmBuildRun_actionPerformed(e);
+        } catch (IOException | InterruptedException e1)
         {
           // TODO Auto-generated catch block
           e1.printStackTrace();
-        } catch (InterruptedException e1)
+        }
+      }
+
+    });
+    hmmBuildSettings.setText(
+            MessageManager.getString("label.edit_settings_and_run"));
+    hmmBuildSettings.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        try
+        {
+          hmmBuildSettings_actionPerformed(e);
+        } catch (IOException | InterruptedException e1)
         {
           // TODO Auto-generated catch block
           e1.printStackTrace();
         }
       }
-  
+
     });
-    hmmAlign.setText(MessageManager.getString("label.hmmalign"));
-    hmmAlign.addActionListener(new ActionListener()
+    hmmAlignRun.setText(MessageManager.formatMessage(
+            "label.action_with_default_settings", "hmmalign"));
+    hmmAlignRun.addActionListener(new ActionListener()
     {
-  
+
       @Override
       public void actionPerformed(ActionEvent e)
       {
         try
         {
-          hmmAlign_actionPerformed(e);
-        } catch (IOException e1)
+          hmmAlignRun_actionPerformed(e);
+        } catch (IOException | InterruptedException e1)
         {
           // TODO Auto-generated catch block
           e1.printStackTrace();
-        } catch (InterruptedException e1)
+        }
+      }
+
+    });
+    hmmAlignSettings.setText(
+            MessageManager.getString("label.edit_settings_and_run"));
+    hmmAlignSettings.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        try
+        {
+          hmmAlignSettings_actionPerformed(e);
+        } catch (IOException | InterruptedException e1)
         {
           // TODO Auto-generated catch block
           e1.printStackTrace();
         }
       }
-  
+
+    });
+    hmmSearchRun.setText(MessageManager.formatMessage(
+            "label.action_with_default_settings", "hmmsearch"));
+    hmmSearchRun.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        hmmSearchRun_actionPerformed(e);
+      }
+
+    });
+    hmmSearchSettings.setText(
+            MessageManager.getString("label.edit_settings_and_run"));
+    hmmSearchSettings.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        hmmSearchSettings_actionPerformed(e);
+      }
+
     });
     selectHighlighted.addActionListener(al);
     JMenu tooltipSettingsMenu = new JMenu(
@@ -1968,9 +2036,27 @@ public class GAlignFrame extends JInternalFrame
    */
   protected void initHMMERMenu()
   {
-    hmmAlign = new JMenuItem(MessageManager.getString("label.hmmalign"));
-    hmmBuild = new JMenuItem(MessageManager.getString("label.hmmbuild"));
-    hmmSearch = new JMenuItem(MessageManager.getString("label.hmmsearch"));
+    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(
+            MessageManager.getString("label.edit_settings_and_run"));
+    hmmBuildRun = new JMenuItem(MessageManager.formatMessage(
+            "label.action_with_default_settings", "hmmbuild"));
+    hmmBuild.add(hmmBuildSettings);
+    hmmBuild.add(hmmBuildRun);
+    hmmSearch = new JMenu(MessageManager.getString("label.hmmsearch"));
+    hmmSearchSettings = new JMenuItem(
+            MessageManager.getString("label.edit_settings_and_run"));
+    hmmSearchRun = new JMenuItem(MessageManager.formatMessage(
+            "label.action_with_default_settings", "hmmsearch"));
+    hmmSearch.add(hmmSearchSettings);
+    hmmSearch.add(hmmSearchRun);
   }
 
   /**
@@ -2457,25 +2543,31 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void autoAlignSeqs_actionPerformed(boolean selected)
+  protected void hmmBuildRun_actionPerformed(ActionEvent e)
+          throws IOException, InterruptedException
   {
   }
 
-  protected void hmmAlign_actionPerformed(ActionEvent e)
-          throws IOException, InterruptedException
+  protected void hmmSearchRun_actionPerformed(ActionEvent e)
   {
   }
 
-  protected void changeHMMERLocation_actionPerformed(ActionEvent e)
+  protected void hmmAlignRun_actionPerformed(ActionEvent e)
+          throws IOException, InterruptedException
   {
   }
 
-  protected void hmmBuild_actionPerformed(ActionEvent e)
+  protected void hmmBuildSettings_actionPerformed(ActionEvent e)
           throws IOException, InterruptedException
   {
   }
 
-  protected void hmmSearch_actionPerformed(ActionEvent e)
+  protected void hmmSearchSettings_actionPerformed(ActionEvent e)
+  {
+  }
+
+  protected void hmmAlignSettings_actionPerformed(ActionEvent e)
+          throws IOException, InterruptedException
   {
   }
 
index 0ec07c0..a4b494a 100644 (file)
@@ -2156,7 +2156,7 @@ public abstract class AlignmentViewport
         information.hasText = true;
         information.autoCalculated = false;
         information.sequenceRef = seq;
-        information.setCalcId("HMM annotation");
+        information.setCalcId("HMM");
         this.information.add(information);
         hinformation.add(new Profiles(new ProfileI[1]));
         alignment.addAnnotation(information);
diff --git a/src/jalview/ws/params/simple/DoubleParameter.java b/src/jalview/ws/params/simple/DoubleParameter.java
new file mode 100644 (file)
index 0000000..d6ccf46
--- /dev/null
@@ -0,0 +1,89 @@
+package jalview.ws.params.simple;
+
+import jalview.ws.params.ParameterI;
+import jalview.ws.params.ValueConstrainI;
+
+/**
+ * 
+ * @author TZVanaalten
+ *
+ */
+public class DoubleParameter extends Option implements ParameterI
+{
+  Double defval;
+
+  Double min, max;
+
+  @Override
+  public ValueConstrainI getValidValue()
+  {
+    return new ValueConstrainI()
+    {
+
+      @Override
+      public ValueType getType()
+      {
+        return ValueType.Double;
+      }
+
+      @Override
+      public Number getMin()
+      {
+        if (min < max)
+        {
+          return min;
+        }
+        else
+        {
+          return null;
+        }
+      }
+
+      @Override
+      public Number getMax()
+      {
+        if (min < max)
+        {
+          return max;
+        }
+        else
+        {
+          return null;
+        }
+      }
+    };
+  }
+
+  public DoubleParameter(DoubleParameter parm)
+  {
+    super(parm);
+    max = parm.max;
+    min = parm.min;
+  }
+
+  public DoubleParameter(String name, String description, boolean required,
+          Double defValue, Double min, Double max)
+  {
+    super(name, description, required, String.valueOf(defValue), null, null,
+            null);
+    defval = defValue;
+    this.min = min;
+    this.max = max;
+  }
+
+  public DoubleParameter(String name, String description, boolean required,
+          Double defValue, Double value, Double min, Double max)
+  {
+    super(name, description, required, String.valueOf(defValue),
+            String.valueOf(value), null, null);
+    defval = defValue;
+    this.min = min;
+    this.max = max;
+  }
+
+  @Override
+  public DoubleParameter copy()
+  {
+    return new DoubleParameter(this);
+  }
+}
index 17ce2cf..7707dca 100644 (file)
@@ -14,9 +14,11 @@ import jalview.gui.Desktop;
 import jalview.io.DataSourceType;
 import jalview.io.FastaFile;
 import jalview.io.FileParse;
+import jalview.ws.params.ArgumentI;
 
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.testng.annotations.AfterClass;
@@ -60,7 +62,8 @@ public class HMMERTest {
     AlignmentI al = new Alignment(seqs);
     frame = new AlignFrame(al, 150, 20);
 
-    HMMBuildThread thread = new HMMBuildThread(frame);
+    HMMBuildThread thread = new HMMBuildThread(frame,
+            new ArrayList<ArgumentI>());
     thread.hmmbuildWaitTillComplete();
 
     SequenceI seq = frame.getViewport().getAlignment().getSequenceAt(0);
@@ -80,7 +83,8 @@ public class HMMERTest {
   @Test(priority = 1)
   public void testHMMAlign() throws MalformedURLException, IOException
   {
-    HMMAlignThread thread = new HMMAlignThread(frame, true);
+    HMMAlignThread thread = new HMMAlignThread(frame, true,
+            new ArrayList<ArgumentI>());
     try
     {
       thread.hmmalignWaitTillComplete();