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;
12 import java.io.IOException;
13 import java.io.InputStreamReader;
14 import java.io.PrintWriter;
15 import java.util.List;
17 public class HMMERCommands
19 // Path of hmmer binaries directory
20 static String HMMERFOLDER = "/Documents/";
22 static final String JALVIEWDIRECTORY = System.getProperty("user.dir")
25 static String HMMALIGN = "/hmmalign ";
27 static String HMMBUILD = "/hmmbuild ";
29 static String HMMSEARCH = "/hmmsearch ";
31 static final String HMMBUFFER = "src/jalview/hmmer/hmm_buffer.hmm ";
33 static final String ALIGNMENTBUFFER = "src/jalview/hmmer/alignment_buffer.sto ";
35 static final String ALIGNMENTINPUT = "src/jalview/hmmer/alignment_input.sto ";
37 static final String OUTPUTALIGNMENT = "-o " + JALVIEWDIRECTORY
40 static final String NAME = "-n ";
42 static final String SPACE = " ";
44 static final String ALLCOL = "--allcol ";
46 static final String TRIM = "--trim ";
50 * Runs a command in the terminal.
54 * @throws InterruptedException
56 public static void runCommand(String command)
57 throws IOException, InterruptedException
59 final Process p = Runtime.getRuntime().exec(command);
61 new Thread(new Runnable()
66 BufferedReader input = new BufferedReader(
67 new InputStreamReader(p.getInputStream()));
72 while ((line = input.readLine()) != null)
74 System.out.println(line);
76 } catch (IOException e)
87 * Exports an alignment to the buffer location in Jalview.
92 public static void exportData(AlignmentI alignment,
93 boolean exportAlignment, boolean exportHMM, HiddenMarkovModel hmm)
98 if (!alignment.isAligned())
102 List<SequenceI> list = alignment.getSequences();
103 SequenceI[] array = new SequenceI[list.size()];
105 StockholmFile file = new StockholmFile(new Alignment(array));
107 String output = file.print();
108 PrintWriter writer = new PrintWriter(ALIGNMENTBUFFER);
109 writer.println(output);
115 HMMFile file = new HMMFile(hmm);
116 file.exportFile(HMMBUFFER);
120 public static void addHMMConsensusSequence(AlignFrame af, SequenceI seq,
123 seq.getHMM().initHMMSequence(af, position);
124 AlignmentI al = af.getViewport().getAlignment();
125 af.getViewport().setAlignment(al);
126 af.alignPanel.adjustAnnotationHeight();
127 af.getViewport().updateSequenceIdColours();
128 af.buildSortByAnnotationScoresMenu();