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 = "/binaries/hmmalign ";
29 public final String HMMBUILD = "/binaries/hmmbuild ";
31 public final String HMMSEARCH = "/binaries/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 boolean 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)
115 * Exports an alignment to the buffer location in Jalview.
118 * @throws IOException
120 public void exportData(SequenceI[] seqs,
121 File stoLocation, HiddenMarkovModel hmm, File hmmLocation)
126 StockholmFile file = new StockholmFile(new Alignment(seqs));
128 String output = file.print();
129 PrintWriter writer = new PrintWriter(stoLocation);
130 writer.println(output);
136 HMMFile file = new HMMFile(hmm);
137 file.exportFile(hmmLocation);
141 public void addHMMConsensusSequences(AlignFrame af)
143 AlignmentI al = af.getViewport().getAlignment();
144 for (SequenceI seq : hmmSeqs)
146 Integer position = seq.getPreviousPosition();
147 al.getSequences().add(position, seq);
149 af.getViewport().setAlignment(al);
150 af.alignPanel.adjustAnnotationHeight();
151 af.getViewport().updateSequenceIdColours();
152 af.buildSortByAnnotationScoresMenu();
155 public List<SequenceI> getHmmSeqs()
160 public void setHmmSeqs(List<SequenceI> hmmSeqs)
162 this.hmmSeqs = hmmSeqs;