def split_gems(frags, thr):
    """
    Split GEMs into sub-GEMs depending on cutoff threshold thr.
    Args:
       frags (list of list): [chrom,start,end] for each fragment 
       thr (int): cutoff threshold in bps
    Returns:
       subgems (list of list)
    """
    subgems = []
    tmpgem = [frags[0]]
    for i in range(len(frags)-1):
        fragdist = frags[i+1][1]-frags[i][2]
        if fragdist < thr:
            tmpgem.append(frags[i+1])
        else:
            subgems.append(tmpgem)
            tmpgem = [frags[i+1]]
    subgems.append(tmpgem)
    fin_subgems = [x for x in subgems if len(x)>1]
    return fin_subgems