JAL-2629 fix hmm on alignment being deleted upon running jackhmmer
[jalview.git] / src / jalview / hmmer / JackHMMER.java
index 85b97f9..1731439 100644 (file)
@@ -246,7 +246,9 @@ public class JackHMMER extends HmmerCommand
        */
       databaseFile = FileUtils.createTempFile("database", ".fa");
       AlignmentI al = af.getViewport().getAlignment();
-      exportFasta(al.getSequencesArray(), databaseFile);
+      AlignmentI copy = new Alignment(al);
+      deleteHmmSequences(copy);
+      exportFasta(copy, databaseFile);
     }
 
     args.add(getFilePath(seqFile, true));
@@ -325,22 +327,12 @@ public class JackHMMER extends HmmerCommand
             && !"".equals(line))
     {
       SequenceI seq = seqs[index];
-      AlignmentAnnotation pp = null;
-      if (seq.getAlignmentAnnotations("", "Posterior Probability")
-              .size() != 0)
-      {
-        pp = seq.getAlignmentAnnotations("", "Posterior Probability")
-                .get(0);
-      }
+
       Scanner scanner = new Scanner(line);
-      String str = scanner.next();
-      str = scanner.next();
-      addScoreAnnotation(str, seq, "jackhmmer E-value",
-              "Full sequence E-value", pp);
-      str = scanner.next();
-      addScoreAnnotation(str, seq, "jackhmmer Score",
-              "Full sequence bit score", pp);
-      seq.removeAlignmentAnnotation(pp);
+      String evalue = scanner.next();
+      evalue = scanner.next();
+      String score = scanner.next();
+      addScoreAnnotations(evalue, score, seq);
       scanner.close();
       line = br.readLine();
       index++;
@@ -349,58 +341,37 @@ public class JackHMMER extends HmmerCommand
     br.close();
   }
 
-  /**
-   * A helper method that adds one score-only (non-positional) annotation to a
-   * sequence
-   * 
-   * @param value
-   * @param seq
-   * @param label
-   * @param description
-   */
-  protected void addScoreAnnotation(String value, SequenceI seq,
-          String label, String description)
+  protected void addScoreAnnotations(String eValue, String bitScore,
+          SequenceI seq)
   {
-    addScoreAnnotation(value, seq, label, description, null);
-  }
+    String label = "Search Scores";
+    String description = "Full sequence bit score and E-Value";
 
-  /**
-   * A helper method that adds one score-only (non-positional) annotation to a
-   * sequence
-   * 
-   * @param value
-   * @param seq
-   * @param label
-   * @param description
-   * @param pp
-   *                      existing posterior probability annotation - values
-   *                      copied to new annotation row
-   */
-  protected void addScoreAnnotation(String value, SequenceI seq,
-          String label, String description, AlignmentAnnotation pp)
-  {
     try
     {
-      AlignmentAnnotation annot = null;
-      if (pp == null)
-      {
-        annot = new AlignmentAnnotation(label, description, null);
-      }
-      else
-      {
-        annot = new AlignmentAnnotation(pp);
-        annot.label = label;
-        annot.description = description;
-      }
+      AlignmentAnnotation annot = new AlignmentAnnotation(label,
+              description, null);
+
+      annot.label = label;
+      annot.description = description;
+
       annot.setCalcId(JACKHMMER);
-      double eValue = Double.parseDouble(value);
-      annot.setScore(eValue);
+
+      double dEValue = Double.parseDouble(eValue);
+      annot.setEValue(dEValue);
+
+      double dBitScore = Double.parseDouble(bitScore);
+      annot.setEValue(dBitScore);
+
       annot.setSequenceRef(seq);
       seq.addAlignmentAnnotation(annot);
     } catch (NumberFormatException e)
     {
-      System.err.println("Error parsing " + label + " from " + value);
+      System.err.println("Error parsing " + label + " from " + eValue
+              + " & " + bitScore);
     }
   }
 
+
+
 }