{
int fpos=seq.getStart(),lpos= seq.getEnd();
int start = 0;
- int end = seq.getLength();
if (hiddenColumns == null || hiddenColumns.size() == 0)
{
- return new int[] { seq.findIndex(fpos), seq.findIndex(lpos), fpos,
+ return new int[] { seq.findIndex(fpos) - 1, seq.findIndex(lpos) - 1,
+ fpos,
lpos };
}
List<int[]> regions = getHiddenColumns();
int spos = fpos, lastvispos = -1, rcount = 0, hideStart = seq
.getLength(), hideEnd = -1;
- int visPrev = 0, visNext = 0, base = 0;
+ int visPrev = 0, visNext = 0;
boolean foundStart = false;
for (int p = 0, pLen = seq.getLength(); spos <= seq.getEnd()
&& p < pLen; p++)
while (hideEnd < p && rcount < regions.size())
{
int[] region = regions.get(rcount++);
- visNext += region[1] + 1 - region[0];
- visPrev = visNext-1;
+ visPrev = visNext;
+ visNext += region[0] - visPrev;
hideStart = region[0];
hideEnd = region[1];
}
public void testLocateVisibleBoundsofSequence()
{
ColumnSelection cs = new ColumnSelection();
- SequenceI seq = new Sequence("RefSeq", "-A-SD-ASD--E");
+ SequenceI seq = new Sequence("RefSeq", "-A-SD-ASD--E---");
assertEquals(2, seq.findIndex(seq.getStart()));
- assertEquals(Arrays.toString(new int[] { seq.findIndex(seq.getStart()),
- seq.findIndex(seq.getEnd()), seq.getStart(), seq.getEnd() }),
+
+ // no hidden columns
+ assertEquals(
+ Arrays.toString(new int[] { seq.findIndex(seq.getStart()) - 1,
+ seq.findIndex(seq.getEnd()) - 1, seq.getStart(),
+ seq.getEnd() }),
+ Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
+
+ // hidden column on gap after end of sequence - should not affect bounds
+ cs.hideColumns(13);
+ assertEquals(
+ Arrays.toString(new int[] { seq.findIndex(seq.getStart()) - 1,
+ seq.findIndex(seq.getEnd()) - 1, seq.getStart(),
+ seq.getEnd() }),
+ Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
+
+ cs.revealAllHiddenColumns();
+ // hidden column on gap before beginning of sequence - should vis bounds by
+ // one
+ cs.hideColumns(0);
+ assertEquals(
+ Arrays.toString(new int[] { seq.findIndex(seq.getStart()) - 2,
+ seq.findIndex(seq.getEnd()) - 2, seq.getStart(),
+ seq.getEnd() }),
Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
+
+ cs.revealAllHiddenColumns();
+ // hide columns around most of sequence - leave one residue remaining
cs.hideColumns(1, 3);
cs.hideColumns(6, 11);
assertEquals("-D",
cs.getVisibleSequenceStrings(0, 5, new SequenceI[] { seq })[0]);
assertEquals(Arrays.toString(new int[] { 1, 1, 3, 3 }),
Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
+ cs.revealAllHiddenColumns();
+
+ // hide whole sequence - should just get location of hidden region
+ // containing sequence
+ cs.hideColumns(1, 11);
+ assertEquals(Arrays.toString(new int[] { 0, 1, 0, 0 }),
+ Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
+
}
@Test(groups = { "Functional" })