}
@Override
+ public List<int[]> getInsertions()
+ {
+ ArrayList<int[]> map = new ArrayList<int[]>();
+ int lastj = -1, j = 0;
+ int pos = start;
+ int seqlen = sequence.length;
+ while ((j < seqlen))
+ {
+ if (jalview.util.Comparison.isGap(sequence[j]))
+ {
+ if (lastj == -1)
+ {
+ lastj = j;
+ }
+ }
+ else
+ {
+ if (lastj != -1)
+ {
+ map.add(new int[]
+ { lastj, j - 1 });
+ lastj = -1;
+ }
+ }
+ j++;
+ }
+ if (lastj != -1)
+ {
+ map.add(new int[]
+ { lastj, j - 1 });
+ lastj = -1;
+ }
+ return map;
+ }
+
+ @Override
public void deleteChars(int i, int j)
{
int newstart = start, newend = end;
seq = new Sequence("FER1", "AKPNGVL");
}
@Test
+ public void testInsertGapsAndGapmaps()
+ {
+ SequenceI aseq = seq.deriveSequence();
+ aseq.insertCharAt(2, 3, '-');
+ aseq.insertCharAt(6, 3, '-');
+ assertEquals("Gap insertions not correct", "AK---P---NGVL",
+ aseq.getSequenceAsString());
+ List<int[]> gapInt = aseq.getInsertions();
+ assertEquals("Gap interval 1 start wrong", 2, gapInt.get(0)[0]);
+ assertEquals("Gap interval 1 end wrong", 4, gapInt.get(0)[1]);
+ assertEquals("Gap interval 2 start wrong", 6, gapInt.get(1)[0]);
+ assertEquals("Gap interval 2 end wrong", 8, gapInt.get(1)[1]);
+ }
+
+ @Test
public void testGetAnnotation()
{
// initial state returns null not an empty array