X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FMappingUtils.java;h=1f2e8dbd26633ed7baa6aa5e15544a47aca57f43;hb=373a0f23b37fdd3c40d3ebb4a3c9120f5773bb45;hp=7dd0b5c0ab30cf2e89888f9f6c3d0a5323625049;hpb=10ff37d2cb03f342ddbed679951d3e2fef0a404b;p=jalview.git diff --git a/src/jalview/util/MappingUtils.java b/src/jalview/util/MappingUtils.java index 7dd0b5c..1f2e8db 100644 --- a/src/jalview/util/MappingUtils.java +++ b/src/jalview/util/MappingUtils.java @@ -16,7 +16,6 @@ import jalview.datamodel.SearchResults.Match; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; -import jalview.gui.AlignViewport; import java.util.ArrayList; import java.util.HashMap; @@ -259,7 +258,6 @@ public final class MappingUtils { acf.markMappedRegion(seq, index, results); } - results.addResult(seq, index, index); } return results; } @@ -385,8 +383,8 @@ public final class MappingUtils } /* - * Have to align the sequences before constructing the OrderCommand - which - * then realigns them?!? + * Have to sort the sequences before constructing the OrderCommand - which + * then resorts them?!? */ final SequenceI[] mappedOrderArray = mappedOrder .toArray(new SequenceI[mappedOrder.size()]); @@ -408,7 +406,7 @@ public final class MappingUtils * @return */ public static ColumnSelection mapColumnSelection(ColumnSelection colsel, - AlignViewportI mapFrom, AlignViewport mapTo) + AlignViewportI mapFrom, AlignViewportI mapTo) { boolean targetIsNucleotide = mapTo.isNucleotide(); AlignViewportI protein = targetIsNucleotide ? mapFrom : mapTo; @@ -417,8 +415,15 @@ public final class MappingUtils ColumnSelection mappedColumns = new ColumnSelection(); char fromGapChar = mapFrom.getAlignment().getGapCharacter(); - for (int col : colsel.getSelected()) + // FIXME allow for hidden columns + + /* + * For each mapped column, find the range of columns that residues in that + * column map to. + */ + for (Object obj : colsel.getSelected()) { + int col = ((Integer) obj).intValue(); int mappedToMin = Integer.MAX_VALUE; int mappedToMax = Integer.MIN_VALUE; @@ -448,7 +453,8 @@ public final class MappingUtils SequenceI mappedSeq = m.getSequence(); /* - * Locate the aligned sequence whose dataset is mappedSeq. + * Locate the aligned sequence whose dataset is mappedSeq. TODO a + * datamodel that can do this efficiently. */ for (SequenceI toSeq : mapTo.getAlignment().getSequences()) { @@ -460,12 +466,16 @@ public final class MappingUtils mappedToMax = Math.max(mappedToMax, mappedEndCol); // System.out.println(fromSeq.getName() + " mapped to cols " // + mappedStartCol + ":" + mappedEndCol); + break; + // note: remove break if we ever want to map one to many sequences } } } } /* - * Add mapped columns to mapped selection (converting base 1 to base 0) + * Add the range of mapped columns to the mapped selection (converting + * base 1 to base 0). Note that this may include intron-only regions which + * lie between the start and end ranges of the selection. */ for (int i = mappedToMin; i <= mappedToMax; i++) {