def calc_disfrac(input_df, threshold=0.5):
    """Take a merged IUPRed input (multiple proteins) and calculate
    the fraction of disordered residues according to a specific threshold for
    each case. A pd.GroupBy object is first generated and then the function
    applied.

    Arguments:
        input_df {string} -- [description]

    Keyword Arguments:
        threshold {float} -- [description] (default: {0.5})

    Returns:
        [type] -- [description]
    """
    grouped = input_df.groupby(["protein_ac", "dataset", "disorder_predictor"])
    # Aggregate IUPred scores using the disorder fraction formula
    disfrac = grouped.agg({"score": lambda x: sum(x >= threshold) / len(x)})
    # Rename score column to disorder fraction
    disfrac = disfrac.rename(columns={"score": "disorder_fraction"})
    disfrac.reset_index(inplace=True)

    return disfrac