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.Preferences;
9 import jalview.io.DataSourceType;
10 import jalview.io.FileFormat;
11 import jalview.util.MessageManager;
14 import java.io.FileNotFoundException;
15 import java.io.IOException;
16 import java.util.List;
18 import javax.swing.JOptionPane;
20 public class HMMBuildThread implements Runnable
22 HMMERCommands cmds = new HMMERCommands();
28 boolean canRun = true;
36 public HMMBuildThread(AlignFrame af)
39 if (af.getViewport().getSelectionGroup() != null)
41 group = af.getViewport().getSelectionGroup();
43 alignment = af.getViewport().getAlignment();
50 barID = System.currentTimeMillis();
51 af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
53 cmds.HMMERFOLDER = Cache.getProperty(Preferences.HMMER_PATH);
54 if (alignment == null && group == null)
56 JOptionPane.showMessageDialog(af,
57 MessageManager.getString("label.no_sequence_data"));
62 hmmTemp = File.createTempFile("hmm", ".hmm");
63 hmmTemp.deleteOnExit();
64 stoTemp = File.createTempFile("output", ".sto");
65 stoTemp.deleteOnExit();
66 } catch (IOException e1)
75 List<SequenceI> seqs = alignment
76 .getHMMConsensusSequences(true);
77 cmds.setHmmSeqs(seqs);
80 SequenceI[] array = group.getSelectionAsNewSequences(alignment);
82 cmds.exportData(array, stoTemp, null, null);
86 if (!alignment.isAligned())
90 cmds.exportData(alignment.getSequencesArray(), stoTemp, null,
93 } catch (FileNotFoundException e)
95 // TODO Auto-generated catch block
102 } catch (IOException | InterruptedException e)
104 // TODO Auto-generated catch block
111 } catch (IOException | InterruptedException e)
113 // TODO Auto-generated catch block
116 } catch (Exception e)
121 af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
129 private void runCommand() throws IOException, InterruptedException
131 String command = cmds.HMMERFOLDER + cmds.HMMBUILD + cmds.NAME
132 + af.getName() + cmds.SPACE;
133 if (!alignment.isNucleotide())
135 command += cmds.FORCEAMINO; // TODO check for rna
139 command += cmds.FORCEDNA;
142 command += hmmTemp.getAbsolutePath()
143 + cmds.SPACE + stoTemp.getAbsolutePath() + cmds.SPACE;
144 cmds.runCommand(command);
147 private void importData() throws IOException, InterruptedException
149 cmds.addHMMConsensusSequences(af);
150 af.loadJalviewDataFile(hmmTemp.getAbsolutePath(), DataSourceType.FILE,
151 FileFormat.HMMER3, null);
156 public boolean canRun()