Skip to contents

[Experimental] Method for converting from DNA or RNA strings in various formats to a set of codons.

Usage

as_codons(sequence)

# S4 method for DNAString
as_codons(sequence)

# S4 method for RNAString
as_codons(sequence)

# S4 method for character
as_codons(sequence)

Arguments

sequence

an object representing a translatable sequence

Value

a character vector of DNA triplets

Details

This converts a sequence to a character vector of DNA triplets. This function is not vectorized. Supported input types are DNAString, RNAString, and character vector.

Examples

orf <- Biostrings::DNAString("ATGAAATAG")
as_codons(orf)
#> [1] "ATG" "AAA" "TAG"

rna <- Biostrings::RNAString("AUGAAAUAG")
as_codons(rna)
#> [1] "ATG" "AAA" "TAG"

rna <- "AUGAAAUAG"
as_codons(rna)
#> [1] "ATG" "AAA" "TAG"

dna <- "ATGAAATAG"
as_codons(dna)
#> [1] "ATG" "AAA" "TAG"