new method to get map of sequence positions corresponding to alignment columns
[jalview.git] / src / jalview / datamodel / Sequence.java
index 722edf2..3240f84 100755 (executable)
@@ -656,7 +656,29 @@ public class Sequence implements SequenceI
 
     return map;
   }
+  /*
+   * (non-Javadoc)
+   * 
+   * @see jalview.datamodel.SequenceI#findPositionMap()
+   */
+  public int[] findPositionMap()
+  {
+    int map[] = new int[sequence.length];
+    int j = 0;
+    int pos = start;
+    int seqlen = sequence.length;
+    while ((j < seqlen))
+    {
+      map[j] = pos;
+      if (!jalview.util.Comparison.isGap(sequence[j]))
+      {
+        pos++;
+      }
 
+      j++;
+    }
+    return map;
+  }
   /*
    * (non-Javadoc)
    *