def filter_mT_table(df, kd_up_lim, SE_upper_lim, kd_low_lim=0, drop_dup=True):
    """
    filters existing masstitr table
    filters out seqs containing * or X characters
    removes seqs not matching xxxPxExxx motif

    Parameters
    ----------
    SE_upper_lim
        Will filter data for SE values with SE <= `SE_upper_lim`
    kd_up_lim
        Will remove data outside range: Kd < `kd_up_lim`
    kd_low_lim
        Will remove data outside range: `kd_low_lim` < Kd
    drop_dup : :obj:`bool`, optional
        Whether or not to drop duplicate sequences

    Returns
    ------
    filtered dataframe
    """
    # drop duplicates first just in case only a single duplicate makes the cutoff but the other(s) do not
    # for example, if LNLPEESDW had 2 entries with diff Kd values with one of them > kd_up_lim and the other < kd_up_lim
    if drop_dup:
        df = df.drop_duplicates(subset="AA_seq", keep=False)
    df = df[~df.AA_seq.str.contains("[\*X]")]
    df = df[df.AA_seq.str.contains(r"...P.E...")]
    df = df[df["SE"] <= SE_upper_lim]
    # df = df[df["R2"] >= R2_lower_lim]
    df = df[(df["Kd"] < kd_up_lim) & (df["Kd"] > kd_low_lim)]
    return df