SimpleAlignedSequence implements AlignedSequence<S, C> { @Override public int getSequenceIndexAt(int alignmentIndex) { if (sequenceFromAlignment == null) { sequenceFromAlignment = new int[length]; int a = 1, s = numBefore + 1; for (int i = 0; i < getStart().getPosition(); i++, a++) { sequenceFromAlignment[a - 1] = s; } for (; a <= length; a++) { if (!isGap(a)) { s++; } sequenceFromAlignment[a - 1] = s; } } return sequenceFromAlignment[alignmentIndex - 1]; } SimpleAlignedSequence(S original, List<Step> steps);  SimpleAlignedSequence(S original, List<Step> steps, int numBefore, int numAfter);  SimpleAlignedSequence(AlignedSequence<S, C> prev, List<Step> steps);  SimpleAlignedSequence(AlignedSequence<S, C> prev, List<Step> steps, int numBefore, int numAfter); @Override void clearCache(); @Override int getAlignmentIndexAt(int sequenceIndex); @Override Point getEnd(); @Override Location getLocationInAlignment(); @Override int getNumGaps(); @Override S getOriginalSequence(); @Override int getOverlapCount(); @Override int getSequenceIndexAt(int alignmentIndex); @Override Point getStart(); @Override boolean isCircular(); @Override boolean isGap(int alignmentIndex); @Override int countCompounds(C... compounds); @Override AccessionID getAccession(); @Override List<C> getAsList(); @Override C getCompoundAt(int alignmentIndex); @Override CompoundSet<C> getCompoundSet(); @Override int getIndexOf(C compound); @Override int getLastIndexOf(C compound); @Override int getLength(); @Override String getSequenceAsString(); @Override SequenceView<C> getSubSequence(Integer start, Integer end); @Override Iterator<C> iterator(); @Override String toString(); @Override //TODO Needs to implements SequenceView<C> getInverse();  }
@Test public void testGetSequenceIndexAt() { assertEquals(global.getSequenceIndexAt(1), 1); assertEquals(global.getSequenceIndexAt(2), 1); assertEquals(global.getSequenceIndexAt(3), 2); assertEquals(global.getSequenceIndexAt(4), 2); assertEquals(global.getSequenceIndexAt(5), 3); assertEquals(global.getSequenceIndexAt(6), 4); assertEquals(global.getSequenceIndexAt(7), 4); assertEquals(local.getSequenceIndexAt(1), 2); assertEquals(local.getSequenceIndexAt(2), 3); assertEquals(local.getSequenceIndexAt(3), 3); assertEquals(local.getSequenceIndexAt(4), 3); assertEquals(local.getSequenceIndexAt(5), 4); assertEquals(local.getSequenceIndexAt(6), 4); assertEquals(local.getSequenceIndexAt(7), 5); assertEquals(local.getSequenceIndexAt(8), 6); assertEquals(local2.getSequenceIndexAt(1), 2); assertEquals(local2.getSequenceIndexAt(2), 3); assertEquals(local2.getSequenceIndexAt(3), 4); }
@Test(expected=IndexOutOfBoundsException.class) public void testGetSequenceIndexAtOutOfBounds() { global.getSequenceIndexAt(0); }
@Test(expected=IndexOutOfBoundsException.class) public void testGetSequenceIndexAtOutOfBounds2() { global.getSequenceIndexAt(8); }
@Test(expected=IndexOutOfBoundsException.class) public void testGetSequenceIndexAtOutOfBounds3() { local.getSequenceIndexAt(0); }
@Test(expected=IndexOutOfBoundsException.class) public void testGetSequenceIndexAtOutOfBounds4() { local.getSequenceIndexAt(9); }