RepeatContextFactory { public static int backwardRepeats(int index, int repeatLength, final byte[] readSequence) { for (int count = 1; ; count++) { if (!match(index, repeatLength, index - count * repeatLength, readSequence)) { return count - 1; } } } private  RepeatContextFactory(); @NotNull static Optional<RepeatContext> repeats(int index, final byte[] readSequence); @NotNull static Optional<RepeatContext> repeats(int index, @NotNull final String sequence); static int backwardRepeats(int index, int repeatLength, final byte[] readSequence);  }
@Test public void testBackwardRepeats() { final String sequence = "AAGATCATCATC"; assertEquals(1, RepeatContextFactory.backwardRepeats(6, 3, sequence.getBytes())); assertEquals(2, RepeatContextFactory.backwardRepeats(9, 3, sequence.getBytes())); }