AminoAcidColours.pl

From Organic Design wiki
sub colorise_peptide 
{
    my $params = {motif => '',
		  schema => $form_data{"-schema"} || 'accessible_area',
		  blocks => 0,
		  start => 1,
		  @_};
    
    unless(ref $params->{'motif'} eq 'SCALAR')
    {
	&return_html_error('title_text' =>  'INTERNAL ERROR',
			   'error_msg'	=> qq|<font color="red">&nucleotide_colors subroutine variable 'motif' requires a SCALAR reference as input</font>|);
	exit 0;
    }  
    
    my $residue_color_schemes =
    {
        'accessible_area' =>
        {
	    'C' => '#FF66FF',   # pink
	    'I' => '#FF3300',   # red
	    'G' => '#FF3300',   # red
	    'V' => '#FF3300',   # red
	    'A' => '#9900CC',   # purple
	    'F' => '#9900CC',   # purple
	    'L' => '#9900CC',   # purple
	    'M' => '#9900CC',   # purple
	    'H' => '#999900',   # olive
	    'S' => '#999900',   # olive
	    'T' => '#999900',   # olive
	    'W' => '#999900',   # olive
	    'P' => '#996600',   # brown
	    'D' => '#3399FF',   # skyblue
	    'N' => '#3399FF',   # skyblue
	    'Y' => '#3399FF',   # skyblue
	    'E' => '#0000FF',   # blue
	    'Q' => '#0000FF',   # blue
	    'R' => '#990000',
	    'K' => '#999999',    # gray
	},
	'standard_area' =>
	{
	    'G' => '#FF66FF',   # pink
	    'A' => '#FF3300',   # red
	    'S' => '#FF3300',   # red
	    'C' => '#9900CC',   # purple
	    'P' => '#9900CC',   # purple
	    'D' => '#999900',   # olive
	    'N' => '#999900',   # olive
	    'T' => '#999900',   # olive
	    'V' => '#999900',   # olive
	    'E' => '#996600',   # brown
	    'I' => '#996600',   # brown
	    'H' => '#3399FF',   # skyblue
	    'L' => '#3399FF',   # skyblue
	    'M' => '#3399FF',   # skyblue
	    'Q' => '#3399FF',   # skyblue
	    'F' => '#0000FF',   # blue
	    'K' => '#0000FF',   # blue
	    'Y' => '#990000',
	    'R' => '#999999',   # gray
	    'W' => '#999999',   # gray
	},
	'hydropathy'    =>
        {
	    'D' => '#FF0000',
	    'E' => '#FF0000',
	    'H' => '#0000FF',
	    'K' => '#0000FF',
	    'R' => '#0000FF',
	    'C' => '#FF9900',
	    'G' => '#FF9900',
	    'N' => '#FF9900',
	    'Q' => '#FF9900',
	    'S' => '#FF9900',
	    'T' => '#FF9900',
	    'Y' => '#FF9900',
	    'A' => '#339900',
	    'F' => '#339900',
	    'I' => '#339900',
	    'L' => '#339900',
	    'M' => '#339900',
	    'P' => '#339900',
	    'V' => '#339900',
	    'W' => '#339900',
	},
	'charge'        =>
        {
	    'D' => '#FF0000',
	    'E' => '#FF0000',
	    'H' => '#0000FF',
	    'K' => '#0000FF',
	    'R' => '#0000FF',
	},
        'chemical'      =>
        {
	    'D' => '#FF0000',   #
	    'E' => '#FF0000',   #
	    'H' => '#0000FF',   #
	    'K' => '#0000FF',   #
	    'R' => '#0000FF',   #
	    'A' => '#9900CC',   # purple
	    'G' => '#9900CC',   # purple
	    'I' => '#9900CC',   # purple
	    'L' => '#9900CC',   # purple
	    'V' => '#9900CC',   # purple
	    'N' => '#999900',   # olive
	    'Q' => '#999900',   # olive
	    'F' => '#996600',   # brown
	    'W' => '#996600',   # brown
	    'Y' => '#996600',   # brown
	    'S' => '#3399FF',   # skyblue
	    'T' => '#3399FF',   # skyblue
	    'P' => '#990000',
	    'C' => '#999999',    # gray
	    'M' => '#999999',    # gray
	},
	'structure'     =>
	{
	    'D' => '#FF9900',
	    'E' => '#FF9900',
	    'H' => '#FF9900',
	    'K' => '#FF9900',
	    'N' => '#FF9900',
	    'Q' => '#FF9900',
	    'R' => '#FF9900',
	    'F' => '#339900',
	    'I' => '#339900',
	    'L' => '#339900',
	    'M' => '#339900',
	    'V' => '#339900',
	    'A' => '#3399FF',    # skyblue
	    'C' => '#3399FF',    # skyblue
	    'G' => '#3399FF',    # skyblue
	    'P' => '#3399FF',    # skyblue
	    'S' => '#3399FF',    # skyblue
	    'T' => '#3399FF',    # skyblue
	    'W' => '#3399FF',    # skyblue
	    'Y' => '#3399FF',    # skyblue
	},
    };                           
 if($params->{blocks})
    {
	${$params->{motif}} =~s/(\w{$params->{blocks}})/$1 /g;
    }

${$params->{'motif'}} =~ s/([@{[join "",keys %{$residue_color_schemes ->{$params->{schema}}}]}])/<font color=\"$residue_color_schemes->{$params->{schema}}->{$1}\" class="est">$1<\/font>/g;
}


# ------------------------- Other useful lookup tables -------------------------- #
# Source: http://examples.oreilly.com/begperlbio/


    my %three2one = (
      'ALA' => 'A',
      'VAL' => 'V',
      'LEU' => 'L',
      'ILE' => 'I',
      'PRO' => 'P',
      'TRP' => 'W',
      'PHE' => 'F',
      'MET' => 'M',
      'GLY' => 'G',
      'SER' => 'S',
      'THR' => 'T',
      'TYR' => 'Y',
      'CYS' => 'C',
      'ASN' => 'N',
      'GLN' => 'Q',
      'LYS' => 'K',
      'ARG' => 'R',
      'HIS' => 'H',
      'ASP' => 'D',
      'GLU' => 'E',
    );

 my(%genetic_code) = (
    
    'TCA' => 'S',    # Serine
    'TCC' => 'S',    # Serine
    'TCG' => 'S',    # Serine
    'TCT' => 'S',    # Serine
    'TTC' => 'F',    # Phenylalanine
    'TTT' => 'F',    # Phenylalanine
    'TTA' => 'L',    # Leucine
    'TTG' => 'L',    # Leucine
    'TAC' => 'Y',    # Tyrosine
    'TAT' => 'Y',    # Tyrosine
    'TAA' => '_',    # Stop
    'TAG' => '_',    # Stop
    'TGC' => 'C',    # Cysteine
    'TGT' => 'C',    # Cysteine
    'TGA' => '_',    # Stop
    'TGG' => 'W',    # Tryptophan
    'CTA' => 'L',    # Leucine
    'CTC' => 'L',    # Leucine
    'CTG' => 'L',    # Leucine
    'CTT' => 'L',    # Leucine
    'CCA' => 'P',    # Proline
    'CCC' => 'P',    # Proline
    'CCG' => 'P',    # Proline
    'CCT' => 'P',    # Proline
    'CAC' => 'H',    # Histidine
    'CAT' => 'H',    # Histidine
    'CAA' => 'Q',    # Glutamine
    'CAG' => 'Q',    # Glutamine
    'CGA' => 'R',    # Arginine
    'CGC' => 'R',    # Arginine
    'CGG' => 'R',    # Arginine
    'CGT' => 'R',    # Arginine
    'ATA' => 'I',    # Isoleucine
    'ATC' => 'I',    # Isoleucine
    'ATT' => 'I',    # Isoleucine
    'ATG' => 'M',    # Methionine
    'ACA' => 'T',    # Threonine
    'ACC' => 'T',    # Threonine
    'ACG' => 'T',    # Threonine
    'ACT' => 'T',    # Threonine
    'AAC' => 'N',    # Asparagine
    'AAT' => 'N',    # Asparagine
    'AAA' => 'K',    # Lysine
    'AAG' => 'K',    # Lysine
    'AGC' => 'S',    # Serine
    'AGT' => 'S',    # Serine
    'AGA' => 'R',    # Arginine
    'AGG' => 'R',    # Arginine
    'GTA' => 'V',    # Valine
    'GTC' => 'V',    # Valine
    'GTG' => 'V',    # Valine
    'GTT' => 'V',    # Valine
    'GCA' => 'A',    # Alanine
    'GCC' => 'A',    # Alanine
    'GCG' => 'A',    # Alanine
    'GCT' => 'A',    # Alanine
    'GAC' => 'D',    # Aspartic Acid
    'GAT' => 'D',    # Aspartic Acid
    'GAA' => 'E',    # Glutamic Acid
    'GAG' => 'E',    # Glutamic Acid
    'GGA' => 'G',    # Glycine
    'GGC' => 'G',    # Glycine
    'GGG' => 'G',    # Glycine
    'GGT' => 'G',    # Glycine
    );

 my %iub2character_class = (
    
        A => 'A',
        C => 'C',
        G => 'G',
        T => 'T',
        R => '[GA]',
        Y => '[CT]',
        M => '[AC]',
        K => '[GT]',
        S => '[GC]',
        W => '[AT]',
        B => '[CGT]',
        D => '[AGT]',
        H => '[ACT]',
        V => '[ACG]',
        N => '[ACGT]',
    );