def get_sequences(sequence, min_seq_len=1):
    """
    Transforms the output of get_repeat_counts() into distinct
    "sequences" and "repeats". Sequences are runs of data that
    do not contain any repetition inside them.
    ! This is adjustable using min_seq_len: repeats in the input
      that are shorter than this value are folded into the
      previous sequence.
    [(3, 1), (1, 2), (2, 3)] -> [(('R', 3, 1), ('S', [2]), ('R', 2, 3))]
    """
    result = []
    build_seq = []

    for count, val in sequence:
        if count > min_seq_len:
            if build_seq:
                result.append(("S", build_seq))
                build_seq = []
            result.append(("R", count, val))
        else:
            build_seq.extend([val] * count)
    return result