def KyteDoolittleColorMapping(maptype='<STR_LIT>', reverse=True):
d = {'<STR_LIT:A>':<NUM_LIT>, '<STR_LIT:C>':<NUM_LIT>, '<STR_LIT:D>':-<NUM_LIT>, '<STR_LIT:E>':-<NUM_LIT>, '<STR_LIT:F>':<NUM_LIT>, '<STR_LIT>':-<NUM_LIT>,'<STR_LIT:H>':-<NUM_LIT>, '<STR_LIT:I>':<NUM_LIT>, '<STR_LIT>':-<NUM_LIT>, '<STR_LIT:L>':<NUM_LIT>, '<STR_LIT:M>':<NUM_LIT>, '<STR_LIT:N>':-<NUM_LIT>,'<STR_LIT:P>':-<NUM_LIT>, '<STR_LIT>':-<NUM_LIT>, '<STR_LIT:R>':-<NUM_LIT>, '<STR_LIT:S>':-<NUM_LIT>, '<STR_LIT:T>':-<NUM_LIT>,'<STR_LIT>':<NUM_LIT>, '<STR_LIT>':-<NUM_LIT>, '<STR_LIT:Y>':-<NUM_LIT>}<EOL>aas = sorted(AA_TO_INDEX.keys())<EOL>hydrophobicities = [d[aa] for aa in aas]<EOL>if reverse:<EOL><INDENT>hydrophobicities = [-<NUM_LIT:1> * x for x in hydrophobicities]<EOL><DEDENT>mapper = pylab.cm.ScalarMappable(cmap=maptype)<EOL>mapper.set_clim(min(hydrophobicities), max(hydrophobicities))<EOL>mapping_d = {'<STR_LIT:*>':'<STR_LIT>'}<EOL>for (aa, h) in zip(aas, hydrophobicities):<EOL><INDENT>tup = mapper.to_rgba(h, bytes=True)<EOL>(red, green, blue, alpha) = tup<EOL>mapping_d[aa] = '<STR_LIT>' % (red, green, blue)<EOL>assert len(mapping_d[aa]) == <NUM_LIT:7><EOL><DEDENT>cmap = mapper.get_cmap()<EOL>return (cmap, mapping_d, mapper)<EOL>
Maps amino-acid hydrophobicities to colors.

    Uses the Kyte-Doolittle hydrophobicity scale defined by::

        J. Kyte & R. F. Doolittle: 
        "A simple method for displaying the hydropathic character of a protein." 
        J Mol Biol, 157, 105-132

    More positive values indicate higher hydrophobicity, while more negative values
    indicate lower hydrophobicity.

    The returned variable is the 3-tuple *(cmap, mapping_d, mapper)*:

        * *cmap* is a ``pylab`` *LinearSegmentedColorMap* object.

        * *mapping_d* is a dictionary keyed by the one-letter amino-acid
          codes. The values are the colors in CSS2 format (e.g. #FF0000
          for red) for that amino acid. The value for a stop codon 
          (denoted by a ``*`` character) is black (#000000).

        * *mapper* is the actual *pylab.cm.ScalarMappable* object.

    The optional calling argument *maptype* should specify a valid ``pylab`` color map.

    The optional calling argument *reverse* specifies that we set up the color
    map so that the most hydrophobic residue comes first (in the Kyte-Doolittle
    scale the most hydrophobic comes last as it has the largest value). This option
    is *True* by default as it seems more intuitive to have charged residues red
    and hydrophobic ones blue.