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 cmds.exportData(alignment, stoTemp, null, null);
62 } catch (FileNotFoundException e)
64 // TODO Auto-generated catch block
71 } catch (IOException | InterruptedException e)
73 // TODO Auto-generated catch block
80 } catch (IOException | InterruptedException e)
82 // TODO Auto-generated catch block
90 af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
98 private void runCommand() throws IOException, InterruptedException
100 final String command = cmds.HMMERFOLDER + cmds.HMMBUILD + cmds.NAME
101 + af.getName() + cmds.SPACE + hmmTemp.getAbsolutePath()
102 + cmds.SPACE + stoTemp.getAbsolutePath() + cmds.SPACE;
103 cmds.runCommand(command);
106 private void importData() throws IOException, InterruptedException
108 af.loadJalviewDataFile(hmmTemp.getAbsolutePath(), DataSourceType.FILE,
109 FileFormat.HMMER3, null);
110 for (Map.Entry<Integer, SequenceI> entry : hmmSeqs.entrySet())
112 SequenceI seq = entry.getValue();
113 Integer pos = entry.getKey();
114 cmds.addHMMConsensusSequence(af, seq, pos);
116 af.alignPanel.alignmentChanged();