X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fhmmer%2FHMMAlignThread.java;h=532271b4c36d625995f84fde2c86916871d94576;hb=bd4ab013e64863bbbffa93c58953051e11cfb236;hp=1c2450c2d866ac8cbf0de82ee3624a926bffef33;hpb=43664b003de849eaed85cb18bd67c71c4b74bb52;p=jalview.git diff --git a/src/jalview/hmmer/HMMAlignThread.java b/src/jalview/hmmer/HMMAlignThread.java index 1c2450c..532271b 100644 --- a/src/jalview/hmmer/HMMAlignThread.java +++ b/src/jalview/hmmer/HMMAlignThread.java @@ -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 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 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).