JAL-2629 hmmer searches now read domain rather than full scores
[jalview.git] / src / jalview / hmmer / HmmerCommand.java
index dd6adc8..f38be02 100644 (file)
@@ -62,24 +62,36 @@ public abstract class HmmerCommand implements Runnable
 
   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 REPORTING_SEQ_EVALUE_KEY = "label.reporting_seq_evalue";
 
-  static final String CUTOFF_SCORE = "Score";
+  static final String REPORTING_DOM_EVALUE_KEY = "label.reporting_dom_evalue";
 
-  static final String CUTOFF_EVALUE = "E-Value";
+  static final String REPORTING_SEQ_SCORE_KEY = "label.reporting_seq_score";
 
-  static final String SEQ_EVALUE_KEY = "label.seq_evalue";
+  static final String REPORTING_DOM_SCORE_KEY = "label.reporting_dom_score";
 
-  static final String DOM_EVALUE_KEY = "label.dom_evalue";
+  static final String INCLUSION_SEQ_EVALUE_KEY = "label.inclusion_seq_evalue";
 
-  static final String SEQ_SCORE_KEY = "label.seq_score";
+  static final String INCLUSION_DOM_EVALUE_KEY = "label.inclusion_dom_evalue";
 
-  static final String DOM_SCORE_KEY = "label.dom_score";
+  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
    * 
@@ -236,7 +248,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 +292,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 +397,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
    */
@@ -471,17 +476,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<Boolean> 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 +512,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);
+        }
+      }
+    }
   }
 
 }