From 6e2c975d1b0b32b54da3e2854a75dae607a4bfd3 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 5 May 2016 14:25:30 +0100 Subject: [PATCH] =?utf8?q?JAL-192=20patch=20for=20off-by=20one=20and=20patho?= =?utf8?q?logical=20case=20(hide=20inserted=20regions=20+=20set=20reference=20?= =?utf8?q?sequence=20->=20column=20positions=20numbered=20with=20seq-number+?= =?utf8?q?=E2=80=99-=E2=80=98=20!=20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/datamodel/ColumnSelection.java | 2 +- src/jalview/gui/ScalePanel.java | 4 ++-- test/jalview/datamodel/ColumnSelectionTest.java | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) 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() { -- 1.7.10.2