JAL-1691 linked scrollling in split frame (Desktop)
[jalview.git] / src / jalview / util / MappingUtils.java
index ece1bac..c6cbdc5 100644 (file)
@@ -608,4 +608,28 @@ public final class MappingUtils
     }
     return result;
   }
+
+  /**
+   * Returns a list of any mappings that are from or to the given (aligned or
+   * dataset) sequence.
+   * 
+   * @param sequence
+   * @param mappings
+   * @return
+   */
+  public static List<AlignedCodonFrame> findMappingsForSequence(
+          SequenceI sequence, Set<AlignedCodonFrame> mappings)
+  {
+    List<AlignedCodonFrame> result = new ArrayList<AlignedCodonFrame>();
+    if (sequence == null || mappings == null)
+    {
+      return result;
+    }
+    for (AlignedCodonFrame mapping : mappings) {
+      if (mapping.involvesSequence(sequence)) {
+        result.add(mapping);
+      }
+    }
+    return result;
+  }
 }