<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def mendelian_errors2(args):
 """ %prog mendelian_errors2 Trios.summary.csv Plot Mendelian errors as calculated by mendelian(). File `Trios.summary.csv` looks like: Name,Motif,Inheritance,N_Correct,N_Error,N_missing,ErrorRate [N_Error / (N_Correct + N_Error))] DM1,CTG,AD,790,12,0,1.5% DM2,CCTG,AD,757,45,0,5.6% DRPLA,CAG,AD,791,11,0,1.4% """

    p = OptionParser(mendelian_errors2.__doc__)
    opts, args, iopts = p.set_image_options(args, figsize="7x7", format="png")

    if len(args) != 1:
        sys.exit(not p.print_help())

    csvfile, = args
    fig, ax = plt.subplots(ncols=1, nrows=1,
                           figsize=(iopts.w, iopts.h))
    root = fig.add_axes([0, 0, 1, 1])

    ymin = -.2
    df = pd.read_csv(csvfile)
    data = []
    for i, d in df.iterrows():
        tred = d['Name']
        motif = d['Motif']
        if tred in ignore:
            logging.debug("Ignore {}".format(d['TRED']))
            continue

        if len(motif) > 6:
            if "/" in motif:  # CTG/CAG
                motif = motif.split("/")[0]
            else:
                motif = motif[:6] + ".."
        xtred = "{} {}".format(tred, motif)
        accuracy = d[-1]
        data.append((xtred, accuracy))

    key = lambda x: float(x.rstrip('%'))
    data.sort(key=lambda x: key(x[-1]))
    print(data)
    treds, accuracies = zip(*data)
    ntreds = len(treds)
    ticks = range(ntreds)
    accuracies = [key(x) for x in accuracies]

    for tick, accuracy in zip(ticks, accuracies):
        ax.plot([tick, tick], [ymin, accuracy],
                "-", lw=2, color='lightslategray')

    trios, = ax.plot(accuracies, "o", mfc='w', mec='b')
    ax.set_title("Mendelian errors based on STR calls in trios in HLI samples")
    ntrios = "Mendelian errors in 802 trios"
    ax.legend([trios], [ntrios], loc='best')

    ax.set_xticks(ticks)
    ax.set_xticklabels(treds, rotation=45, ha="right", size=8)
    ax.set_yticklabels([int(x) for x in ax.get_yticks()], family='Helvetica')
    ax.set_ylabel("Mendelian errors (\%)")
    ax.set_ylim(ymin, 100)

    normalize_axes(root)

    image_name = "mendelian_errors2." + iopts.format
    savefig(image_name, dpi=iopts.dpi, iopts=iopts)