Skip to contents

This function split a DNA sequence into a codon sequence.

Usage

base2codon(x, ...)

# S4 method for character
base2codon(x)

# S4 method for DNAStringSet
base2codon(x)

# S4 method for DNAMultipleAlignment
base2codon(x)

Arguments

x

A character string, DNAStringSet-class or DNAMultipleAlignment-class object carrying the a DNA sequence.

...

Not in use.

Value

If the argument of 'x' is character string, then a character vector of codons will returned. If the argument of 'x' is DNAStringSet-class or DNAMultipleAlignment-class object, then a matrix of codons is returned.

Details

It is expected that the provided DNA sequence is multiple of 3, otherwise gaps are added to the end of the sequence.

Author

Robersy Sanchez https://genomaths.com. 01/15/2022

Examples


## Gaps are added at the sequence end.
seq <- c("ACCT")
base2codon(x = seq)
#> Warning: *** Base sequence of 'x' is not multiple of 3. Gaps '-' have been added at the end of the sequence.
#> [1] "ACC" "T--"

## This DNA sequence is multiple of 3
seq <- c("ACCTCA")
base2codon(x = seq)
#> [1] "ACC" "TCA"

## Load a DNAStringSet. A matrix of codons is returned
data("aln", package = "GenomAutomorphism")
base2codon(x = aln)
#>       [,1]  [,2] 
#>  [1,] "ACC" "ATC"
#>  [2,] "TAT" "TAT"
#>  [3,] "GTT" "GTT"
#>  [4,] "GGT" "GGT"
#>  [5,] "ATT" "ATT"
#>  [6,] "---" "ACG"
#>  [7,] "GCG" "ACG"
#>  [8,] "CTC" "CTC"
#>  [9,] "CAA" "CAA"
#> [10,] "CTC" "TTC"
#> [11,] "CTT" "CTT"
#> [12,] "GGC" "GGG"
#> [13,] "TCT" "TCC"
#> [14,] "AGC" "---"
#> [15,] "TCA" "---"
#> [16,] "CTA" "CTC"
#> [17,] "CAT" "CTT"