package jalview.hmmer;
+import jalview.bin.Cache;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.util.MessageManager;
import jalview.ws.params.ArgumentI;
import jalview.ws.params.simple.BooleanOption;
+import jalview.ws.params.simple.Option;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class HMMSearch extends HmmerCommand
{
+ private static final String PARAMNAME_NO_OF_RESULTS = MessageManager.getString("label.number_of_results");
+
static final String HMMSEARCH = "hmmsearch";
boolean realign = false;
@Override
public void run()
{
- HiddenMarkovModel hmm = af.getSelectedHMM();
+ HiddenMarkovModel hmm = getHmmProfile();
if (hmm == null)
{
- JOptionPane.showMessageDialog(af,
- MessageManager.getString("warn.no_selected_hmm"));
+ // shouldn't happen if we got this far
+ Cache.log.error("Error: no hmm for hmmsearch");
return;
}
- SequenceI hmmSeq = af.getSelectedHMMSequence();
+ SequenceI hmmSeq = hmm.getConsensusSequence();// af.getSelectedHMMSequence();
long msgId = System.currentTimeMillis();
af.setProgressBar(MessageManager.getString("status.running_hmmsearch"),
msgId);
boolean ran = runCommand(searchOutputFile, hitsAlignmentFile, hmmFile);
if (!ran)
{
- JvOptionPane.showInternalMessageDialog(af,
- MessageManager.getString("warn.hmmsearch_failed"));
+ JvOptionPane.showInternalMessageDialog(af, MessageManager
+ .formatMessage("warn.command_failed", "hmmsearch"));
return;
}
{
/*
* no external database specified for search, so
- * export current alignment as 'database' to search
+ * export current alignment as 'database' to search,
+ * excluding any HMM consensus sequences it contains
*/
databaseFile = FileUtils.createTempFile("database", ".sto");
AlignmentI al = af.getViewport().getAlignment();
AlignmentI copy = new Alignment(al);
- SequenceI hmms = copy.getHmmConsensus();
- if (hmms != null)
+ List<SequenceI> hmms = copy.getHmmSequences();
+ for (SequenceI hmmSeq : hmms)
{
- copy.deleteSequence(hmms);
+ copy.deleteSequence(hmmSeq);
}
exportStockholm(copy.getSequencesArray(), databaseFile, null);
// StockholmFile stoFile = new StockholmFile(copy);
hmmAndSeqs[0] = hmmSeq;
System.arraycopy(seqs, 0, hmmAndSeqs, 1, seqCount);
- AlignmentI alignment = new Alignment(hmmAndSeqs);
- AlignFrame frame = new AlignFrame(alignment, 1, 1);
- frame.setSelectedHMMSequence(hmmSeq);
+ /*
+ * 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)
{
alignArgs.add(new BooleanOption(