X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fhmmer%2FHmmerCommand.java;h=9db0ae19601e2135f00f90c221477cf0f01cf522;hb=747167089ecf8d6afc70d417f5a20352e029bd95;hp=dd6adc8f856ac9ceeabe724b0eecd6d1e003bc46;hpb=3e49da65865c812f4b2b81f40ef65c983f14aa83;p=jalview.git diff --git a/src/jalview/hmmer/HmmerCommand.java b/src/jalview/hmmer/HmmerCommand.java index dd6adc8..9db0ae1 100644 --- a/src/jalview/hmmer/HmmerCommand.java +++ b/src/jalview/hmmer/HmmerCommand.java @@ -1,7 +1,9 @@ package jalview.hmmer; import jalview.analysis.SeqsetUtils; +import jalview.analysis.SeqsetUtils.SequenceInfo; import jalview.bin.Cache; +import jalview.bin.Console; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; @@ -30,6 +32,7 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import java.util.Map; /** * Base class for hmmbuild, hmmalign and hmmsearch @@ -60,26 +63,40 @@ public abstract class HmmerCommand implements Runnable static final String NUMBER_OF_RESULTS_KEY = "label.number_of_results"; + static final String NUMBER_OF_ITERATIONS = "label.number_of_iterations"; + static final String TRIM_TERMINI_KEY = "label.trim_termini"; + static final String RETURN_N_NEW_SEQ = "label.check_for_new_sequences"; + static final String REPORTING_CUTOFF_KEY = "label.reporting_cutoff"; - static final String CUTOFF_NONE = "None"; + static final String CUTOFF_NONE = "label.default"; + + static final String CUTOFF_SCORE = "label.score"; + + static final String CUTOFF_EVALUE = "label.evalue"; - static final String CUTOFF_SCORE = "Score"; + static final String REPORTING_SEQ_EVALUE_KEY = "label.reporting_seq_evalue"; - static final String CUTOFF_EVALUE = "E-Value"; + static final String REPORTING_DOM_EVALUE_KEY = "label.reporting_dom_evalue"; - static final String SEQ_EVALUE_KEY = "label.seq_evalue"; + static final String REPORTING_SEQ_SCORE_KEY = "label.reporting_seq_score"; - static final String DOM_EVALUE_KEY = "label.dom_evalue"; + static final String REPORTING_DOM_SCORE_KEY = "label.reporting_dom_score"; - static final String SEQ_SCORE_KEY = "label.seq_score"; + static final String INCLUSION_SEQ_EVALUE_KEY = "label.inclusion_seq_evalue"; - static final String DOM_SCORE_KEY = "label.dom_score"; + static final String INCLUSION_DOM_EVALUE_KEY = "label.inclusion_dom_evalue"; + + static final String INCLUSION_SEQ_SCORE_KEY = "label.inclusion_seq_score"; + + static final String INCLUSION_DOM_SCORE_KEY = "label.inclusion_dom_score"; static final String ARG_TRIM = "--trim"; + static final String INCLUSION_THRESHOLD_KEY = "label.inclusion_threshold"; + /** * Constructor * @@ -113,7 +130,7 @@ public abstract class HmmerCommand implements Runnable * * @param seqs */ - protected Hashtable stashSequences(SequenceI[] seqs) + protected Map stashSequences(SequenceI[] seqs) { return SeqsetUtils.uniquify(seqs, true); } @@ -121,12 +138,12 @@ public abstract class HmmerCommand implements Runnable /** * Restores the sequence data lost by uniquifying * - * @param hashtable + * @param sequencesHash * @param seqs */ - protected void recoverSequences(Hashtable hashtable, SequenceI[] seqs) + protected void recoverSequences(Map sequencesHash, SequenceI[] seqs) { - SeqsetUtils.deuniquify(hashtable, seqs); + SeqsetUtils.deuniquify(sequencesHash, seqs); } /** @@ -140,14 +157,14 @@ public abstract class HmmerCommand implements Runnable public boolean runCommand(List commands) throws IOException { - List args = Platform.isWindows() ? wrapWithCygwin(commands) + List args = Platform.isWindowsAndNotJS() ? wrapWithCygwin(commands) : commands; try { ProcessBuilder pb = new ProcessBuilder(args); pb.redirectErrorStream(true); // merge syserr to sysout - if (Platform.isWindows()) + if (Platform.isWindowsAndNotJS()) { String path = pb.environment().get("Path"); path = jalview.bin.Cache.getProperty("CYGWIN_PATH") + ";" + path; @@ -180,8 +197,8 @@ public abstract class HmmerCommand implements Runnable int exitValue = p.exitValue(); if (exitValue != 0) { - Cache.log.error("Command failed, return code = " + exitValue); - Cache.log.error("Command/args were: " + args.toString()); + Console.error("Command failed, return code = " + exitValue); + Console.error("Command/args were: " + args.toString()); } return exitValue == 0; // 0 is success, by convention } catch (Exception e) @@ -204,7 +221,7 @@ public abstract class HmmerCommand implements Runnable Cache.getProperty(Preferences.CYGWIN_PATH)); if (bash == null) { - Cache.log.error("Cygwin shell not found"); + Console.error("Cygwin shell not found"); return commands; } @@ -236,7 +253,7 @@ public abstract class HmmerCommand implements Runnable * @throws IOException */ public void exportStockholm(SequenceI[] seqs, File toFile, - AnnotatedCollectionI annotated, boolean removeSS) + AnnotatedCollectionI annotated) throws IOException { if (seqs == null) @@ -280,17 +297,10 @@ public abstract class HmmerCommand implements Runnable for (SequenceI seq : newAl.getSequencesArray()) { - if (removeSS && seq.getAnnotation() != null) + if (seq.getAnnotation() != null) { for (AlignmentAnnotation ann : seq.getAnnotation()) { - // TODO investigate how to make hmmsearch and jackhmmer work with annotations - /* - if (ann.label.equals("Secondary Structure")) - { - seq.removeAlignmentAnnotation(ann); - } - */ seq.removeAlignmentAnnotation(ann); } } @@ -392,8 +402,8 @@ 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) + * Answers the query sequence the user selected (default is just the first + * sequence in the alignment) * * @return */ @@ -429,7 +439,7 @@ public abstract class HmmerCommand implements Runnable protected String getFilePath(File resultFile, boolean isInCygwin) { String path = resultFile.getAbsolutePath(); - if (Platform.isWindows() && isInCygwin) + if (Platform.isWindowsAndNotJS() && isInCygwin) { // the first backslash escapes '\' for the regular expression argument path = path.replaceAll("\\" + File.separator, "/"); @@ -471,17 +481,33 @@ public abstract class HmmerCommand implements Runnable } } - void renameDuplicates(SequenceI[] seqs) + /** + * Sets the names of any duplicates within the given sequences to include their + * respective lengths. Deletes any duplicates that have the same name after this + * step + * + * @param seqs + */ + void renameDuplicates(AlignmentI al) { - // rename duplicate sequences, hmmsearch fails db contains duplicates + + SequenceI[] seqs = al.getSequencesArray(); + List wasRenamed = new ArrayList<>(); + + for (SequenceI seq : seqs) + { + wasRenamed.add(false); + } + for (int i = 0; i < seqs.length; i++) { - boolean renamed = false; for (int j = 0; j < seqs.length; j++) { - renamed = true; - if (seqs[i].getName().equals(seqs[j].getName()) && i != j) + if (seqs[i].getName().equals(seqs[j].getName()) && i != j + && !wasRenamed.get(j)) { + + wasRenamed.set(i, true); String range = "/" + seqs[j].getStart() + "-" + seqs[j].getEnd(); // setting sequence name to include range - to differentiate between // sequences of the same name. Currently have to include the range twice @@ -491,12 +517,23 @@ public abstract class HmmerCommand implements Runnable } } - if (renamed) + if (wasRenamed.get(i)) { String range = "/" + seqs[i].getStart() + "-" + seqs[i].getEnd(); seqs[i].setName(seqs[i].getName() + range + range); } } + + for (int i = 0; i < seqs.length; i++) + { + for (int j = 0; j < seqs.length; j++) + { + if (seqs[i].getName().equals(seqs[j].getName()) && i != j) + { + al.deleteSequence(j); + } + } + } } }