+
+ @Test(groups = { "Functional" })
+ public void testFindHiddenRegionPositions()
+ {
+ HiddenColumns hc = new HiddenColumns();
+
+ List<Integer> positions = hc.findHiddenRegionPositions();
+ assertTrue(positions.isEmpty());
+
+ hc.hideColumns(3, 7);
+ hc.hideColumns(10, 10);
+ hc.hideColumns(14, 15);
+
+ positions = hc.findHiddenRegionPositions();
+ assertEquals(3, positions.size());
+ assertEquals(3, positions.get(0).intValue());
+ assertEquals(5, positions.get(1).intValue());
+ assertEquals(8, positions.get(2).intValue());
+ }
+
+ @Test(groups = { "Functional" })
+ public void testRegionsToString()
+ {
+ HiddenColumns hc = new HiddenColumns();
+
+ String result = hc.regionsToString(",", "--");
+ assertEquals("", result);
+
+ hc.hideColumns(3, 7);
+ hc.hideColumns(10, 10);
+ hc.hideColumns(14, 15);
+
+ result = hc.regionsToString(",", "--");
+ assertEquals("3--7,10--10,14--15", result);
+ }
+
+ @Test(groups = "Functional")
+ public void getVisibleStartAndEndIndexTest()
+ {
+ Sequence seq = new Sequence("testSeq", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+ AlignmentI align = new Alignment(new SequenceI[] { seq });
+ HiddenColumns hc = new HiddenColumns();
+
+ int[] startEnd = hc.getVisibleStartAndEndIndex(align.getWidth());
+ assertEquals(0, startEnd[0]);
+ assertEquals(25, startEnd[1]);
+
+ hc.hideColumns(0, 0);
+ startEnd = hc.getVisibleStartAndEndIndex(align.getWidth());
+ assertEquals(1, startEnd[0]);
+ assertEquals(25, startEnd[1]);
+
+ hc.hideColumns(6, 9);
+ hc.hideColumns(11, 12);
+ startEnd = hc.getVisibleStartAndEndIndex(align.getWidth());
+ assertEquals(1, startEnd[0]);
+ assertEquals(25, startEnd[1]);
+
+ hc.hideColumns(24, 25);
+ startEnd = hc.getVisibleStartAndEndIndex(align.getWidth());
+ System.out.println(startEnd[0] + " : " + startEnd[1]);
+ assertEquals(1, startEnd[0]);
+ assertEquals(23, startEnd[1]);
+ }
+
+ @Test(groups = "Functional")
+ public void testGetRegionWithEdgeAtRes()
+ {
+ HiddenColumns hc = new HiddenColumns();
+
+ int[] result = hc.getRegionWithEdgeAtRes(5);
+ assertNull(result);
+
+ hc.hideColumns(3, 7);
+ hc.hideColumns(10, 10);
+ hc.hideColumns(14, 15);
+
+ result = hc.getRegionWithEdgeAtRes(3);
+ assertEquals(3, result[0]);
+ assertEquals(7, result[1]);
+
+ result = hc.getRegionWithEdgeAtRes(5);
+ assertEquals(10, result[0]);
+ assertEquals(10, result[1]);
+
+ result = hc.getRegionWithEdgeAtRes(6);
+ assertNull(result);
+ }
+
+ @Test(groups = "Functional")
+ public void testPropagateInsertions()
+ {
+ // create an alignment with no gaps - this will be the profile seq and other
+ // JPRED seqs
+ AlignmentGenerator gen = new AlignmentGenerator(false);
+ AlignmentI al = gen.generate(20, 10, 1234, 0, 0);
+
+ // get the profileseq
+ SequenceI profileseq = al.getSequenceAt(0);
+ SequenceI gappedseq = new Sequence(profileseq);
+ gappedseq.insertCharAt(5, al.getGapCharacter());
+ gappedseq.insertCharAt(6, al.getGapCharacter());
+ gappedseq.insertCharAt(7, al.getGapCharacter());
+ gappedseq.insertCharAt(8, al.getGapCharacter());
+
+ // create an alignment view with the gapped sequence
+ SequenceI[] seqs = new SequenceI[1];
+ seqs[0] = gappedseq;
+ AlignmentI newal = new Alignment(seqs);
+ HiddenColumns hidden = new HiddenColumns();
+ hidden.hideColumns(15, 17);
+
+ AlignmentView view = new AlignmentView(newal, hidden, null, true, false,
+ false);
+
+ // confirm that original contigs are as expected
+ int[] oldcontigs = hidden.getVisibleContigs(0, 20);
+ int[] testcontigs = { 0, 14, 18, 19 };
+ assertTrue(Arrays.equals(oldcontigs, testcontigs));
+
+ // propagate insertions
+ HiddenColumns result = HiddenColumns.propagateInsertions(profileseq, al,
+ view);
+
+ // confirm that the contigs have changed to account for the gaps
+ int[] newcontigs = result.getVisibleContigs(0, 20);
+ testcontigs[1] = 10;
+ testcontigs[2] = 14;
+ assertTrue(Arrays.equals(newcontigs, testcontigs));
+
+ }