3 import jalview.bin.Cache;
4 import jalview.datamodel.AlignmentI;
5 import jalview.datamodel.SequenceI;
6 import jalview.gui.AlignFrame;
7 import jalview.gui.Preferences;
8 import jalview.io.DataSourceType;
9 import jalview.io.FileFormat;
10 import jalview.util.MessageManager;
13 import java.io.FileNotFoundException;
14 import java.io.IOException;
17 public class HMMBuildThread implements Runnable
19 HMMERCommands cmds = new HMMERCommands();
29 Map<Integer, SequenceI> hmmSeqs;
31 public HMMBuildThread(AlignFrame af)
34 alignment = af.getViewport().getAlignment();
40 barID = System.currentTimeMillis();
41 System.out.println(System.getProperty("java.io.tmpdir"));
42 af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
44 cmds.HMMERFOLDER = Cache.getProperty(Preferences.HMMER_PATH);
47 hmmTemp = File.createTempFile("hmm", ".hmm");
48 hmmTemp.deleteOnExit();
49 stoTemp = File.createTempFile("output", ".sto");
50 stoTemp.deleteOnExit();
51 } catch (IOException e1)
60 hmmSeqs = alignment.getHMMConsensusSequences(true);
61 if (!alignment.isAligned())
65 cmds.exportData(alignment.getSequencesArray(), stoTemp, null, null);
66 } catch (FileNotFoundException e)
68 // TODO Auto-generated catch block
75 } catch (IOException | InterruptedException e)
77 // TODO Auto-generated catch block
84 } catch (IOException | InterruptedException e)
86 // TODO Auto-generated catch block
94 af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
102 private void runCommand() throws IOException, InterruptedException
104 final String command = cmds.HMMERFOLDER + cmds.HMMBUILD + cmds.NAME
105 + af.getName() + cmds.SPACE + hmmTemp.getAbsolutePath()
106 + cmds.SPACE + stoTemp.getAbsolutePath() + cmds.SPACE;
107 cmds.runCommand(command);
110 private void importData() throws IOException, InterruptedException
112 af.loadJalviewDataFile(hmmTemp.getAbsolutePath(), DataSourceType.FILE,
113 FileFormat.HMMER3, null);
114 for (Map.Entry<Integer, SequenceI> entry : hmmSeqs.entrySet())
116 SequenceI seq = entry.getValue();
117 Integer pos = entry.getKey();
118 cmds.addHMMConsensusSequence(af, seq, pos);
120 af.alignPanel.alignmentChanged();