JAL-3899 Update usages of uniquify and deuniquify.
[jalview.git] / src / jalview / hmmer / HMMAlign.java
index befdc55..dd85c74 100644 (file)
@@ -1,6 +1,7 @@
 package jalview.hmmer;
 
 import jalview.analysis.AlignmentSorter;
+import jalview.analysis.SeqsetUtils.SequenceInfo;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentOrder;
@@ -24,6 +25,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.List;
+import java.util.Map;
 
 import javax.swing.JInternalFrame;
 
@@ -31,8 +33,6 @@ public class HMMAlign extends HmmerCommand
 {
   static final String HMMALIGN = "hmmalign";
 
-  static final String ARG_TRIM = "--trim";
-
   private final AlignmentI dataset;
 
   /**
@@ -64,17 +64,15 @@ public class HMMAlign extends HmmerCommand
   @Override
   public void run()
   {
-    HiddenMarkovModel hmm = af.getSelectedHMM();
-    if (hmm == null)
-    {
-      System.err.println("Can't run hmmalign as no HMM profile selected");
-      return;
-    }
+    HiddenMarkovModel hmm = getHmmProfile();
 
     long msgId = System.currentTimeMillis();
     af.setProgressBar(MessageManager.getString("status.running_hmmalign"),
             msgId);
 
+    // ensure alignments are the same length
+    alignment.padGaps();
+
     AlignmentView msa = af.gatherSequencesForAlignment();
     SequenceI[][] subAlignments = msa.getVisibleContigs(alignment.getGapCharacter());
 
@@ -84,7 +82,7 @@ public class HMMAlign extends HmmerCommand
     int job = 0;
     for (SequenceI[] seqs : subAlignments)
     {
-      Hashtable sequencesHash = stashSequences(seqs);
+      Map<String, SequenceInfo> sequencesHash = stashSequences(seqs);
       try
       {
         File modelFile = FileUtils.createTempFile("hmm", ".hmm");
@@ -97,8 +95,8 @@ public class HMMAlign extends HmmerCommand
         boolean ran = runCommand(modelFile, alignmentFile, resultFile);
         if (!ran)
         {
-          JvOptionPane.showInternalMessageDialog(af,
-                  MessageManager.getString("warn.hmmalign_failed"));
+          JvOptionPane.showInternalMessageDialog(af, MessageManager
+                  .formatMessage("warn.command_failed", "hmmalign"));
           return;
         }
 
@@ -157,9 +155,9 @@ public class HMMAlign extends HmmerCommand
       }
     }
     args.add("-o");
-    args.add(resultFile.getAbsolutePath());
-    args.add(modelFile.getAbsolutePath());
-    args.add(alignmentFile.getAbsolutePath());
+    args.add(getFilePath(resultFile, true));
+    args.add(getFilePath(modelFile, true));
+    args.add(getFilePath(alignmentFile, true));
     
     return runCommand(args);
   }
@@ -177,7 +175,7 @@ public class HMMAlign extends HmmerCommand
   private SequenceI[] importData(File resultFile,
           List<AlignmentOrder> allOrders) throws IOException
   {
-    StockholmFile file = new StockholmFile(resultFile.getAbsolutePath(),
+    StockholmFile file = new StockholmFile(getFilePath(resultFile, false),
             DataSourceType.FILE);
     SequenceI[] result = file.getSeqsAsArray();
     AlignmentOrder msaorder = new AlignmentOrder(result);
@@ -212,14 +210,6 @@ public class HMMAlign extends HmmerCommand
       al.setDataset(dataset);
     }
 
-    /*
-     * hack to ensure hmm set on alignment
-     */
-    if (al.getSequenceAt(0).isHMMConsensusSequence())
-    {
-      al.setHmmConsensus(al.getSequenceAt(0));
-    }
-
     displayInNewFrame(al, allOrders, hidden, title);
   }