#!/usr/bin/perl -w # AA_MODULE # VERSION: Version 1.2 (16 Nov 2003) # PURPOSE: Exports three hashes: # %aa_full_name - converts 1- or 3-letter code to full name of amino acid # %aa_1_letter_code - converts full name or 3-letter code to 1-letter amino acid code # %aa_3_letter_code - converts full name or 1-letter code to 3-letter amino acid code # In all cases, the hash also converts an element to itself. For example: # $aa_full_name{"I"} ==> "Isoleucine" # $aa_1_letter_code{"ARG"} ==> "R" # $aa_3_letter_code{"PRO"} ==> "Pro" # The key must be all upper case package AA_module; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(%aa_full_name %aa_1_letter_code %aa_3_letter_code); ############## LIBRARIES AND PRAGMAS ################ use strict; #################### CONSTANTS ###################### my $true = 1; #################### VARIABLES ###################### our %aa_1_letter_code; # Exported hash our %aa_3_letter_code; # Exported hash our %aa_full_name; # Exported hash ################# INITIALIZATION #################### Read_aa_info ( ); return $true; #################### SUBROUTINES #################### ##### READ_AA_INFO # Initializes hashes that interconvert different names of amino acids # Information is stored in a huge string in Initialize_aa_string # String is split up line by line, then parsed sub Read_aa_info { my $line; my $aa_string = Initialize_aa_string ( ); # Get all aa info while ($aa_string =~ /(.+?)\n/g) { # Split up by line $line = $1; if ($line =~ /^\s*#/) {next} # Ignore comments $line =~ /\s*(.+?)\W+(\w)\W+(\w\w\w)\W+(\d+)/; my $aa_full_name = $1; my $aa_1_letter_code = $2; my $aa_3_letter_code = $3; my $aa_atoms = $4; $aa_full_name{ uc($aa_full_name) } = $aa_full_name; $aa_full_name{ uc($aa_1_letter_code) } = $aa_full_name; $aa_full_name{ uc($aa_3_letter_code) } = $aa_full_name; $aa_1_letter_code{ uc($aa_full_name) } = $aa_1_letter_code; $aa_1_letter_code{ uc($aa_1_letter_code) } = $aa_1_letter_code; $aa_1_letter_code{ uc($aa_3_letter_code) } = $aa_1_letter_code; $aa_3_letter_code{ uc($aa_full_name) } = $aa_3_letter_code; $aa_3_letter_code{ uc($aa_1_letter_code) } = $aa_3_letter_code; $aa_3_letter_code{ uc($aa_3_letter_code) } = $aa_3_letter_code; } } ##### INITIALIZE_AA_STRING # Simply returns a single string with all amino acid info sub Initialize_aa_string { return " # Amino acid 1-letter code 3-letter code atoms alanine A Ala 5 arginine R Arg 11 asparagine N Asn 8 aspartic acid D Asp 8 cysteine C Cys 6 glutamic acid E Glu 9 glutamine Q Gln 9 glycine G Gly 4 histidine H His 10 isoleucine I Ile 8 leucine L Leu 8 lysine K Lys 9 methionine M Met 8 phenylalanine F Phe 11 proline P Pro 7 serine S Ser 6 threonine T Thr 7 tryptophan W Trp 13 tyrosine Y Tyr 11 valine V Val 7 " }