Merge branch 'improvement/JAL-3848_slivka_0.8' into alpha/JAL-3066_Jalview_212_slivka...
[jalview.git] / src / jalview / io / AnnotationFile.java
index 2182b24..9daae63 100755 (executable)
@@ -33,6 +33,7 @@ import java.util.Vector;
 
 import jalview.analysis.Conservation;
 import jalview.api.AlignViewportI;
+import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.Annotation;
@@ -65,6 +66,11 @@ public class AnnotationFile
   private String lastread = "";
 
   /**
+   * default calcId string for new annotation
+   */
+  private String defaultCalcId = null;
+
+  /**
    * Constructor
    */
   public AnnotationFile()
@@ -664,6 +670,21 @@ public class AnnotationFile
     return readAnnotationFile(al, null, file, sourceType);
   }
 
+  /**
+   * read an annotation file onto the alignment, but apply the given calcId
+   * @param aln
+   * @param calcId
+   * @param file
+   * @param url
+   * @return
+   */
+  public boolean readAnnotationFileWithCalcId(Alignment aln, String calcId, String file,
+          DataSourceType url)
+  {
+    defaultCalcId=calcId;
+    return readAnnotationFile(aln, null, file, url);
+  }
+  
   public boolean readAnnotationFile(AlignmentI al, HiddenColumns hidden,
           Object file, DataSourceType sourceType)
   {
@@ -1004,7 +1025,7 @@ public class AnnotationFile
 
         annotation = new AlignmentAnnotation(label, description,
                 (index == 0) ? null : annotations, 0, 0, graphStyle);
-
+        annotation.setCalcId(defaultCalcId);
         annotation.score = score;
         if (!overrideAutoAnnot && autoAnnots
                 .containsKey(autoAnnotsKey(annotation, refSeq, groupRef)))