This function takes an AAStringSet alignment and its corresponding coding sequences DNAStringSet and converts the protein alignment into a codon alignment.

pal2nal(pal, nal, remove.gaps = FALSE)

Arguments

pal

AAStringSet [mandatory]

nal

DNAStringSet [mandatory]

remove.gaps

specify if gaps in the codon alignment should be removed [default: FALSE]

Value

codon alignment as DNAStringSet

References

Pagès, H et al. (2014) Biostrings: Efficient manipulation of biological strings. R package version, 2(0).

Author

Kristian K Ullrich

Examples

## define two cds sequences
cds <- Biostrings::DNAStringSet(c("ATGCAACATTGC", "ATGCATTGC"))
names(cds) <- c("cds1", "cds2")
## get protein alignment
aa <- MSA2dist::cds2aa(cds)
msa <- makePostalignedSeqs(Biostrings::pairwiseAlignment(aa[1], aa[2]))[[1L]]
names(msa) <- names(aa)
## get codon alignment
nal <- MSA2dist::pal2nal(pal=msa, nal=cds)
nal
#> DNAStringSet object of length 2:
#>     width seq                                               names               
#> [1]    12 ATGCAACATTGC                                      cds1
#> [2]    12 ATG---CATTGC                                      cds2