def rep_find(rdseq, max_rep_unit=100):
    """
    max_rep_unit 为指定最大的重复单元碱基数
    返回  (左端重复单元，左端重复单元重复次数，右端重复单元，右端重复单元重复次数)
    """
    length = len(rdseq)
    left, right = {}, {}
    for j in range(1, min(max_rep_unit + 1, length / 2 + 1)):
        rep = [rdseq[:j], rdseq[-j:]]
        for i in range(0, length - j, j):
            s = rdseq[i + j:i + j + j]
            if s != rdseq[:j]:
                break
            rep[0] += s
        else:
            left.setdefault(rep[0], j)
            right.setdefault(rep[0], j)
            continue
        for i in range(-j, -length, -j):
            s = rdseq[i - j:i]
            if s != rdseq[-j:]:
                break
            rep[1] = s + rep[1]
        if len(rep[0]) > j:
            left.setdefault(rep[0], j)
        else:
            left[rdseq[0]] = 1
        if len(rep[1]) > j:
            right.setdefault(rep[1], j)
        else:
            right[rdseq[-1]] = 1
    o1, o2 = sorted(left.items(), key=lambda x: len(x[0]))[-1], sorted(right
        .items(), key=lambda x: len(x[0]))[-1]
    return o1[0][:o1[1]], len(o1[0]) / o1[1], o2[0][:o2[1]], len(o2[0]) / o2[1]
