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;
import java.util.Map;
import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
public class HMMAlignThread implements Runnable
{
HiddenMarkovModel hmm;
+ List<ArgumentI> args;
+
boolean newFrame;
long barID;
* @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();
}
newFrame = createNewFrame;
featureSettings = af.getFeatureRenderer().getSettings();
+ this.args = args;
}
/**
@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);
*/
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();
}
{
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
/**
* 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).