code: public BitapMatcher substitutionOnlyMatcherFirst(int substitutions, final Sequence sequence, int from, int to) {
          if (sequence.getAlphabet().size() != patternMask.length)
              throw new IllegalArgumentException();
  
          return new BitapMatcherImpl(substitutions + 1, from, to) {
              @Override
              public int findNext() {
                  long matchingMask = (1L << (size - 1));
  
                  int d;
                  long preMismatchTmp, mismatchTmp;
  
                  boolean match = false;
  
                  for (int i = current; i < to; ++i) {
                      long currentPatternMask = patternMask[sequence.codeAt(i)];
  
                      // Exact match on the previous step == match with insertion on current step
                      R[0] <<= 1;
                      mismatchTmp = R[0];
                      R[0] |= currentPatternMask;
  
                      if (0 == (R[0] & matchingMask)) {
                          errors = 0;
                          match = true;
                      }
  
                      for (d = 1; d < R.length; ++d) {
                          R[d] <<= 1;
                          preMismatchTmp = R[d];
                          R[d] |= currentPatternMask;
                          R[d] &= mismatchTmp;
                          if (!match && 0 == (R[d] & matchingMask) && i >= size - 1) {
                              errors = d;
                              match = true;
                          }
                          mismatchTmp = preMismatchTmp;
                      }
  
                      if (match) {
                          current = i + 1;
                          return i - size + 1;
                      }
                  }
                  current = to;
                  return -1;
              }
          };
      }
docs: Returns a BitapMatcher preforming a fuzzy search in a subsequence of {@code sequence}. Search range starts from
  {@code from} (inclusive) and ends at {@code to} (exclusive). Search allows no more than {@code substitutions}
  number of substitutions. Matcher will return positions of first matched letter in the motif in ascending order.
  
  @param substitutions maximal number of allowed substitutions
  @param sequence      target sequence
  @param from          left boundary of search range (inclusive)
  @param to            right boundary of search range (exclusive)
  @return matcher which will return positions of first matched letter in the motif in ascending order