bugfix on copy only referenced annotation in copy constructor
authorjprocter <Jim Procter>
Thu, 10 May 2007 08:40:31 +0000 (08:40 +0000)
committerjprocter <Jim Procter>
Thu, 10 May 2007 08:40:31 +0000 (08:40 +0000)
src/jalview/datamodel/Sequence.java

index d64e133..7d6ba27 100755 (executable)
@@ -165,11 +165,15 @@ public class Sequence
       }
     }
     setDatasetSequence(seq.getDatasetSequence());
-    if (seq.getAnnotation()!=null && alAnnotation!=null) {
+    if (seq.getAnnotation()!=null) {
       AlignmentAnnotation[] sqann = seq.getAnnotation();
       for (int i=0;i<sqann.length; i++)
       {
-        boolean found = sqann == alAnnotation;
+        if (sqann[i]==null)
+        {
+          continue;
+        }
+        boolean found = (alAnnotation==null);
         if (!found)
         {
           for (int apos = 0; !found && apos<alAnnotation.length; apos++)
@@ -177,8 +181,12 @@ public class Sequence
             found = (alAnnotation[apos] == sqann[i]);
           }
         }
-        AlignmentAnnotation newann = new AlignmentAnnotation(sqann[i]);
-        addAlignmentAnnotation(newann);
+        if (found)
+        {
+          // only copy the given annotation
+          AlignmentAnnotation newann = new AlignmentAnnotation(sqann[i]);
+          addAlignmentAnnotation(newann);
+        }
       }
     }
     if (seq.getPDBId()!=null) {