code: protected void justify(Variant variant, int startOffset, int endOffset, String allele, String genomicSequence,
                           String strand) {
          StringBuilder stringBuilder = new StringBuilder(allele);
          // Justify to the left
          if ("-".equals(strand)) {
              while (startOffset > 0 && genomicSequence.charAt(startOffset - 1) == stringBuilder.charAt(stringBuilder.length() - 1)) {
                  stringBuilder.deleteCharAt(stringBuilder.length() - 1);
                  stringBuilder.insert(0, genomicSequence.charAt(startOffset - 1));
                  startOffset--;
                  endOffset--;
                  variant.setStart(variant.getStart() - 1);
                  variant.setEnd(variant.getEnd() - 1);
              }
          // Justify to the right
          } else {
              while ((endOffset + 1) < genomicSequence.length() && genomicSequence.charAt(endOffset + 1) == stringBuilder.charAt(0)) {
                  stringBuilder.deleteCharAt(0);
                  stringBuilder.append(genomicSequence.charAt(endOffset + 1));
                  startOffset++;
                  endOffset++;
                  variant.setStart(variant.getStart() + 1);
                  variant.setEnd(variant.getEnd() + 1);
              }
          }
          // Insertion
          if (variant.getReference().isEmpty()) {
              variant.setAlternate(stringBuilder.toString());
          // Deletion
          } else {
              variant.setReference(stringBuilder.toString());
          }
      }
docs: Justify an indel to the left or right along a sequence 'seq'.
  @param variant Variant object that needs to be justified. It will get modified accordingly.
  @param startOffset relative start position of the variant within genomicSequence (0-based).
  @param endOffset relative end position of the variant within genomicSequence (0-based, startOffset=endOffset
  for insertions).
  @param allele String containing the allele that needs to be justified.
  @param genomicSequence String containing the genomic sequence around the variant.getStart() position
  (+-NEIGHBOURING_SEQUENCE_SIZE).
  @param strand String {"+", "-"}.