new method to get map of sequence positions corresponding to alignment columns
authorjprocter <Jim Procter>
Tue, 22 Jan 2008 16:14:19 +0000 (16:14 +0000)
committerjprocter <Jim Procter>
Tue, 22 Jan 2008 16:14:19 +0000 (16:14 +0000)
src/jalview/datamodel/Sequence.java
src/jalview/datamodel/SequenceI.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)
    * 
index da49a31..d9ffc81 100755 (executable)
@@ -174,6 +174,14 @@ public interface SequenceI
   public int[] gapMap();
 
   /**
+   * Returns an int array where indices correspond to each position in
+   * sequence char array and the element value gives the result of findPosition
+   * for that index in the sequence.
+   * 
+   * @return int[SequenceI.getLength()] 
+   */
+  public int[] findPositionMap();
+  /**
    * Delete a range of aligned sequence columns, creating a new dataset sequence if necessary
    * and adjusting start and end positions accordingly.
    *