JAL-845 implement alignment of protein to match cDNA alignment
[jalview.git] / src / jalview / datamodel / AlignedCodonFrame.java
index 9c17306..cbddf1c 100644 (file)
@@ -123,6 +123,32 @@ public class AlignedCodonFrame
   }
 
   /**
+   * Returns the first mapping found which is to or from the given sequence, or
+   * null.
+   * 
+   * @param seq
+   * @return
+   */
+  public Mapping getMappingForSequence(SequenceI seq)
+  {
+    if (dnaSeqs == null)
+    {
+      return null;
+    }
+    SequenceI seqDs = seq.getDatasetSequence();
+    seqDs = seqDs != null ? seqDs : seq;
+
+    for (int ds = 0; ds < dnaSeqs.length; ds++)
+    {
+      if (dnaSeqs[ds] == seqDs || dnaToProt[ds].to == seqDs)
+      {
+        return dnaToProt[ds];
+      }
+    }
+    return null;
+  }
+
+  /**
    * Return the corresponding aligned or dataset aa sequence for given dna
    * sequence, null if not found.
    *