def findMismappedFivePrime(sam_df, proper_5_loc=706, margin=10):
    """
    Takes a SAM dataframe and finds the percent of total that mapped successully,
    but is mismapped in the 5' end. Likely sequencing errors. So probably an
    unreliable read to look at.
    """

    total = len(sam_df)

    is_mapped = sam_df.FLAG.isin([0,16])

    improperFiveMapped = ((sam_df.POS < proper_5_loc - margin) | (sam_df.POS > proper_5_loc + margin)) & is_mapped

    return len(sam_df[improperFiveMapped]) / total