Realigned { @NotNull static RealignedContext realigned(int baseStartIndex, int baseEndIndex, final byte[] bases, final int otherBaseIndex, final byte[] otherBases, int maxDistance) { if (otherBaseIndex >= 0) { final RealignedContext context = realigned(baseStartIndex, baseEndIndex, bases, otherBaseIndex, otherBases); if (context.type() != RealignedType.NONE) { return context; } } RealignedContext result = NONE; for (int i = -maxDistance; i <= maxDistance; i++) { int otherBaseIndexWithOffset = otherBaseIndex + i; if (i != 0 && otherBaseIndexWithOffset >= 0) { final RealignedContext context = realigned(baseStartIndex, baseEndIndex, bases, otherBaseIndexWithOffset, otherBases); if (context.type() != RealignedType.NONE) { if (context.type() == RealignedType.EXACT) { return context; } result = context; } } } return result; }  @NotNull static RealignedContext realignedAroundIndex(@NotNull final ReadContext readContext, final int otherBaseIndex,
            final byte[] otherBases, int maxSize); static final int MAX_REPEAT_SIZE; }
@Test public void testRealignedTooShort() { String sequence = "GAGAGTGTGTGTGTGTGTCTGTGTGTATGTATATATATATATATATATATCACATTTTT"; String truncatedAtEnd = "GAGAGTGTGTGTGTGTGTCTGTGTGTATGTATATATATATATATATATATCACATTTT"; String truncatedAtStart = "GAGTGTGTGTGTGTGTCTGTGTGTATGTATATATATATATATATATATCACATTTTT"; int startIndex = 0; int endIndex = sequence.length() - 1; assertRealigned(EXACT, realigned(startIndex, endIndex, sequence.getBytes(), startIndex, sequence.getBytes(), 0)); assertRealigned(NONE, realigned(startIndex, endIndex, sequence.getBytes(), startIndex, truncatedAtEnd.getBytes(), 0)); assertRealigned(NONE, realigned(startIndex, endIndex, sequence.getBytes(), -2, truncatedAtStart.getBytes(), 0)); }
@Test public void testRealigned() { String sequence = "GAGAGTGTGTGTGTGTGTCTGTGTGTATGTATATATATATATATATATATCACATTTTTATTATTG"; int startIndex = 3; int endIndex = startIndex + 55; assertRealigned(EXACT, realigned(startIndex, endIndex, sequence.getBytes(), startIndex, sequence.getBytes(), 0)); assertRealigned(NONE, realigned(startIndex, endIndex, sequence.getBytes(), startIndex - 1, sequence.getBytes(), 0)); assertRealigned(NONE, realigned(startIndex, endIndex, sequence.getBytes(), startIndex + 1, sequence.getBytes(), 0)); assertRealigned(NONE, realigned(startIndex, endIndex, sequence.getBytes(), startIndex - 2, sequence.getBytes(), 1)); assertRealigned(EXACT, realigned(startIndex, endIndex, sequence.getBytes(), startIndex - 1, sequence.getBytes(), 1)); assertRealigned(EXACT, realigned(startIndex, endIndex, sequence.getBytes(), startIndex + 1, sequence.getBytes(), 1)); assertRealigned(NONE, realigned(startIndex, endIndex, sequence.getBytes(), startIndex + 2, sequence.getBytes(), 1)); assertRealigned(EXACT, realigned(startIndex, endIndex, sequence.getBytes(), startIndex - 2, sequence.getBytes(), 2)); assertRealigned(EXACT, realigned(startIndex, endIndex, sequence.getBytes(), startIndex + 2, sequence.getBytes(), 2)); }
@Test public void testPolyA() { String shorter = "GATCAAAAAAAAAGATC"; String ref = "GATCAAAAAAAAAAGATC"; String longer = "GATCAAAAAAAAAAAGATC"; int startIndex = 0; int endIndex = ref.length() - 1; assertRealigned(EXACT, realigned(startIndex, endIndex, ref.getBytes(), startIndex, ref.getBytes(), 10)); assertRealigned(SHORTENED, 9, realigned(startIndex, endIndex, ref.getBytes(), startIndex, shorter.getBytes(), 10)); assertRealigned(LENGTHENED, 11, realigned(startIndex, endIndex, ref.getBytes(), startIndex, longer.getBytes(), 10)); }
@Test public void testDiNucleotideRepeat() { String shorter = "GATCATATATATGATC"; String ref = "GATCATATATATATGATC"; String longer = "GATCATATATATATATGATC"; int startIndex = 0; int endIndex = ref.length() - 1; assertRealigned(EXACT, realigned(startIndex, endIndex, ref.getBytes(), startIndex, ref.getBytes(), 10)); assertRealigned(SHORTENED, 4, realigned(startIndex, endIndex, ref.getBytes(), startIndex, shorter.getBytes(), 10)); assertRealigned(LENGTHENED, 6, realigned(startIndex, endIndex, ref.getBytes(), startIndex, longer.getBytes(), 10)); }