X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fhmmer%2FHMMERCommands.java;h=913eee8baad428dda856b67eab7e3edfd257c889;hb=d4db66b0d4d89405bc90aa999e15debc7bf85659;hp=4f1dbc6a7f6e1afe61215bb177211c0b5b93ccc7;hpb=c9a198a4eb76592ff9091cdba7d0299a0345ba09;p=jalview.git diff --git a/src/jalview/hmmer/HMMERCommands.java b/src/jalview/hmmer/HMMERCommands.java index 4f1dbc6..913eee8 100644 --- a/src/jalview/hmmer/HMMERCommands.java +++ b/src/jalview/hmmer/HMMERCommands.java @@ -16,6 +16,13 @@ import java.io.PrintWriter; import java.util.Hashtable; import java.util.List; +/** + * Contains multiple commands and methods frequently used to run hmmbuild, + * hmmalign and hmmsearch + * + * @author TZVanaalten + * + */ public class HMMERCommands { // Path of hmmer binaries directory @@ -24,17 +31,11 @@ public class HMMERCommands public String JALVIEWDIRECTORY = System.getProperty("user.dir") + "/"; - public final String HMMALIGN = "/binaries/hmmalign "; + public final String HMMALIGN = "/hmmalign "; - public final String HMMBUILD = "/binaries/hmmbuild "; + public final String HMMBUILD = "/hmmbuild "; - public final String HMMSEARCH = "/binaries/hmmsearch "; - - public String HMMBUFFER; - - public String ALIGNMENTBUFFER; - - public String ALIGNMENTINPUT; + public final String HMMSEARCH = "/hmmsearch "; public String OUTPUTALIGNMENT; @@ -56,18 +57,29 @@ public class HMMERCommands List hmmSeqs; + /** + * Uniquifies the sequences when exporting and stores their details in a + * hashtable. + * + * @param seqs + */ public void uniquifySequences(SequenceI[] seqs) { hash = jalview.analysis.SeqsetUtils.uniquify(seqs, true); } + /** + * Recover the sequence data lost by uniquifying. + * + * @param seqs + */ public void recoverSequenceNames(SequenceI[] seqs) { jalview.analysis.SeqsetUtils.deuniquify(hash, seqs); } /** - * Runs a command in the terminal. + * Runs a command in the command line. * * @param command * @throws IOException @@ -112,7 +124,7 @@ public class HMMERCommands } /** - * Exports an alignment to the buffer location in Jalview. + * Exports an alignment and/or HMM to the specified file. * * @param alignment * @throws IOException @@ -124,12 +136,7 @@ public class HMMERCommands if (seqs != null) { StockholmFile file = new StockholmFile(new Alignment(seqs)); - boolean removeAnnots = false; - if (hmm == null) - { - removeAnnots = true; - } - String output = file.print(seqs, false, removeAnnots); + String output = file.print(seqs, false); PrintWriter writer = new PrintWriter(stoLocation); writer.println(output); writer.close(); @@ -138,13 +145,25 @@ public class HMMERCommands if (hmm != null) { HMMFile file = new HMMFile(hmm); - file.exportFile(hmmLocation); + PrintWriter writer = new PrintWriter(hmmLocation); + writer.print(file.print()); + writer.close(); } } + /** + * Adds any HMM sequences removed before submitting the alignment as a job + * back into the alignment. + * + * @param af + */ public void addHMMConsensusSequences(AlignFrame af) { AlignmentI al = af.getViewport().getAlignment(); + if (hmmSeqs == null || hmmSeqs.size() < 1) + { + return; + } for (SequenceI seq : hmmSeqs) { Integer position = seq.getPreviousPosition(); @@ -154,13 +173,24 @@ public class HMMERCommands af.alignPanel.adjustAnnotationHeight(); af.getViewport().updateSequenceIdColours(); af.buildSortByAnnotationScoresMenu(); + af.getViewport().initInformation(); } + /** + * Returns the list of HMM sequences removed + * + * @return + */ public List getHmmSeqs() { return hmmSeqs; } + /** + * Sets the list of removed HMM sequences + * + * @param hmmSeqs + */ public void setHmmSeqs(List hmmSeqs) { this.hmmSeqs = hmmSeqs;