backTranslate: Replace amino acids with codons

View source: R/multialign.R

backTranslateR Documentation

Replace amino acids with codons

Description

Replaces aligned amino acids with their original codon triplets.

Usage

backTranslate(aa.msa, nuc.ffn)

Arguments

aa.msa

A fasta object with a multiple alignment, see msalign.

nuc.ffn

A fasta object with the coding sequences, see readFasta.

Details

This function replaces the aligned amino acids in aa.msa with their original codon triplets. This is possible only when the nucleotide sequences in nuc.ffn are the exact nucleotide sequences behind the protein sequences that are aligned in aa.msa.

It is required that the first token of the ‘⁠Header⁠’ lines is identical for a protein sequence in aa.msa and its nucleotide version in ‘⁠nuc.ffn⁠’, otherwise it is impossible to match them. Thus, they may not appear in the same order in the two input fasta objects.

When aligning coding sequences, one should in general always align their protein sequences, to keep the codon structure, and then use backTranslate to convert this into a nucleotide alignment, if required.

If the nuclotide sequences contain the stop codons, these will be removed.

Value

A fasta object similar to aa.msa, but where each amino acid has been replace by its corresponding codon. All gaps ‘⁠"-"⁠’ are replaced by triplets ‘⁠"---"⁠’.

Author(s)

Lars Snipen.

See Also

msalign, readFasta.

Examples

msa.file <- file.path(file.path(path.package("microseq"),"extdata"), "small.msa")
aa.msa <- readFasta(msa.file)
nuc.file <- file.path(file.path(path.package("microseq"),"extdata"), "small.ffn")
nuc <- readFasta(nuc.file)
nuc.msa <- backTranslate(aa.msa, nuc)


microseq documentation built on Aug. 21, 2023, 5:10 p.m.