From b61d853baef9db35859efb45d331becfdd11e61d Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Wed, 16 Sep 2015 18:38:24 +0100 Subject: [PATCH] JAL-1486 off-by-one error bugfix --- src/jalview/gui/AlignFrame.java | 19 ++++++++----------- src/jalview/io/FormatAdapter.java | 5 +---- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 88271b9..360cf6b 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1309,19 +1309,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, int startPos = aligmentStartEnd[0]; int endPos = aligmentStartEnd[1]; - int[] lowestRange = new int[2]; - int[] higestRange = new int[2]; + int[] lowestRange = new int[] { -1, -1 }; + int[] higestRange = new int[] { -1, -1 }; for (int[] hiddenCol : hiddenCols) { - // System.out.println("comparing : " + hiddenCol[0] + "-" + hiddenCol[1]); lowestRange = (hiddenCol[0] <= startPos) ? hiddenCol : lowestRange; higestRange = (hiddenCol[1] >= endPos) ? hiddenCol : higestRange; } - // System.out.println("min : " + lowestRange[0] + "-" + lowestRange[1]); - // System.out.println("max : " + higestRange[0] + "-" + higestRange[1]); - if (lowestRange[0] == 0 && lowestRange[1] == 0) + if (lowestRange[0] == -1 && lowestRange[1] == -1) { startPos = aligmentStartEnd[0]; } @@ -1330,27 +1327,27 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, startPos = lowestRange[1] + 1; } - if (higestRange[0] == 0 && higestRange[1] == 0) + if (higestRange[0] == -1 && higestRange[1] == -1) { endPos = aligmentStartEnd[1]; } else { - endPos = higestRange[0]; + endPos = higestRange[0] - 1; } - // System.out.println("Export range : " + minPos + " - " + maxPos); + // System.out.println("Export range : " + startPos + " - " + endPos); return new int[] { startPos, endPos }; } public static void main(String[] args) { ArrayList hiddenCols = new ArrayList(); - hiddenCols.add(new int[] { 0, 4 }); + hiddenCols.add(new int[] { 0, 0 }); hiddenCols.add(new int[] { 6, 9 }); hiddenCols.add(new int[] { 11, 12 }); hiddenCols.add(new int[] { 33, 33 }); - hiddenCols.add(new int[] { 45, 50 }); + hiddenCols.add(new int[] { 50, 50 }); int[] x = getStartEnd(new int[] { 0, 50 }, hiddenCols); // System.out.println("Export range : " + x[0] + " - " + x[1]); diff --git a/src/jalview/io/FormatAdapter.java b/src/jalview/io/FormatAdapter.java index ebca31b..4ec077f 100755 --- a/src/jalview/io/FormatAdapter.java +++ b/src/jalview/io/FormatAdapter.java @@ -107,7 +107,6 @@ public class FormatAdapter extends AppletFormatAdapter { startRes = seqs[i].getStart(); endRes = seqs[i].getEnd(); - if (startEnd != null) { startIndex = startEnd[0]; @@ -127,9 +126,7 @@ public class FormatAdapter extends AppletFormatAdapter } startRes = seqs[i].findPosition(startIndex); - startRes = seqs[i].getStart() > 1 ? startRes - seqs[i].getStart() - : startRes; - endRes = seqs[i].findPosition(endIndex) - seqs[i].getStart(); + endRes = seqs[i].findPosition(endIndex); } tmp[i] = new Sequence(seqs[i].getName(), omitHiddenColumns[i], -- 1.7.10.2