def calc_window(pos, n, reg_n, search_window):
    """Find start/stop bounds within search_window size around a position"""
    start=pos - search_window
    if start < reg_n:
        start = reg_n

    stop = pos + search_window
    if stop + reg_n >= n:
        stop = n-reg_n

    return (start, stop)