From: kiramt Date: Tue, 26 Sep 2017 13:49:16 +0000 (+0100) Subject: JAL-2674 Changed CigarArray constructor to use HiddenColumns iterator X-Git-Tag: Release_2_10_4~55^2~1^2~104 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7c70de6dbc24545b9da5aac77896220d15394fb9;p=jalview.git JAL-2674 Changed CigarArray constructor to use HiddenColumns iterator --- diff --git a/src/jalview/datamodel/CigarArray.java b/src/jalview/datamodel/CigarArray.java index b6224c2..d90b3cd 100644 --- a/src/jalview/datamodel/CigarArray.java +++ b/src/jalview/datamodel/CigarArray.java @@ -20,7 +20,7 @@ */ package jalview.datamodel; -import java.util.List; +import java.util.Iterator; public class CigarArray extends CigarBase { @@ -90,9 +90,7 @@ public class CigarArray extends CigarBase SequenceGroup selectionGroup) { this(constructSeqCigarArray(alignment, selectionGroup)); - constructFromAlignment(alignment, - hidden != null ? hidden.getHiddenColumnsCopy() : null, - selectionGroup); + constructFromAlignment(alignment, hidden, selectionGroup); } private static int[] _calcStartEndBounds(AlignmentI alignment, @@ -154,22 +152,29 @@ public class CigarArray extends CigarBase * @param selectionGroup */ private void constructFromAlignment(AlignmentI alignment, - List list, SequenceGroup selectionGroup) + HiddenColumns hidden, SequenceGroup selectionGroup) { int[] _startend = _calcStartEndBounds(alignment, selectionGroup); - int start = _startend[1], end = _startend[2]; + int start = _startend[1]; + int end = _startend[2]; // now construct the CigarArray operations - if (list != null) + if (hidden != null) { int[] region; - int hideStart, hideEnd; + int hideStart; + int hideEnd; int last = start; - for (int j = 0; last < end & j < list.size(); j++) + + Iterator regions = hidden.getBoundedIterator(start, end, true); + while (regions.hasNext()) { - region = list.get(j); + region = regions.next(); hideStart = region[0]; hideEnd = region[1]; + // edit hidden regions to selection range + // TODO possible bug here in original code: if hideEnd==last we continue + // but shouldn't this be a single D at start? if (hideStart < last) { if (hideEnd > last) @@ -206,6 +211,7 @@ public class CigarArray extends CigarBase addOperation(CigarArray.D, 1 + hideEnd - hideStart); last = hideEnd + 1; } + // Final match if necessary. if (last < end) {