from typing import List


def gapped_indices(seq: str) -> List[str]:
    """
    Given the gapped reference sequence, create index strings for use in aadiff site columns.

    Any gaps before the first reference base translate to negative numbers
    specifying the negative offset from the first reference base. Any gaps
    after a reference base translate to strings specifying the positive offset.

    For example:
      "--AT--G-"  -->  ["-2", "-1", "1", "2", "2+1", "2+2", "3", "3+1"]
    """

    def _handle_run(run: int, ind: int) -> List[str]:
        if ind == 0:
            return list(reversed([("-" + str(i)) for i in range(1, run + 1)]))
        else:
            return [f"{str(ind)}+{str(i)}" for i in range(1, run + 1)]

    indices = []
    run = 0
    ind = 0
    for i in range(len(seq)):
        if seq[i] == "-":
            run += 1
        else:
            if run > 0:
                indices += _handle_run(run, ind)
                run = 0
            ind += 1
            indices.append(str(ind))
    if run > 0:
        indices += _handle_run(run, ind)
    return indices