an increasing body of research is based on the classification and evaluation of the rate of dna evolution in coding regions . in many cases nucleotide substitutions are classified according to their impact on the encoded protein and the resulting classification can be used for a variety of analyses . classification of synonymous ( ks ) and non - synonymous ( ka ) substitutions can be used to detect the presence or absence of selection ( 1 ) and the classification of substitutions according to codon position can be used with sophisticated evolutionary models to better reconstruct phylogenies . in both of these cases the programs that perform the analysis , such as paml ( 2 ) , require a codon alignment as input . owing to the degeneracy of the genetic code , where a single amino acid can be encoded by multiple codons , it is often preferable to align protein sequences rather than the underlying coding dna as it increases sensitivity at longer evolutionary distances and prevents the introduction of frame shifts into an alignment . thus the construction of a protein alignment first and then reverse translating this into a codon - based dna alignment is invariably the optimal solution and provides reliable alignments to perform correct evolutionary analyses . in the ideal case where the protein and the corresponding dna match perfectly , the conversion from a protein alignment into the corresponding codon alignment can be achieved by replacing each amino acid residue with three nucleotide residues , a procedure which is implemented in several tools , e.g. aa_to_dna_aln in the bioperl toolkit ( 3 ) , revtrans ( 4 ) , transalign ( 5 ) and aa2dna ( ) . however it often happens that the corresponding dna sequence has mismatches when compared with its theoretical protein sequence , or contains untranslated regions ( utrs ) and polya tails . in such instances , moreover the analysis of pseudogenes , which are an interesting subject of molecular evolution studies , requires dealing with frame shifts and inframe stop codons . these situations , which are rather frequent in large - scale analysis of sequenced genomes , can not be solved by the programs mentioned above and therefore require additional solutions . here we describe a web server , pal2nal , which converts a protein sequence alignment into the corresponding codon alignment , despite the presence of mismatches between the protein and the dna sequences , utrs and polya tails in the input dna sequences , and frame shifts and inframe stop codons in the input alignment . another useful feature of this server is that it is possible to obtain codon alignments for specific regions of interest , such as functional domains or particular exons by selecting the positions in the input protein sequence alignment . the server requires a multiple sequence alignment of proteins and the corresponding dna sequences as input . the internal action of the program can be divided into three main steps : ( i ) upload the protein sequence alignment and dna sequences , ( ii ) reverse translation , i.e. conversion of the protein sequences into the corresponding dna sequences in the form of regular expression patterns and ( iii ) generation of the codon alignment . in the second step , for example , a short peptide sequence , mdp , is reverse - translated into a regular expression pattern of the dna sequence as ( a(ut)g)(ga(utcy))(cc . ) . for frame shifts , we adapted the notation used in genewise ( 6 ) : if an insertion or deletion is found in the coding region , it is represented by the number of nucleic acid residues at that site instead of an amino acid code . for example , m2p indicates that there is 1 nt deletion between methionine and proline . with this notation , it is easy to convert the peptide sequence into a regular expression pattern , in this case ( a(ut)g) .. (cc . ) . after converting into a regular expression pattern , the input dna sequence is searched with the pattern to obtain the corresponding coding region . this was achieved by extending 10 amino acid regular expression matches in both directions until the entire coding region of the input dna sequence is covered . the regions between the extended fragments and those not covered by the extension are taken as mismatches , and reported , if any , in the output . in the third step , the protein sequence alignment is converted into the corresponding codon alignment by replacing each amino acid residue with the corresponding codon sequence . the pal2nal server takes the following two files as input : ( i ) a multiple sequence alignment of proteins either in the clustal or in the fasta format and ( ii ) the corresponding dna sequences in the fasta format . an example of the application of pal2nal is shown in figure 1 . in this example , a multiple sequence alignment of human dihydrofolate reductase in the clustal format ( 7 ) ( figure 1a ) and the corresponding dna ( or mrna ) sequences in the fasta format ( figure 1b ) are used as input . the second sequence of this example is a pseudogene , and it contains two frame shifts and three inframe stop codons . the program automatically trims all utrs and polya tails , and successfully converts the protein alignment into the codon alignment , despite the presence of a mismatch and two frame shifts ( figure 1c ) . if some positions of the input alignment are marked with  #  under the alignment ( figure 1a ) , the corresponding regions are also marked in the output codon alignment ( figure 1c ) . the users can select a codon table : either  universal ( default ) or this option should be selected if the codon alignment is to be further analyzed by codeml to calculate ks and ka since the paml package does not accept codon alignments containing gaps or inframe stop codons . if the second option ( remove gaps and inframe stop codons ) is selected and the input is a pair of sequences , this option also allows to calculate ks and ka values by the codeml program ( 8) included in the paml package . the calculation of ks and ka is only performed for sequence pairs because the computationally demanding construction of phylogenetic topologies would be required for alignments with more than two sequences . if there are mismatched codons between the protein and the dna sequences , the users can either remove or retain such codon sites by this option . ( v ) use only selected positions . with this option , only the codon alignment corresponding to the regions marked by this option is very useful because it allows the construction of codon alignment for a certain exon or a domain or conserved blocks , for example those identified automatically by gblocks ( 9 ) . the pal2nal server ( ) is useful for constructing codon multiple alignments , which are required in many molecular evolutionary analyses , such as the calculation of ks and ka values . for a large - scale analysis , the distribution version of the pal2nal script , which is written in perl and works in command line , is also available for download . we successfully applied the distribution version of pal2nal , for example , to the detection of human pseudogenes ( 10 ) and to the annotation of genes in human chromosomes 2 and 4 ( 11 ) . an example of pal2nal input and output files . ( a ) the first input file : a multiple sequence alignment of human dihydrofolate reductase ( genbank accession no . bc070280 ) and its pseudogene in the clustal format with the notation used in genewise for frame shifts . frame shifts and inframe stop codons in the pseudogene are shown in orange . under the alignment , ( b ) the second input file : the corresponding dna ( or mrna ) sequences in the fasta format . utrs and polya tails are shown in cyan to indicate how these regions are excluded from the resulting output . the position of the codon that does not correspond with the input protein sequence is shown in red . the regions of alignment blocks correspond to those specified in the input protein alignment are indicated by ( d ) output with the following option setting : remove mismatches , yes ; use only selected positions , yes ; output format , paml . with this setting ,