deleteSequenceFeature
[jalview.git] / src / jalview / datamodel / AlignmentAnnotation.java
index 04689cd..c3396b6 100755 (executable)
@@ -1,6 +1,6 @@
 /*
 * Jalview - A Sequence Alignment Editor and Viewer
-* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
@@ -258,11 +258,14 @@ public class AlignmentAnnotation
       }
 
       /**
-       * Attach the annotation to seqRef, starting from startRes position.
+       * Attach the annotation to seqRef, starting from startRes position. If alreadyMapped is true then the indices of the annotation[] array are sequence positions rather than alignment column positions.
        * @param seqRef
        * @param startRes
+       * @param alreadyMapped
        */
-      public void createSequenceMapping(SequenceI seqRef, int startRes)
+      public void createSequenceMapping(SequenceI seqRef,
+                                        int startRes,
+                                        boolean alreadyMapped)
       {
         if(seqRef == null)
           return;
@@ -270,33 +273,22 @@ public class AlignmentAnnotation
         sequenceMapping = new java.util.Hashtable();
 
         sequenceRef = seqRef;
-
-        if(startRes < sequenceRef.getStart())
-          startRes = sequenceRef.getStart();
-
         int seqPos;
 
-        int fileOffset = 0;
-        if(startRes > sequenceRef.getStart())
-        {
-          fileOffset = startRes - sequenceRef.getStart();
-        }
-
         for(int i = 0; i < annotations.length; i++)
         {
-            seqPos = sequenceRef.findPosition(i + fileOffset);
-            if(seqPos<annotations.length)
+            if (annotations[i] != null)
             {
-              if (annotations[i] != null)
-              {
-                  sequenceMapping.put(new Integer(seqPos),
-                                      annotations[i]);
-              }
+              if(alreadyMapped)
+                seqPos = seqRef.findPosition(i);
+              else
+                seqPos = i+startRes;
+
+              sequenceMapping.put(new Integer(seqPos), annotations[i]);
             }
          }
 
         adjustForAlignment();
-
       }
 
       public void adjustForAlignment()