JAL-2147 additional test coverage for findMappingsForSequenceAndOthers
[jalview.git] / src / jalview / util / MappingUtils.java
index 515ff51..da83338 100644 (file)
@@ -757,9 +757,19 @@ public final class MappingUtils
     return findMappingsForSequenceAndOthers(sequence, mappings, null);
   }
 
+  /**
+   * Returns a list of any mappings that are from or to the given (aligned or
+   * dataset) sequence, optionally limited to mappings involving one of a given
+   * list of sequences.
+   * 
+   * @param sequence
+   * @param mappings
+   * @param filterList
+   * @return
+   */
   public static List<AlignedCodonFrame> findMappingsForSequenceAndOthers(
           SequenceI sequence, List<AlignedCodonFrame> mappings,
-          AlignmentI alignment)
+          List<SequenceI> filterList)
   {
     List<AlignedCodonFrame> result = new ArrayList<AlignedCodonFrame>();
     if (sequence == null || mappings == null)
@@ -770,14 +780,14 @@ public final class MappingUtils
     {
       if (mapping.involvesSequence(sequence))
       {
-        if (alignment != null)
+        if (filterList != null)
         {
-          for (SequenceI otherseq : alignment.getSequences())
+          for (SequenceI otherseq : filterList)
           {
+            SequenceI otherDataset = otherseq.getDatasetSequence();
             if (otherseq == sequence
-                    || (otherseq.getDatasetSequence() != null && (otherseq
-                            .getDatasetSequence() == sequence || otherseq
-                            .getDatasetSequence() == sequence
+                    || otherseq == sequence.getDatasetSequence()
+                    || (otherDataset != null && (otherDataset == sequence || otherDataset == sequence
                             .getDatasetSequence())))
             {
               // skip sequences in subset which directly relate to sequence