JAL-1645 Version-Rel Version 2.9 Year-Rel 2015 Licensing glob
[jalview.git] / src / jalview / ws / jws2 / JabawsCalcWorker.java
index e966886..d2e5bcd 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9)
+ * Copyright (C) 2015 The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
@@ -115,7 +115,10 @@ public abstract class JabawsCalcWorker extends AbstractJabaCalcWorker
         rslt = aaservice.customAnalize(seqs, getJabaArguments());
       } catch (WrongParameterException x)
       {
-        throw new JobSubmissionException(MessageManager.getString("exception.jobsubmission_invalid_params_set"), x);
+        throw new JobSubmissionException(
+                MessageManager
+                        .getString("exception.jobsubmission_invalid_params_set"),
+                x);
 
       }
     }
@@ -158,6 +161,30 @@ public abstract class JabawsCalcWorker extends AbstractJabaCalcWorker
     return annotation;
   }
 
+  protected void replaceAnnotationOnAlignmentWith(
+          AlignmentAnnotation newAnnot, String typeName, String calcId,
+          SequenceI aSeq)
+  {
+    SequenceI dsseq = aSeq.getDatasetSequence();
+    while (dsseq.getDatasetSequence() != null)
+    {
+      dsseq = dsseq.getDatasetSequence();
+    }
+    // look for same annotation on dataset and lift this one over
+    List<AlignmentAnnotation> dsan = dsseq.getAlignmentAnnotations(calcId,
+            typeName);
+    if (dsan != null && dsan.size() > 0)
+    {
+      for (AlignmentAnnotation dssan : dsan)
+      {
+        dsseq.removeAlignmentAnnotation(dssan);
+      }
+    }
+    AlignmentAnnotation dssan = new AlignmentAnnotation(newAnnot);
+    dsseq.addAlignmentAnnotation(dssan);
+    dssan.adjustForAlignment();
+  }
+
   private void constructAnnotationFromScore(AlignmentAnnotation annotation,
           int base, int alWidth, Score scr)
   {