[Bio] / FigKernelPackages / NCBI_genetic_code.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/NCBI_genetic_code.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3, Fri Aug 27 19:32:22 2010 UTC revision 1.4, Sun Mar 4 00:51:51 2012 UTC
# Line 26  Line 26 
26  #  Access to the numbered genetic codes used by NCBI.  A code is returned  #  Access to the numbered genetic codes used by NCBI.  A code is returned
27  #  as a reference to a hash that has both uppercase and lowercase translations.  #  as a reference to a hash that has both uppercase and lowercase translations.
28  #  #
29  #  There are two access methods: by hash element and by subroutine:  #  There are two access methods: by hash lookup and by function:
30  #  #
31  #   \%genetic_code_n = $NCBI_genetic_code::genetic_code{ $n };  #   \%genetic_code = $NCBI_genetic_code::genetic_code{ $n };
32    #   \%genetic_code =  NCBI_genetic_code::genetic_code( $n );
33  #  #
34  #   \%genetic_code_n =  NCBI_genetic_code::genetic_code( $n );  #   \%genetic_code_name = $NCBI_genetic_code::genetic_code_name{ $n };
35    #   \%genetic_code_name =  NCBI_genetic_code::genetic_code_name( $n );
36    #
37    #   \%is_start_codon = $NCBI_genetic_code::is_start_codon{ $n };
38    #   \%is_start_codon =  NCBI_genetic_code::is_start_codon( $n );
39    #
40    #   \%is_stop_codon = $NCBI_genetic_code::is_stop_codon{ $n };
41    #   \%is_stop_codon =  NCBI_genetic_code::is_stop_codon( $n );
42  #  #
43  #  The only difference in behaviour is that the subroutine defaults to code  #  The only difference in behaviour is that the subroutine defaults to code
44  #  number 1 when no parameter is supplied:  #  number 1 when no parameter is supplied:
# Line 51  Line 59 
59                           } @nt                           } @nt
60                     } @nt;                     } @nt;
61    
62    our %genetic_code;
63    our %genetic_code_name;
64    our %is_start_codon;
65    our %is_stop_codon;
66    
67  my $code_num;  my $code_num;
68    while ( <DATA> )
69    {
70        chomp;
71        if ( /\d+\.\s+(.*)\s+\(transl_table=(\d+)/ )
72        {
73            $code_num = $2;
74            $genetic_code_name{ $code_num } = $1;
75        }
76    
77  our %genetic_code = map { my @aas = split //, $_->[1];      if ( /AAs\s+=\s+(\S+)/ )
78                            $_->[0] => { map { @$_, map { lc } @$_ }   # uc and lc      {
79                                         map { [ $_ => shift @aas ] }  # assignment          my @aas = split //, $1;
80                                         @triplets                     # codons          my %code;
81            my %stops;
82            foreach my $codon ( @triplets )
83            {
84                my $aa = shift( @aas );
85                $code{    $codon } =    $aa;
86                $code{ lc $codon } = lc $aa;
87                if ( $aa eq '*' ) { $stops{ $codon } = $stops{ lc $codon } = 1 }
88                                       }                                       }
89            $genetic_code{ $code_num } = \%code;
90            $is_stop_codon{ $code_num } = \%stops;
91                          }                          }
92                      map { if ( /transl_table=(\d+)/ ) { $code_num = $1 };  
93                            /AAs\s+=\s+(\S+)/ ? [ $code_num, $1 ] : ()      if ( /Starts\s+=\s+(\S+)/ )
94        {
95            my @data = split //, $1;
96            my %starts;
97            foreach my $codon ( @triplets )
98            {
99                if ( shift( @data ) eq 'M' )
100                {
101                    $starts{ $codon } = $starts{ lc $codon } = 1;
102                          }                          }
103                      split /\n/, <<'End_of_Codes';          }
104            $is_start_codon{ $code_num } = \%starts;
105        }
106    }
107    
108    sub genetic_code      { $genetic_code{ $_[0]      || '1' } }
109    sub genetic_code_name { $genetic_code_name{ $_[0] || '1' } }
110    sub is_start_codon    { $is_start_codon{ $_[0]    || '1' } }
111    sub is_stop_codon     { $is_stop_codon{ $_[0]     || '1' } }
112    
113    1;
114    
115    __DATA__
116    
117  1. The Standard Code (transl_table=1)  1. The Standard Code (transl_table=1)
118    
# Line 199  Line 249 
249    Base1  = TTTTTTTTTTTTTTTTCCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGG    Base1  = TTTTTTTTTTTTTTTTCCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGG
250    Base2  = TTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGG    Base2  = TTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGG
251    Base3  = TCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAG    Base3  = TCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAG
   
 End_of_Codes  
   
 sub genetic_code { $genetic_code{ $_[0] || '1' } }  
   
 1;  

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3