moving word methods to MapList and begin bug-fix for single-residue codon span featur...
[jalview.git] / src / jalview / datamodel / Mapping.java
index 2594c31..b9874a4 100644 (file)
@@ -5,9 +5,9 @@ import jalview.util.MapList;
 public class Mapping {
   /**
    * Contains the
-   * start-end pairs mapping from 
-   * the associated sequence to the 
-   * sequence in the database 
+   * start-end pairs mapping from
+   * the associated sequence to the
+   * sequence in the database
    * coordinate system
    * it also takes care of step difference between coordinate systems
    */
@@ -37,14 +37,14 @@ public class Mapping {
     this(to, new MapList(exon, is, i, j));
   }
   /**
-   * create a duplicate (and independent) mapping object with 
+   * create a duplicate (and independent) mapping object with
    * the same reference to any SequenceI being mapped to.
    * @param map2
    */
   public Mapping(Mapping map2)
   {
     if (map2!=this && map2!=null) {
-      if (map2.map!=null) 
+      if (map2.map!=null)
       {
         map=new MapList(map2.map);
       }
@@ -67,7 +67,7 @@ public class Mapping {
   /**
    * Equals that compares both the to references and MapList mappings.
    * @param other
-   * @return 
+   * @return
    */
   public boolean equals(Mapping other) {
     if (other==null)
@@ -88,7 +88,7 @@ public class Mapping {
    * @param mpos
    * @return
    */
-  public int getPosition(int mpos) 
+  public int getPosition(int mpos)
   {
     if (map!=null) {
       int[] mp = map.shiftTo(mpos);
@@ -103,14 +103,14 @@ public class Mapping {
     if (map!=null) {
       int[] mp=map.shiftTo(mpos);
       if (mp!=null) {
-        return new int[] {mp[0], mp[0]+mp[2]*(map.getFromRatio()-1)}; 
+        return new int[] {mp[0], mp[0]+mp[2]*(map.getFromRatio()-1)};
       }
     }
     return null;
   }
   /**
-   * width of mapped unit in associated sequence 
-   * 
+   * width of mapped unit in associated sequence
+   *
    */
   public int getWidth() {
     if (map!=null) {
@@ -157,18 +157,13 @@ public class Mapping {
     return null;
   }
   /**
-   * locates the region of feature f in the associated sequence's reference frame 
+   * locates the region of feature f in the associated sequence's reference frame
    * @param f
    * @return one or more features corresponding to f
    */
   public SequenceFeature[] locateFeature(SequenceFeature f)
   {
-    // this is a stopgap - features broken over exon boundaries will not be
-    // broken into a collection of feature fragments.
-    // TODO: implement creation of several features from a single feature on a discontinuously mapped seuqence
-    // need a function like int [] fromrange = map.getRange(from,to)
-    // need to make subgrouped sequence features.
-    if (true) {
+    if (true) { // f.getBegin()!=f.getEnd()) {
       if (map!=null) {
         int[] frange = map.locateInFrom(f.getBegin(), f.getEnd());
         SequenceFeature[] vf = new SequenceFeature[frange.length/2];
@@ -182,16 +177,17 @@ public class Mapping {
         return vf;
       }
     }
-    if (false){
+    if (false) //else
+    {
       int[] word = getWord(f.getBegin());
-      if (word[0]<word[1]) 
+      if (word[0]<word[1])
       {
         f.setBegin(word[0]);
       } else {
         f.setBegin(word[1]);
       }
       word = getWord(f.getEnd());
-      if (word[0]>word[1]) 
+      if (word[0]>word[1])
       {
         f.setEnd(word[0]);
       } else {
@@ -201,7 +197,7 @@ public class Mapping {
     // give up and just return the feature.
     return new SequenceFeature[] { f };
   }
-      
+
     /**
    * return a series of contigs on the associated sequence corresponding to
    * the from,to interval on the mapped reference frame
@@ -221,7 +217,7 @@ public class Mapping {
    * @return
    */
   public int[] locateMappedRange(int from, int to) {
-    //TODO 
+    //TODO
     return null;
   }
 }