def calibrate_percentile_ranks(<EOL>self,<EOL>peptides=None,<EOL>num_peptides_per_length=int(<NUM_LIT>),<EOL>alleles=None,<EOL>bins=None):
if bins is None:<EOL><INDENT>bins = to_ic50(numpy.linspace(<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:1000>))<EOL><DEDENT>if alleles is None:<EOL><INDENT>alleles = self.supported_alleles<EOL><DEDENT>if peptides is None:<EOL><INDENT>peptides = []<EOL>lengths = range(<EOL>self.supported_peptide_lengths[<NUM_LIT:0>],<EOL>self.supported_peptide_lengths[<NUM_LIT:1>] + <NUM_LIT:1>)<EOL>for length in lengths:<EOL><INDENT>peptides.extend(<EOL>random_peptides(num_peptides_per_length, length))<EOL><DEDENT><DEDENT>encoded_peptides = EncodableSequences.create(peptides)<EOL>for (i, allele) in enumerate(alleles):<EOL><INDENT>predictions = self.predict(encoded_peptides, allele=allele)<EOL>transform = PercentRankTransform()<EOL>transform.fit(predictions, bins=bins)<EOL>self.allele_to_percent_rank_transform[allele] = transform<EOL><DEDENT>return encoded_peptides<EOL>
Compute the cumulative distribution of ic50 values for a set of alleles
over a large universe of random peptides, to enable computing quantiles in
this distribution later.

Parameters
----------
peptides : sequence of string or EncodableSequences, optional
    Peptides to use
num_peptides_per_length : int, optional
    If peptides argument is not specified, then num_peptides_per_length
    peptides are randomly sampled from a uniform distribution for each
    supported length
alleles : sequence of string, optional
    Alleles to perform calibration for. If not specified all supported
    alleles will be calibrated.
bins : object
    Anything that can be passed to numpy.histogram's "bins" argument
    can be used here, i.e. either an integer or a sequence giving bin
    edges. This is in ic50 space.

Returns
----------
EncodableSequences : peptides used for calibration