From 834dcc21a8a324b092285c1295df9392654d526b Mon Sep 17 00:00:00 2001 From: kiramt Date: Thu, 29 Jun 2017 14:02:45 +0100 Subject: [PATCH] JAL-2597 Fix and unit test --- src/jalview/datamodel/HiddenColumns.java | 3 +- test/jalview/datamodel/HiddenColumnsTest.java | 42 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/jalview/datamodel/HiddenColumns.java b/src/jalview/datamodel/HiddenColumns.java index d34b316..169b0a4 100644 --- a/src/jalview/datamodel/HiddenColumns.java +++ b/src/jalview/datamodel/HiddenColumns.java @@ -1407,8 +1407,7 @@ public class HiddenColumns // recover mapping between sequence's non-gap positions and positions // mapping to view. pruneDeletions(ShiftList.parseMap(origseq.gapMap())); - int[] viscontigs = al.getHiddenColumns().getVisibleContigs(0, - profileseq.getLength()); + int[] viscontigs = getVisibleContigs(0, profileseq.getLength()); int spos = 0; int offset = 0; diff --git a/test/jalview/datamodel/HiddenColumnsTest.java b/test/jalview/datamodel/HiddenColumnsTest.java index fbb354b..7c88d71 100644 --- a/test/jalview/datamodel/HiddenColumnsTest.java +++ b/test/jalview/datamodel/HiddenColumnsTest.java @@ -689,4 +689,46 @@ public class HiddenColumnsTest 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)); + + } } -- 1.7.10.2