From: Jim Procter Date: Thu, 5 May 2016 13:25:30 +0000 (+0100) Subject: JAL-192 patch for off-by one and pathological case (hide inserted regions + set refer... X-Git-Tag: Release_2_10_0~227^2~4 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6e2c975d1b0b32b54da3e2854a75dae607a4bfd3;p=jalview.git JAL-192 patch for off-by one and pathological case (hide inserted regions + set reference sequence -> column positions numbered with seq-number+’-‘ ! ) --- diff --git a/src/jalview/datamodel/ColumnSelection.java b/src/jalview/datamodel/ColumnSelection.java index e3a8472..6fd76b2 100644 --- a/src/jalview/datamodel/ColumnSelection.java +++ b/src/jalview/datamodel/ColumnSelection.java @@ -600,7 +600,7 @@ public class ColumnSelection * Return absolute column index for a visible column index * * @param column - * int column index in alignment view + * int column index in alignment view (count from zero) * @return alignment column index for column */ public int adjustForHiddenColumns(int column) diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index aedb157..194066e 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -529,10 +529,10 @@ public class ScalePanel extends JPanel implements MouseMotionListener, { if (((i - refSp) % 10) == 0) { - iadj = av.getColumnSelection().adjustForHiddenColumns(i) - 1; + iadj = av.getColumnSelection().adjustForHiddenColumns(i - 1); if (refSeq == null) { - string = String.valueOf(iadj + 1); + string = String.valueOf(iadj); } else { diff --git a/test/jalview/datamodel/ColumnSelectionTest.java b/test/jalview/datamodel/ColumnSelectionTest.java index 63f80b2..86e7949 100644 --- a/test/jalview/datamodel/ColumnSelectionTest.java +++ b/test/jalview/datamodel/ColumnSelectionTest.java @@ -155,6 +155,21 @@ public class ColumnSelectionTest } + @Test(groups={"Functional"}) + public void testLocateVisibleBoundsPathologicals() + { + // test some pathological cases we missed + AlignmentI al = new Alignment(new SequenceI[] { new Sequence("refseqGaptest","KTDVTI----------NFI-----G----L")}); + ColumnSelection cs = new ColumnSelection(); + cs.hideInsertionsFor(al.getSequenceAt(0)); + assertEquals( + "G", + "" + + al.getSequenceAt(0).getCharAt( + cs.adjustForHiddenColumns(9))); + + + } @Test(groups = { "Functional" }) public void testHideColumns() {