3 import jalview.datamodel.Alignment;
4 import jalview.datamodel.AlignmentI;
5 import jalview.datamodel.HiddenMarkovModel;
6 import jalview.datamodel.SequenceI;
7 import jalview.gui.AlignFrame;
8 import jalview.io.HMMFile;
9 import jalview.io.StockholmFile;
11 import java.io.BufferedReader;
13 import java.io.IOException;
14 import java.io.InputStreamReader;
15 import java.io.PrintWriter;
16 import java.util.Hashtable;
17 import java.util.List;
19 public class HMMERCommands
21 // Path of hmmer binaries directory
22 String HMMERFOLDER = "/Documents/";
24 public String JALVIEWDIRECTORY = System.getProperty("user.dir")
27 public String HMMALIGN = "/hmmalign ";
29 public String HMMBUILD = "/hmmbuild ";
31 public String HMMSEARCH = "/hmmsearch ";
33 public String HMMBUFFER;
35 public String ALIGNMENTBUFFER;
37 public String ALIGNMENTINPUT;
39 public String OUTPUTALIGNMENT;
41 public String NAME = "-n ";
43 public String SPACE = " ";
45 public String ALLCOL = "--allcol ";
47 public String TRIM = "--trim ";
49 Hashtable hash = new Hashtable();
51 List<SequenceI> hmmSeqs;
53 public void uniquifySequences(SequenceI[] seqs)
55 hash = jalview.analysis.SeqsetUtils.uniquify(seqs, true);
58 public void recoverSequenceNames(SequenceI[] seqs)
60 jalview.analysis.SeqsetUtils.deuniquify(hash, seqs);
64 * Runs a command in the terminal.
68 * @throws InterruptedException
70 public void runCommand(String command)
71 throws IOException, InterruptedException
73 final Process p = Runtime.getRuntime().exec(command);
75 new Thread(new Runnable()
80 BufferedReader input = new BufferedReader(
81 new InputStreamReader(p.getInputStream()));
86 while ((line = input.readLine()) != null)
88 System.out.println(line);
90 } catch (IOException e)
101 * Exports an alignment to the buffer location in Jalview.
104 * @throws IOException
106 public void exportData(SequenceI[] seqs,
107 File stoLocation, HiddenMarkovModel hmm, File hmmLocation)
112 StockholmFile file = new StockholmFile(new Alignment(seqs));
114 String output = file.print();
115 PrintWriter writer = new PrintWriter(stoLocation);
116 writer.println(output);
122 HMMFile file = new HMMFile(hmm);
123 file.exportFile(hmmLocation);
127 public void addHMMConsensusSequences(AlignFrame af)
129 AlignmentI al = af.getViewport().getAlignment();
130 for (SequenceI seq : hmmSeqs)
132 Integer position = seq.getPreviousPosition();
133 al.getSequences().add(position, seq);
135 af.getViewport().setAlignment(al);
136 af.alignPanel.adjustAnnotationHeight();
137 af.getViewport().updateSequenceIdColours();
138 af.buildSortByAnnotationScoresMenu();
141 public List<SequenceI> getHmmSeqs()
146 public void setHmmSeqs(List<SequenceI> hmmSeqs)
148 this.hmmSeqs = hmmSeqs;