SimpleAlignedSequence implements AlignedSequence<S, C> { @Override public int getAlignmentIndexAt(int sequenceIndex) { if (alignmentFromSequence == null) { alignmentFromSequence = new int[original.getLength()]; int s = 1, a = 1; for (int i = 0; i < numBefore; i++, s++) { alignmentFromSequence[s - 1] = a; } for (; s <= alignmentFromSequence.length && a <= length; s++, a++) { while (a <= length && isGap(a)) { a++; } alignmentFromSequence[s - 1] = a; } a--; for (int i = 0; i < numAfter; i++, s++) { alignmentFromSequence[s - 1] = a; } } return alignmentFromSequence[sequenceIndex - 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 testGetAlignmentIndexAt() { assertEquals(global.getAlignmentIndexAt(1), 2); assertEquals(global.getAlignmentIndexAt(2), 3); assertEquals(global.getAlignmentIndexAt(3), 5); assertEquals(global.getAlignmentIndexAt(4), 6); assertEquals(local.getAlignmentIndexAt(1), 1); assertEquals(local.getAlignmentIndexAt(2), 1); assertEquals(local.getAlignmentIndexAt(3), 2); assertEquals(local.getAlignmentIndexAt(4), 5); assertEquals(local.getAlignmentIndexAt(5), 7); assertEquals(local.getAlignmentIndexAt(6), 8); assertEquals(local.getAlignmentIndexAt(7), 8); assertEquals(local.getAlignmentIndexAt(8), 8); assertEquals(local.getAlignmentIndexAt(9), 8); assertEquals(local2.getAlignmentIndexAt(1), 1); assertEquals(local2.getAlignmentIndexAt(2), 1); assertEquals(local2.getAlignmentIndexAt(3), 2); assertEquals(local2.getAlignmentIndexAt(4), 3); }
@Test(expected=IndexOutOfBoundsException.class) public void testGetAlignmentIndexAtOutOfBounds() { global.getAlignmentIndexAt(0); }
@Test(expected=IndexOutOfBoundsException.class) public void testGetAlignmentIndexAtOutOfBounds2() { global.getAlignmentIndexAt(5); }
@Test(expected=IndexOutOfBoundsException.class) public void testGetAlignmentIndexAtOutOfBounds3() { local.getAlignmentIndexAt(0); }
@Test(expected=IndexOutOfBoundsException.class) public void testGetAlignmentIndexAtOutOfBounds4() { local.getAlignmentIndexAt(10); }