Add annotation with sequence ref updated
[jalview.git] / src / jalview / datamodel / AlignmentAnnotation.java
index fcf9844..b93f178 100755 (executable)
@@ -27,7 +27,12 @@ package jalview.datamodel;
  */\r
 public class AlignmentAnnotation\r
 {\r
-    public SequenceI refSequence;\r
+    public SequenceI sequenceRef;\r
+\r
+    /** This annotation is the original loaded annotation\r
+     *  without any gaps. It is necessary to adjust the annotation\r
+     *  if sequences are updated */\r
+    public AlignmentAnnotation datasetAnnotation;\r
 \r
     /** DOCUMENT ME!! */\r
     public String label;\r
@@ -233,7 +238,7 @@ public class AlignmentAnnotation
         if(graphLines==null)\r
           graphLines = new java.util.Vector();\r
 \r
-        graphLines.add(line);\r
+        graphLines.addElement(line);\r
       }\r
 \r
       public GraphLine getGraphLine(int index)\r
@@ -244,6 +249,26 @@ public class AlignmentAnnotation
         else\r
           return null;\r
       }\r
+\r
+      public void adjustForAlignment()\r
+      {\r
+          int a=0, aSize = sequenceRef.getLength();\r
+\r
+          int index = 0;\r
+          Annotation[] temp = new Annotation[aSize];\r
+\r
+          for (a = 0; a < aSize; a++)\r
+          {\r
+            if (!jalview.util.Comparison.isGap(sequenceRef.getCharAt(a)))\r
+            {\r
+              index = sequenceRef.findPosition(a);\r
+              if(datasetAnnotation.annotations.length>index)\r
+                temp[a] = datasetAnnotation.annotations[index];\r
+            }\r
+          }\r
+\r
+          annotations = temp;\r
+      }\r
 }\r
 \r
 \r