def percentile_ranks(self, affinities, allele=None, alleles=None, throw=True):
if allele is not None:<EOL><INDENT>try:<EOL><INDENT>transform = self.allele_to_percent_rank_transform[allele]<EOL>return transform.transform(affinities)<EOL><DEDENT>except KeyError:<EOL><INDENT>msg = "<STR_LIT>" % allele<EOL>if throw:<EOL><INDENT>raise ValueError(msg)<EOL><DEDENT>else:<EOL><INDENT>warnings.warn(msg)<EOL>return numpy.ones(len(affinities)) * numpy.nan<EOL><DEDENT><DEDENT><DEDENT>if alleles is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>df = pandas.DataFrame({"<STR_LIT>": affinities})<EOL>df["<STR_LIT>"] = alleles<EOL>df["<STR_LIT:result>"] = numpy.nan<EOL>for (allele, sub_df) in df.groupby("<STR_LIT>"):<EOL><INDENT>df.loc[sub_df.index, "<STR_LIT:result>"] = self.percentile_ranks(<EOL>sub_df.affinity, allele=allele, throw=throw)<EOL><DEDENT>return df.result.values<EOL>
Return percentile ranks for the given ic50 affinities and alleles.

The 'allele' and 'alleles' argument are as in the `predict` method.
Specify one of these.

Parameters
----------
affinities : sequence of float
    nM affinities
allele : string
alleles : sequence of string
throw : boolean
    If True, a ValueError will be raised in the case of unsupported
    alleles. If False, a warning will be logged and NaN will be returned
    for those percentile ranks.

Returns
-------
numpy.array of float