+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_NullAnnotationsAndNoColsHidden()
+ {
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", null);
+ HiddenColumns hc = new HiddenColumns();
+ ann.makeVisibleAnnotation(hc);
+ assertThat(ann.annotations, is(nullValue()));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_NullAnnotationsAndTrim()
+ {
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", null);
+ HiddenColumns hc = new HiddenColumns();
+ ann.makeVisibleAnnotation(3, 5, hc);
+ assertThat(ann.annotations, is(nullValue()));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_NoColsHidden()
+ {
+ Annotation[] annots = new Annotation[] {
+ EMPTY_ANNOTATION, EMPTY_ANNOTATION, new Annotation(1),
+ new Annotation(2), new Annotation(3), EMPTY_ANNOTATION,
+ EMPTY_ANNOTATION, new Annotation(4), new Annotation(5),
+ EMPTY_ANNOTATION, new Annotation(6), new Annotation(7),
+ new Annotation(8) };
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ ann.makeVisibleAnnotation(hc);
+ assertThat(ann.annotations, matchesAnnotations(annots));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_HideCols()
+ {
+ Annotation[] annots = new Annotation[] {
+ new Annotation(0), new Annotation(1), new Annotation(2),
+ new Annotation(3), new Annotation(4), new Annotation(5),
+ new Annotation(6), new Annotation(7), new Annotation(8) };
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ hc.hideColumns(2, 6);
+ ann.makeVisibleAnnotation(hc);
+ var expected = new Annotation[] {
+ new Annotation(0), new Annotation(1), new Annotation(7),
+ new Annotation(8) };
+ assertThat(ann.annotations, matchesAnnotations(expected));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_ExplicitFullWidthAndHideCols()
+ {
+ Annotation[] annots = new Annotation[] {
+ new Annotation(0), new Annotation(1), new Annotation(2),
+ new Annotation(3), new Annotation(4), new Annotation(5),
+ new Annotation(6), new Annotation(7), new Annotation(8),
+ new Annotation(9), new Annotation(10), new Annotation(11) };
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ hc.hideColumns(4, 7);
+ ann.makeVisibleAnnotation(0, 11, hc);
+ assertThat(ann.annotations,
+ matchesAnnotations(new Annotation(0), new Annotation(1),
+ new Annotation(2), new Annotation(3), new Annotation(8),
+ new Annotation(9), new Annotation(10), new Annotation(11)));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_ExplicitFullWidthAndHideCols2()
+ {
+ Annotation[] annots = new Annotation[] {
+ new Annotation(0), new Annotation(1), new Annotation(2),
+ new Annotation(3), new Annotation(4), new Annotation(5),
+ new Annotation(6), new Annotation(7), new Annotation(8), };
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ hc.hideColumns(4, 7);
+ ann.makeVisibleAnnotation(0, 8, hc);
+ assertThat(ann.annotations,
+ matchesAnnotations(new Annotation(0), new Annotation(1),
+ new Annotation(2), new Annotation(3), new Annotation(8)));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_HideColsWithEmptyAnnots()
+ {
+ Annotation[] annots = new Annotation[] {
+ EMPTY_ANNOTATION, EMPTY_ANNOTATION, new Annotation(1),
+ new Annotation(2), new Annotation(3), EMPTY_ANNOTATION,
+ EMPTY_ANNOTATION, new Annotation(4), new Annotation(5),
+ EMPTY_ANNOTATION, new Annotation(6), new Annotation(7),
+ new Annotation(8) };
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ hc.hideColumns(1, 3);
+ hc.hideColumns(8, 9);
+ ann.makeVisibleAnnotation(hc);
+ var expected = new Annotation[] {
+ EMPTY_ANNOTATION, new Annotation(3), EMPTY_ANNOTATION, EMPTY_ANNOTATION,
+ new Annotation(4), new Annotation(6), new Annotation(7),
+ new Annotation(8) };
+ assertThat(ann.annotations, matchesAnnotations(expected));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_HideColsWithNullAnnots()
+ {
+ Annotation[] annots = new Annotation[] {
+ null, null, new Annotation(2), null, new Annotation(4),
+ new Annotation(5), null, null };
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ hc.hideColumns(2, 4);
+ ann.makeVisibleAnnotation(hc);
+ var expected = new Annotation[] {
+ null, null, new Annotation(5), null, null };
+ assertThat(ann.annotations, matchesAnnotations(expected));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_Truncate()
+ {
+ Annotation[] annots = new Annotation[] {
+ new Annotation(0), new Annotation(1), new Annotation(2),
+ new Annotation(3), new Annotation(4), new Annotation(5),
+ new Annotation(6), new Annotation(7) };
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ ann.makeVisibleAnnotation(3, 6, new HiddenColumns());
+ assertThat(ann.annotations, matchesAnnotations(new Annotation(3),
+ new Annotation(4), new Annotation(5), new Annotation(6)));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_TruncateAndHideColumns()
+ {
+ Annotation[] annots = new Annotation[] {
+ new Annotation(0), new Annotation(1), new Annotation(2),
+ new Annotation(3), new Annotation(4), new Annotation(5),
+ new Annotation(6), new Annotation(7), new Annotation(8),
+ new Annotation(9), new Annotation(10), new Annotation(11) };
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ hc.hideColumns(4, 7);
+ ann.makeVisibleAnnotation(1, 9, hc);
+ assertThat(ann.annotations,
+ matchesAnnotations(new Annotation(1), new Annotation(2),
+ new Annotation(3), new Annotation(8), new Annotation(9)));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_TruncateNegativeStart()
+ {
+ Annotation[] annots = annotsRange(8);
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ ann.makeVisibleAnnotation(-5, 1, hc);
+ assertThat(ann.annotations,
+ matchesAnnotations(new Annotation(0), new Annotation(1)));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_TruncateNegativeStartAndEnd()
+ {
+ Annotation[] annots = annotsRange(8);
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ ann.makeVisibleAnnotation(-5, -2, hc);
+ assertThat(ann.annotations, is(emptyArray()));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_TruncateEndBeyondSize()
+ {
+ Annotation[] annots = annotsRange(8);
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ ann.makeVisibleAnnotation(6, 10, hc);
+ assertThat(ann.annotations, matchesAnnotations(new Annotation(6), new Annotation(7)));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_TruncateStartAndEndBeyondSize()
+ {
+ Annotation[] annots = annotsRange(4);
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ ann.makeVisibleAnnotation(6, 10, hc);
+ assertThat(ann.annotations, is(emptyArray()));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_HiddenRegionBeyondSize()
+ {
+ Annotation[] annots = annotsRange(4);
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ hc.hideColumns(6, 7);
+ ann.makeVisibleAnnotation(hc);
+ assertThat(ann.annotations, matchesAnnotations(annots));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_HiddenRegionAndTrimEndBeyondSize()
+ {
+ Annotation[] annots = annotsRange(4);
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ hc.hideColumns(6, 7);
+ ann.makeVisibleAnnotation(0, 10, hc);
+ assertThat(ann.annotations, matchesAnnotations(annots));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_HiddenRegionBeforeStart()
+ {
+ Annotation[] annots = annotsRange(4);
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ hc.hideColumns(-3, -2);
+ ann.makeVisibleAnnotation(hc);
+ assertThat(ann.annotations, matchesAnnotations(annots));
+ }
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation_HiddenRegionAndTrimStartBeforeStart()
+ {
+ Annotation[] annots = annotsRange(4);
+ AlignmentAnnotation ann = new AlignmentAnnotation("label", "desc", annots);
+ HiddenColumns hc = new HiddenColumns();
+ hc.hideColumns(-3, -2);
+ ann.makeVisibleAnnotation(-5, annots.length - 1, hc);
+ assertThat(ann.annotations, matchesAnnotations(annots));
+ }
+
+ static Annotation[] annotsRange(int stop)
+ {
+ Annotation[] annotations = new Annotation[stop];
+ for (int i = 0; i < stop; i++)
+ annotations[i] = new Annotation(i);
+ return annotations;
+ }