IndexedBases { public boolean phased(int offset, @NotNull final IndexedBases other) { int otherReadIndex = other.index + offset; boolean centreMatch = coreMatch(otherReadIndex, other.bases); if (!centreMatch) { return false; } boolean otherCentreMatch = other.coreMatch(index - offset, bases); if (!otherCentreMatch) { return false; } int leftFlankingBases = leftFlankMatchingBases(otherReadIndex, other.bases); if (leftFlankingBases < 0) { return false; } int rightFlankingBases = rightFlankMatchingBases(otherReadIndex, other.bases); return rightFlankingBases >= 0 && (rightFlankingBases >= flankSize || leftFlankingBases >= flankSize); } IndexedBases(final int position, final int index, final byte[] bases);  IndexedBases(final int position, final int index, final int leftCoreIndex, int rightCoreIndex, int flankSize,
            final byte[] bases); @NotNull static IndexedBases resize(final int position, final int recordIndex, final int recordLeftCoreIndex,
            final int recordRightCoreIndex, final int flankSize, final int additionalFlank, final byte[] recordBases); boolean phased(int offset, @NotNull final IndexedBases other); boolean isCentreCovered(int otherReadIndex, byte[] otherBases); @NotNull ReadContextMatch matchAtPosition(@NotNull final IndexedBases other); @NotNull ReadContextMatch matchAtPosition(int otherReadIndex, byte[] otherBases); @NotNull ReadContextMatch matchAtPosition(int otherReadIndex, int otherLength, byte[] otherBases); @NotNull String centerString(); @Override String toString(); int flankSize(); int index(); int index(int position); byte[] bases(); int leftCentreIndex(); int rightCentreIndex(); int position(); int leftFlankIndex(); int rightFlankIndex(); byte base(int position); int maxFlankLength(); byte[] trinucleotideContext(int position);  }
@Test public void testPhasedMNV() { ReadContext victim1 = new ReadContext(Strings.EMPTY, 1000, 4, 4, 4, 4, "GATCTTGAT".getBytes(), Strings.EMPTY); ReadContext victim2 = new ReadContext(Strings.EMPTY, 1001, 5, 5, 5, 4, "GATCTTGATC".getBytes(), Strings.EMPTY); assertTrue(victim1.phased(-1, victim2)); assertTrue(victim2.phased(1, victim1)); }
@Test public void testPhasedReadLongEnoughOnAtLeastOneSide() { ReadContext victim1 = new ReadContext(Strings.EMPTY, 1000, 4, 4, 4, 4, "GATCTTGA".getBytes(), Strings.EMPTY); ReadContext victim2 = new ReadContext(Strings.EMPTY, 1001, 5, 5, 5, 4, "GATCTTGATCT".getBytes(), Strings.EMPTY); assertTrue(victim1.phased(-1, victim2)); assertTrue(victim2.phased(1, victim1)); }
@Test public void testLongReadShortFlanks() { final String read = "TACCACAAATACATATACGTGTATCTGTCTGTGTGTTATGAACTTATATAAACCATCAC"; ReadContext victim1 = new ReadContext(Strings.EMPTY, 1010, 10, 9, 11, 3, read.getBytes(), Strings.EMPTY); ReadContext victim2 = new ReadContext(Strings.EMPTY, 1030, 40, 39, 41, 3, read.getBytes(), Strings.EMPTY); assertTrue(victim1.phased(-30, victim2)); assertTrue(victim2.phased(30, victim1)); }
@Test public void testBothCentreMatches() { ReadContext victim1 = new ReadContext(Strings.EMPTY, 1000, 4, 4, 4, 4, "AAAATGGGG".getBytes(), Strings.EMPTY); ReadContext victim2 = new ReadContext(Strings.EMPTY, 1005, 5, 5, 5, 4, "TGGGGACCCC".getBytes(), Strings.EMPTY); assertFalse(victim1.phased(-5, victim2)); assertFalse(victim2.phased(5, victim1)); }