def filter_mismatched_alignments(df):
    """
    Removes any alignment that contains more than the smallest number of mismatches.
    If there are two miRs that map to a single read, this function compares both 
    miRs and returns only the one(s) that have the least amount of mismatches.
    """
    print("Now filtering miRs with mismatches.")
    return df[df.groupby('ref_name')['mutation_num'].transform('min') == df['mutation_num']]