SequenceI replaceSequenceAt(int i, SequenceI seq);
/**
- * Deletes a sequence from the alignment
+ * Deletes a sequence from the alignment. Updates hidden sequences to account
+ * for the removed sequence. Do NOT use this method to delete sequences which
+ * are just hidden.
*
* @param s
* Sequence to be deleted.
void deleteSequence(SequenceI s);
/**
- * Deletes a sequence from the alignment.
+ * Deletes a sequence from the alignment. Updates hidden sequences to account
+ * for the removed sequence. Do NOT use this method to delete sequences which
+ * are just hidden.
*
* @param i
* Index of sequence to be deleted.
void deleteSequence(int i);
/**
+ * Deletes a sequence in the alignment which has been hidden.
+ *
+ * @param i
+ * Index of sequence to be deleted
+ */
+ void deleteHiddenSequence(int i);
+
+ /**
* Finds sequence in alignment using sequence name as query.
*
* @param name
* @return
*/
public int[] getVisibleStartAndEndIndex(List<int[]> hiddenCols);
+
}
hiddenSequences = new SequenceI[alignment.getHeight()];
}
- int alignmentIndex = alignment.findIndex(sequence);
- alignmentIndex = adjustForHiddenSeqs(alignmentIndex);
+ int absAlignmentIndex = alignment.findIndex(sequence);
+ int alignmentIndex = adjustForHiddenSeqs(absAlignmentIndex);
if (hiddenSequences[alignmentIndex] != null)
{
hiddenSequences[alignmentIndex] = sequence;
- alignment.deleteSequence(sequence);
+ alignment.deleteHiddenSequence(absAlignmentIndex);
}
public List<SequenceI> showAll(
assertEquals(10, al.getHeight());
}
+ /**
+ * Test the method that adds a sequence to the hidden sequences and deletes it
+ * from the alignment, and its converse, where the first hidden sequences are
+ * at the bottom of the alignment (JAL-2437)
+ */
+ @Test(groups = "Functional")
+ public void testHideShowLastSequences()
+ {
+ AlignmentI al = new Alignment(seqs);
+ assertTrue(al.getSequences().contains(seqs[1]));
+ HiddenSequences hs = al.getHiddenSequences();
+ assertEquals(0, hs.getSize());
+ assertEquals(10, al.getHeight());
+
+ /*
+ * hide the last sequence in the alignment
+ */
+ hs.hideSequence(seqs[9]);
+ assertFalse(hs.isHidden(seqs[8]));
+ assertTrue(hs.isHidden(seqs[9]));
+ assertFalse(al.getSequences().contains(seqs[9]));
+ assertEquals(1, hs.getSize());
+ assertEquals(9, al.getHeight());
+
+ /*
+ * hide the third last sequence in the alignment
+ */
+ hs.hideSequence(seqs[7]);
+ assertFalse(hs.isHidden(seqs[8]));
+ assertTrue(hs.isHidden(seqs[7]));
+ assertFalse(al.getSequences().contains(seqs[7]));
+ assertEquals(2, hs.getSize());
+ assertEquals(8, al.getHeight());
+
+ /*
+ * reveal all the sequences, which should be reinstated in the same order as they started in
+ */
+ hs.showAll(null);
+ assertFalse(hs.isHidden(seqs[7]));
+ assertFalse(hs.isHidden(seqs[9]));
+ assertEquals(seqs[7], al.getSequences().get(7));
+ assertEquals(seqs[8], al.getSequences().get(8));
+ assertEquals(seqs[9], al.getSequences().get(9));
+ assertEquals(0, hs.getSize());
+ assertEquals(10, al.getHeight());
+ }
+
@Test(groups = "Functional")
public void testIsHidden()
{