3 import jalview.bin.Cache;
4 import jalview.datamodel.AlignmentI;
5 import jalview.datamodel.SequenceGroup;
6 import jalview.datamodel.SequenceI;
7 import jalview.gui.AlignFrame;
8 import jalview.gui.JvOptionPane;
9 import jalview.gui.Preferences;
10 import jalview.io.DataSourceType;
11 import jalview.io.FileFormat;
12 import jalview.util.MessageManager;
15 import java.io.FileNotFoundException;
16 import java.io.IOException;
17 import java.util.List;
19 import javax.swing.JOptionPane;
21 public class HMMBuildThread implements Runnable
23 HMMERCommands cmds = new HMMERCommands();
29 boolean canRun = true;
37 public HMMBuildThread(AlignFrame af)
40 if (af.getViewport().getSelectionGroup() != null)
42 group = af.getViewport().getSelectionGroup();
44 alignment = af.getViewport().getAlignment();
51 barID = System.currentTimeMillis();
52 af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
54 cmds.HMMERFOLDER = Cache.getProperty(Preferences.HMMER_PATH);
55 if (alignment == null && group == null)
57 JOptionPane.showMessageDialog(af,
58 MessageManager.getString("label.no_sequence_data"));
63 hmmTemp = File.createTempFile("hmm", ".hmm");
64 hmmTemp.deleteOnExit();
65 stoTemp = File.createTempFile("output", ".sto");
66 stoTemp.deleteOnExit();
67 } catch (IOException e1)
77 List<SequenceI> seqs = alignment
78 .getHMMConsensusSequences(true);
79 cmds.setHmmSeqs(seqs);
82 array = group.getSelectionAsNewSequences(alignment);
86 if (!alignment.isAligned())
90 array = alignment.getSequencesArray();
92 cmds.uniquifySequences(array);
93 cmds.exportData(array, stoTemp, null, null);
94 jalview.analysis.SeqsetUtils.deuniquify(cmds.hash, array);
96 } catch (FileNotFoundException e)
98 // TODO Auto-generated catch block
104 boolean ran = runCommand();
107 JvOptionPane.showInternalMessageDialog(af,
108 MessageManager.getString("warn.hmmbuild_failed"));
111 } catch (IOException | InterruptedException e)
113 // TODO Auto-generated catch block
120 } catch (IOException | InterruptedException e)
122 // TODO Auto-generated catch block
125 } catch (Exception e)
130 af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
138 private boolean runCommand() throws IOException, InterruptedException
140 File file = new File(cmds.HMMERFOLDER + "/binaries/hmmbuild.exe");
141 if (!file.canExecute())
145 String command = cmds.HMMERFOLDER + cmds.HMMBUILD + cmds.NAME
146 + af.getName() + cmds.SPACE;
147 if (!alignment.isNucleotide())
149 command += cmds.FORCEAMINO; // TODO check for rna
153 command += cmds.FORCEDNA;
156 command += hmmTemp.getAbsolutePath()
157 + cmds.SPACE + stoTemp.getAbsolutePath() + cmds.SPACE;
158 return cmds.runCommand(command);
161 private void importData() throws IOException, InterruptedException
163 cmds.addHMMConsensusSequences(af);
164 af.loadJalviewDataFile(hmmTemp.getAbsolutePath(), DataSourceType.FILE,
165 FileFormat.HMMER3, null);
170 public boolean canRun()