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
79 final Process p = Runtime.getRuntime().exec(command);
81 new Thread(new Runnable()
86 BufferedReader input = new BufferedReader(
87 new InputStreamReader(p.getInputStream()));
92 while ((line = input.readLine()) != null)
94 System.out.println(line);
96 } catch (IOException e)
107 * Exports an alignment to the buffer location in Jalview.
110 * @throws IOException
112 public void exportData(SequenceI[] seqs,
113 File stoLocation, HiddenMarkovModel hmm, File hmmLocation)
118 StockholmFile file = new StockholmFile(new Alignment(seqs));
120 String output = file.print();
121 PrintWriter writer = new PrintWriter(stoLocation);
122 writer.println(output);
128 HMMFile file = new HMMFile(hmm);
129 file.exportFile(hmmLocation);
133 public void addHMMConsensusSequences(AlignFrame af)
135 AlignmentI al = af.getViewport().getAlignment();
136 for (SequenceI seq : hmmSeqs)
138 Integer position = seq.getPreviousPosition();
139 al.getSequences().add(position, seq);
141 af.getViewport().setAlignment(al);
142 af.alignPanel.adjustAnnotationHeight();
143 af.getViewport().updateSequenceIdColours();
144 af.buildSortByAnnotationScoresMenu();
147 public List<SequenceI> getHmmSeqs()
152 public void setHmmSeqs(List<SequenceI> hmmSeqs)
154 this.hmmSeqs = hmmSeqs;