def __init__(
            self,
            alleles,
            allele_to_fixed_length_sequence=None):
        """
        A place to cache encodings for a (potentially large) sequence of alleles.

        Parameters
        ----------
        alleles : list of string
            Allele names

        allele_to_fixed_length_sequence : dict of str -> str
            Allele name to fixed lengths sequence ("pseudosequence")
        """

        alleles = pandas.Series(alleles)

        all_alleles = list(sorted(alleles.unique()))

        self.allele_to_index = dict(
            (allele, i)
            for (i, allele) in enumerate(all_alleles))

        self.indices = alleles.map(self.allele_to_index)

        self.fixed_length_sequences = pandas.Series(
            [allele_to_fixed_length_sequence[a] for a in all_alleles],
            index=all_alleles)

        self.encoding_cache = {}
def __init__ ( self , alleles , allele_to_fixed_length_sequence = None ) : alleles = pandas . Series ( alleles ) all_alleles = list ( sorted ( alleles . unique ( ) ) ) self . allele_to_index = dict ( ( allele , i ) for ( i , allele ) in enumerate ( all_alleles ) ) self . indices = alleles . map ( self . allele_to_index ) self . fixed_length_sequences = pandas . Series ( [ allele_to_fixed_length_sequence [ a ] for a in all_alleles ] , index = all_alleles ) self . encoding_cache = { }
A place to cache encodings for a (potentially large) sequence of alleles.

        Parameters
        ----------
        alleles : list of string
            Allele names

        allele_to_fixed_length_sequence : dict of str -> str
            Allele name to fixed lengths sequence ("pseudosequence")