JAL-3763 test coverage for AlignedCodonFrame.markMappedRegion
[jalview.git] / src / jalview / datamodel / AlignedCodonFrame.java
index d59078b..a9875b4 100644 (file)
@@ -170,6 +170,10 @@ public class AlignedCodonFrame
       int[] codon = null;
       SequenceI mappedSeq = null;
       SequenceI ds = seq.getDatasetSequence();
+      if (ds == null)
+      {
+        ds = seq;
+      }
       
       if (this.fromSeq == seq || this.fromSeq == ds)
       {
@@ -379,7 +383,8 @@ public class AlignedCodonFrame
 
   /**
    * Add search results for regions in other sequences that translate or are
-   * translated from a particular position in seq
+   * translated from a particular position in seq (which may be an aligned or
+   * dataset sequence)
    * 
    * @param seq
    * @param index
@@ -391,44 +396,14 @@ public class AlignedCodonFrame
           SearchResultsI results)
   {
     SequenceI ds = seq.getDatasetSequence();
-    for (SequenceToSequenceMapping ssm : mappings)
+    if (ds == null)
     {
-      ssm.markMappedRegion(ds, index, results);
+      ds = seq;
     }
-  }
-
-  /**
-   * Returns the DNA codon positions (base 1) for the given position (base 1) in
-   * a mapped protein sequence, or null if no mapping is found.
-   * 
-   * Intended for use in aligning cDNA to match aligned protein. Only the first
-   * mapping found is returned, so not suitable for use if multiple protein
-   * sequences are mapped to the same cDNA (but aligning cDNA as protein is
-   * ill-defined for this case anyway).
-   * 
-   * @param seq
-   *          the DNA dataset sequence
-   * @param aaPos
-   *          residue position (base 1) in a protein sequence
-   * @return
-   */
-  public int[] getDnaPosition(SequenceI seq, int aaPos)
-  {
-    /*
-     * Adapted from markMappedRegion().
-     */
-    MapList ml = null;
-    int i = 0;
     for (SequenceToSequenceMapping ssm : mappings)
     {
-      if (ssm.fromSeq == seq)
-      {
-        ml = getdnaToProt()[i];
-        break;
-      }
-      i++;
+      ssm.markMappedRegion(ds, index, results);
     }
-    return ml == null ? null : ml.locateInFrom(aaPos, aaPos);
   }
 
   /**