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 final String HMMALIGN = "/hmmalign ";
29 public final String HMMBUILD = "/hmmbuild ";
31 public final String HMMSEARCH = "/hmmsearch ";
33 public String HMMBUFFER;
35 public String ALIGNMENTBUFFER;
37 public String ALIGNMENTINPUT;
39 public String OUTPUTALIGNMENT;
41 public final String NAME = "-n ";
43 public final String SPACE = " ";
45 public final String ALLCOL = "--allcol ";
47 public final String TRIM = "--trim ";
49 public final String FORCEAMINO = "--amino ";
51 public final String FORCEDNA = "--dna ";
53 public final String FORCERNA = "--rna ";
55 Hashtable hash = new Hashtable();
57 List<SequenceI> hmmSeqs;
59 public void uniquifySequences(SequenceI[] seqs)
61 hash = jalview.analysis.SeqsetUtils.uniquify(seqs, true);
64 public void recoverSequenceNames(SequenceI[] seqs)
66 jalview.analysis.SeqsetUtils.deuniquify(hash, seqs);
70 * Runs a command in the terminal.
74 * @throws InterruptedException
76 public void runCommand(String command)
77 throws IOException, InterruptedException
81 final Process p = Runtime.getRuntime().exec(command);
83 new Thread(new Runnable()
88 BufferedReader input = new BufferedReader(
89 new InputStreamReader(p.getInputStream()));
94 while ((line = input.readLine()) != null)
96 System.out.println(line);
98 } catch (IOException e)
106 } catch (Exception e)
113 * Exports an alignment to the buffer location in Jalview.
116 * @throws IOException
118 public void exportData(SequenceI[] seqs,
119 File stoLocation, HiddenMarkovModel hmm, File hmmLocation)
124 StockholmFile file = new StockholmFile(new Alignment(seqs));
126 String output = file.print();
127 PrintWriter writer = new PrintWriter(stoLocation);
128 writer.println(output);
134 HMMFile file = new HMMFile(hmm);
135 file.exportFile(hmmLocation);
139 public void addHMMConsensusSequences(AlignFrame af)
141 AlignmentI al = af.getViewport().getAlignment();
142 for (SequenceI seq : hmmSeqs)
144 Integer position = seq.getPreviousPosition();
145 al.getSequences().add(position, seq);
147 af.getViewport().setAlignment(al);
148 af.alignPanel.adjustAnnotationHeight();
149 af.getViewport().updateSequenceIdColours();
150 af.buildSortByAnnotationScoresMenu();
153 public List<SequenceI> getHmmSeqs()
158 public void setHmmSeqs(List<SequenceI> hmmSeqs)
160 this.hmmSeqs = hmmSeqs;