Convert DNA to 3-base codons

dna2codon(x, ...)

Arguments

x

character vector assumed to contain DNA or RNA nucleotides

...

additional arguments are ignored.

Value

character vector where each element contains three characters, e.g. all(nchar(dna2codon(x)) == 3).

Details

This function takes character string input, either as one large string or vector of strings such as those read from a FASTA file, and returns a vector of 3-base codons. The final codon must contain all three character values otherwise it is removed.

See also

Other jam codon usage functions: codonUsage2df(), jamCai()

Examples

dna <- c("atgggattatag"); dna2codon(dna);
#> 1 2 3 4 #> "atg" "gga" "tta" "tag"
# example adding one extra base, which does not make a full codon dnaext1 <- c("atgggattataga"); dna2codon(dnaext1);
#> Warning: data length [13] is not a sub-multiple or multiple of the number of rows [5]
#> 1 2 3 4 #> "atg" "gga" "tta" "tag"