def enrichment_optimal(ligand_vs_kinase_data):
    """
    Calculate the optimal enrichment, i.e. the ratio of ranked kinases, in which optimally all
    active kinases have been found.

    Parameters
    ----------
    ranks : pandas.DataFrame
        Must use `src.evaluation.kinase_ranks.kinase_ranks_by_ligand_vs_kinase_data`. See this
        return value description in this function's docstring.
    ligand_kinase_method : str
        Name for ligand profiling method to be used as identifier in `ranks`.

    Returns
    -------
    float
        Percentage of ranked kinases that will optimally contain _all_ active kinases.

    Notes
    -----
    N   : Number of kinases in totoal
    N_s : Number of kinases in top x% of ranked kinases
    n   : Number of active kinases in total
    n_s : Number of active kinases in top x% of ranked kinases

    For the enrichment plot, the x values are calculated as follows:
    x = N_s / N
    In the optimal case, N_s = n, hence:
    x_optimal = n / N
    """

    ranks = ligand_vs_kinase_data.data
    n_kinases = ranks.shape[0]
    n_active_kinases = ranks[f"{ligand_vs_kinase_data.ligand_kinase_method}.active"].sum()
    ratio_active_kinases_identified_optimal = n_active_kinases / n_kinases * 100

    return ratio_active_kinases_identified_optimal