X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fhmmer%2FHmmerCommand.java;h=85f64bfa7c5ee72c48f9f95ca186d76c0b71e1b5;hb=1beac3545a78d4c5c3274dbb53296708d693efe0;hp=20e00834e4fb3d4655cf0b07a2cb8193ccc892d4;hpb=a82f1e47eef845557e95e61116e6b34bdd3242f3;p=jalview.git diff --git a/src/jalview/hmmer/HmmerCommand.java b/src/jalview/hmmer/HmmerCommand.java index 20e0083..85f64bf 100644 --- a/src/jalview/hmmer/HmmerCommand.java +++ b/src/jalview/hmmer/HmmerCommand.java @@ -12,6 +12,7 @@ import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; import jalview.gui.JvOptionPane; import jalview.gui.Preferences; +import jalview.io.FastaFile; import jalview.io.HMMFile; import jalview.io.StockholmFile; import jalview.util.FileUtils; @@ -21,6 +22,7 @@ import jalview.ws.params.ArgumentI; import java.io.BufferedReader; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; @@ -45,6 +47,39 @@ public abstract class HmmerCommand implements Runnable protected final List params; + /* + * constants for i18n lookup of passed parameter names + */ + static final String DATABASE_KEY = "label.database"; + + static final String THIS_ALIGNMENT_KEY = "label.this_alignment"; + + static final String USE_ACCESSIONS_KEY = "label.use_accessions"; + + static final String AUTO_ALIGN_SEQS_KEY = "label.auto_align_seqs"; + + static final String NUMBER_OF_RESULTS_KEY = "label.number_of_results"; + + static final String TRIM_TERMINI_KEY = "label.trim_termini"; + + static final String REPORTING_CUTOFF_KEY = "label.reporting_cutoff"; + + static final String CUTOFF_NONE = "None"; + + static final String CUTOFF_SCORE = "Score"; + + static final String CUTOFF_EVALUE = "E-Value"; + + static final String SEQ_EVALUE_KEY = "label.seq_evalue"; + + static final String DOM_EVALUE_KEY = "label.dom_evalue"; + + static final String SEQ_SCORE_KEY = "label.seq_score"; + + static final String DOM_SCORE_KEY = "label.dom_score"; + + static final String ARG_TRIM = "--trim"; + /** * Constructor * @@ -248,6 +283,23 @@ public abstract class HmmerCommand implements Runnable writer.close(); } + public void exportFasta(SequenceI[] seqs, File toFile) + { + FastaFile file = new FastaFile(); + String output = file.print(seqs, false); + PrintWriter writer; + try + { + writer = new PrintWriter(toFile); + writer.println(output); + writer.close(); + } catch (FileNotFoundException e) + { + e.printStackTrace(); + } + + } + /** * Answers the full path to the given hmmer executable, or null if file cannot * be found or is not executable @@ -292,6 +344,25 @@ public abstract class HmmerCommand implements Runnable } } + // TODO is needed? + /** + * Exports a sequence to the specified file + * + * @param hmm + * @param hmmFile + * @throws IOException + */ + public void exportSequence(SequenceI seq, File seqFile) throws IOException + { + if (seq != null) + { + FastaFile file = new FastaFile(); + PrintWriter writer = new PrintWriter(seqFile); + writer.print(file.print(new SequenceI[] { seq }, false)); + writer.close(); + } + } + /** * Answers the HMM profile for the profile sequence the user selected (default * is just the first HMM sequence in the alignment) @@ -318,6 +389,29 @@ public abstract class HmmerCommand implements Runnable } /** + * Answers the HMM profile for the profile sequence the user selected (default + * is just the first HMM sequence in the alignment) + * + * @return + */ + protected SequenceI getSequence() + { + String alignToParamName = MessageManager + .getString("label.use_sequence"); + for (ArgumentI arg : params) + { + String name = arg.getName(); + if (name.equals(alignToParamName)) + { + String seqName = arg.getValue(); + SequenceI seq = alignment.findName(seqName); + return seq; + } + } + return null; + } + + /** * Answers an absolute path to the given file, in a format suitable for * processing by a hmmer command. On a Windows platform, the native Windows file * path is converted to Cygwin format, by replacing '\'with '/' and drive letter