#
# List all available methods for getTrans generic function:
#
methods(getTrans)
#
# Toy CDS example invented by Leonor Palmeira:
#
toycds <- s2c("tctgagcaaataaatcgg")
getTrans(toycds) # should be c("S", "E", "Q", "I", "N", "R")
#
# Toy CDS example with ambiguous bases:
#
toycds2 <- s2c("tcngarcarathaaycgn")
getTrans(toycds2) # should be c("X", "X", "X", "X", "X", "X")
getTrans(toycds2, ambiguous = TRUE) # should be c("S", "E", "Q", "I", "N", "R")
getTrans(toycds2, ambiguous = TRUE, numcode = 2) # should be c("S", "E", "Q", "X", "N", "R")
#
# Real CDS example:
#
realcds <- read.fasta(file = system.file("sequences/malM.fasta", package ="seqinr"))[[1]]
getTrans(realcds)
# Biologically correct, only one stop codon at the end
getTrans(realcds, frame = 3, sens = "R", numcode = 6)
# Biologically meaningless, note the in-frame stop codons
# Read from an alignment as suggested by Dr. H. Suzuki
fasta.res <- read.alignment(file = system.file("sequences/Anouk.fasta", package = "seqinr"),
format = "fasta")
AA1 <- seqinr::getTrans(s2c(fasta.res$seq[[1]]))
AA2 <- seqinr::translate(s2c(fasta.res$seq[[1]]))
identical(AA1, AA2)
AA1 <- lapply(fasta.res$seq, function(x) seqinr::getTrans(s2c(x)))
AA2 <- lapply(fasta.res$seq, function(x) seqinr::translate(s2c(x)))
identical(AA1, AA2)
#
# Complex transsplicing operations, the correct frame and the correct
# genetic code are automatically used for translation into protein for
# sequences coming from an ACNUC server:
#
if (FALSE) {
# Need internet connection.
# Translation of the following EMBL entry:
#
# FT CDS join(complement(153944..154157),complement(153727..153866),
# FT complement(152185..153037),138523..138735,138795..138955)
# FT /codon_start=1
choosebank("emblTP")
trans <- query("trans", "N=AE003734.PE35")
getTrans(trans$req[[1]])
}
Run the code above in your browser using DataLab