X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FMappingUtils.java;h=1fe452d410d74c305a82c4da04aea41d0b84df71;hb=refs%2Fheads%2Freleases%2FRelease_2_10_0_Branch;hp=ae4e55d3a31eea6ea64d8f4b742457627f03db1f;hpb=0e6751ef949bc0bad9a44220262b7e0d6e46c563;p=jalview.git diff --git a/src/jalview/util/MappingUtils.java b/src/jalview/util/MappingUtils.java index ae4e55d..1fe452d 100644 --- a/src/jalview/util/MappingUtils.java +++ b/src/jalview/util/MappingUtils.java @@ -374,7 +374,8 @@ public final class MappingUtils /* * Found a sequence mapping. Locate the start/end mapped residues. */ - List mapping = Arrays.asList(new AlignedCodonFrame[] { acf }); + List mapping = Arrays + .asList(new AlignedCodonFrame[] { acf }); SearchResults sr = buildSearchResults(selected, startResiduePos, mapping); for (Match m : sr.getResults()) @@ -555,9 +556,9 @@ public final class MappingUtils * @param fromGapChar */ protected static void mapHiddenColumns(int[] hidden, - List mappings, - ColumnSelection mappedColumns, List fromSequences, - List toSequences, char fromGapChar) + List mappings, ColumnSelection mappedColumns, + List fromSequences, List toSequences, + char fromGapChar) { for (int col = hidden[0]; col <= hidden[1]; col++) { @@ -589,9 +590,9 @@ public final class MappingUtils * @param fromGapChar */ protected static void mapColumn(int col, - List mappings, - ColumnSelection mappedColumns, List fromSequences, - List toSequences, char fromGapChar) + List mappings, ColumnSelection mappedColumns, + List fromSequences, List toSequences, + char fromGapChar) { int[] mappedTo = findMappedColumns(col, mappings, fromSequences, toSequences, fromGapChar); @@ -646,8 +647,7 @@ public final class MappingUtils * Get the residue position and find the mapped position. */ int residuePos = fromSeq.findPosition(col); - SearchResults sr = buildSearchResults(fromSeq, residuePos, - mappings); + SearchResults sr = buildSearchResults(fromSeq, residuePos, mappings); for (Match m : sr.getResults()) { int mappedStartResidue = m.getStart(); @@ -754,6 +754,23 @@ public final class MappingUtils public static List findMappingsForSequence( SequenceI sequence, List mappings) { + 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 findMappingsForSequenceAndOthers( + SequenceI sequence, List mappings, + List filterList) + { List result = new ArrayList(); if (sequence == null || mappings == null) { @@ -763,7 +780,31 @@ public final class MappingUtils { if (mapping.involvesSequence(sequence)) { - result.add(mapping); + if (filterList != null) + { + for (SequenceI otherseq : filterList) + { + SequenceI otherDataset = otherseq.getDatasetSequence(); + if (otherseq == sequence + || otherseq == sequence.getDatasetSequence() + || (otherDataset != null && (otherDataset == sequence || otherDataset == sequence + .getDatasetSequence()))) + { + // skip sequences in subset which directly relate to sequence + continue; + } + if (mapping.involvesSequence(otherseq)) + { + // selected a mapping contained in subselect alignment + result.add(mapping); + break; + } + } + } + else + { + result.add(mapping); + } } } return result; @@ -852,7 +893,7 @@ public final class MappingUtils { return ranges; } - + int[] copy = Arrays.copyOf(ranges, ranges.length); int sxpos = -1; int cdspos = 0; @@ -880,7 +921,7 @@ public final class MappingUtils break; } } - + if (sxpos > 0) { /*