import jalview.gui.SplitFrame;
import jalview.io.DataSourceType;
import jalview.io.StockholmFile;
+import jalview.util.FileUtils;
import jalview.util.MessageManager;
import jalview.viewmodel.seqfeatures.FeatureRendererSettings;
import jalview.ws.params.ArgumentI;
private final AlignmentI dataset;
- private AlignmentView msa;
-
/**
* Constructor for the HMMAlignThread
*
@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);
- prepareAlignment();
- SequenceI[][] subAlignments = msa.getVisibleContigs('-');
+
+ AlignmentView msa = af.gatherSequencesForAlignment();
+ SequenceI[][] subAlignments = msa.getVisibleContigs(alignment.getGapCharacter());
List<AlignmentOrder> allOrders = new ArrayList<>();
Hashtable sequencesHash = stashSequences(seqs);
try
{
- File modelFile = createTempFile("hmm", ".hmm");
- File alignmentFile = createTempFile("output", ".sto");
- File resultFile = createTempFile("input", ".sto");
+ File modelFile = FileUtils.createTempFile("hmm", ".hmm");
+ File alignmentFile = FileUtils.createTempFile("output", ".sto");
+ File resultFile = FileUtils.createTempFile("input", ".sto");
exportStockholm(seqs, alignmentFile.getAbsoluteFile(), null);
exportHmm(hmm, modelFile.getAbsoluteFile());
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;
}
job++;
}
- displayResults(allResults, allOrders);
+ String title = "hmmalign to " + hmm.getConsensusSequence().getName();
+ displayResults(allResults, allOrders, msa, title);
af.setProgressBar("", msgId);
}
* @throws IOException
*/
private boolean runCommand(File modelFile, File alignmentFile,
- File resultFile)
- throws IOException
+ File resultFile) throws IOException
{
String command = getCommandPath(HMMALIGN);
if (command == null)
}
}
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);
}
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);
}
/**
- * Gathers the sequences in preparation for the alignment.
- */
- private void prepareAlignment()
- {
- msa = af.gatherSequencesForAlignment();
- }
-
- /**
* Displays the results of all 'jobs' in a new frame
*
* @param allResults
*
* @param allOrders
+ * @param msa
+ * @param title
*/
private void displayResults(SequenceI[][] allResults,
- List<AlignmentOrder> allOrders)
+ List<AlignmentOrder> allOrders, AlignmentView msa, String title)
{
AlignmentOrder[] arrOrders = allOrders
.toArray(new AlignmentOrder[allOrders.size()]);
- Object[] newview = msa.getUpdatedView(allResults, arrOrders, '-');
+ Object[] newview = msa.getUpdatedView(allResults, arrOrders,
+ alignment.getGapCharacter());
SequenceI[] seqs = (SequenceI[]) newview[0];
HiddenColumns hidden = (HiddenColumns) newview[1];
Alignment al = new Alignment(seqs);
al.setDataset(dataset);
}
- displayInNewFrame(al, allOrders, hidden);
+ displayInNewFrame(al, allOrders, hidden, title);
}
/**
* run
* @param hidden
* Hidden columns in the previous alignment
+ * @param title
*/
private void displayInNewFrame(AlignmentI al,
- List<AlignmentOrder> alorders, HiddenColumns hidden)
+ List<AlignmentOrder> alorders, HiddenColumns hidden, String title)
{
AlignFrame alignFrame = new AlignFrame(al, hidden, AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
+ alignFrame.setTitle(title);
FeatureRendererSettings featureSettings = af.getFeatureRenderer()
.getSettings();