JAL-2114 save 'raw' ENA location as a sequence feature attribute
[jalview.git] / src / jalview / datamodel / AlignedCodonFrame.java
index a56f1d4..6d6cdb5 100644 (file)
@@ -649,4 +649,29 @@ public class AlignedCodonFrame
   {
     return mappings == null ? "null" : mappings.toString();
   }
+
+  /**
+   * Returns the first mapping found that is from 'fromSeq' to 'toSeq', or null
+   * if none found
+   * 
+   * @param fromSeq
+   *          aligned or dataset sequence
+   * @param toSeq
+   *          aligned or dataset sequence
+   * @return
+   */
+  public Mapping getMappingBetween(SequenceI fromSeq, SequenceI toSeq)
+  {
+    for (SequenceToSequenceMapping mapping : mappings)
+    {
+      SequenceI from = mapping.fromSeq;
+      SequenceI to = mapping.mapping.to;
+      if ((from == fromSeq || from == fromSeq.getDatasetSequence())
+              && (to == toSeq || to == toSeq.getDatasetSequence()))
+      {
+        return mapping.mapping;
+      }
+    }
+    return null;
+  }
 }