skips any annotation that appears to be identical to existing autogenerated annotatio...
authorjprocter <Jim Procter>
Fri, 23 Apr 2010 15:59:56 +0000 (15:59 +0000)
committerjprocter <Jim Procter>
Fri, 23 Apr 2010 15:59:56 +0000 (15:59 +0000)
src/jalview/io/AnnotationFile.java

index 87b21d3..aac48eb 100755 (executable)
@@ -433,6 +433,7 @@ public class AnnotationFile
   public boolean readAnnotationFile(AlignmentI al, String file,\r
           String protocol)\r
   {\r
+    Hashtable autoAnnots=new Hashtable();\r
     try\r
     {\r
       BufferedReader in = null;\r
@@ -462,9 +463,24 @@ public class AnnotationFile
       int graphStyle, index;\r
       int refSeqIndex = 1;\r
       int existingAnnotations = 0;\r
+      // when true - will add new rows regardless of whether they are duplicate auto-annotation like consensus or conservation graphs\r
+      boolean overrideAutoAnnot=false; \r
       if (al.getAlignmentAnnotation() != null)\r
       {\r
         existingAnnotations = al.getAlignmentAnnotation().length;\r
+        if (existingAnnotations>0)\r
+        {\r
+          AlignmentAnnotation[] aa = al.getAlignmentAnnotation();\r
+          for (int aai=0;aai<aa.length;aai++)\r
+          {\r
+            if (aa[aai].autoCalculated)\r
+            {\r
+              // make a note of the name and description\r
+              autoAnnots.put(aa[aai].graph+"\t"+aa[aai].label+"\t"+aa[aai].description+"\t"+(aa[aai].sequenceRef!=null ? aa[aai].sequenceRef.getDisplayId(true) : "")\r
+                      ,new Integer(1));\r
+            }\r
+          }\r
+        }\r
       }\r
 \r
       int alWidth = al.getWidth();\r
@@ -645,14 +661,20 @@ public class AnnotationFile
           }\r
 \r
         }\r
-\r
+        \r
         annotation = new AlignmentAnnotation(label, description,\r
                 (index == 0) ? null : annotations, 0, 0, graphStyle);\r
 \r
         annotation.score = score;\r
-\r
+        if (!overrideAutoAnnot && autoAnnots.containsKey(annotation.graph+"\t"+annotation.label+"\t"+annotation.description+"\t"+(refSeq!=null ? refSeq.getDisplayId(true) : "")))\r
+        {\r
+          // skip - we've already got an automatic annotation of this type.\r
+          continue;\r
+        }\r
+        // otherwise add it!\r
         if (refSeq != null)\r
         {\r
+          \r
           annotation.belowAlignment = false;\r
           // make a copy of refSeq so we can find other matches in the alignment\r
           SequenceI referedSeq = refSeq;\r