Skip to contents

A simple function to represent DNA bases as elements from the Abelian group of integers modulo 4 (Z4) or 5 (Z5).

Usage

base2int(base, ...)

# S4 method for character
base2int(
  base,
  group = c("Z4", "Z5", "Z64", "Z125", "Z4^3", "Z5^3"),
  cube = c("ACGT", "AGCT", "TCGA", "TGCA", "CATG", "GTAC", "CTAG", "GATC", "ACTG",
    "ATCG", "GTCA", "GCTA", "CAGT", "TAGC", "TGAC", "CGAT", "AGTC", "ATGC", "CGTA",
    "CTGA", "GACT", "GCAT", "TACG", "TCAG")
)

# S4 method for data.frame
base2int(
  base,
  group = c("Z4", "Z5", "Z64", "Z125", "Z4^3", "Z5^3"),
  cube = c("ACGT", "AGCT", "TCGA", "TGCA", "CATG", "GTAC", "CTAG", "GATC", "ACTG",
    "ATCG", "GTCA", "GCTA", "CAGT", "TAGC", "TGAC", "CGAT", "AGTC", "ATGC", "CGTA",
    "CTGA", "GACT", "GCAT", "TACG", "TCAG")
)

Arguments

base

A character vector, string , or a dataframe of letters from the DNA/RNA alphabet.

...

Not in use.

group

A character string denoting the group representation for the given base or codon as shown in reference (2-3).

cube

A character string denoting one of the 24 Genetic-code cubes, as given in references (2-3).

Value

A numerical vector.

References

  1. Robersy Sanchez, Jesus Barreto (2021) Genomic Abelian Finite Groups. doi: 10.1101/2021.06.01.446543

  2. M. V Jose, E.R. Morgado, R. Sanchez, T. Govezensky, The 24 possible algebraic representations of the standard genetic code in six or in three dimensions, Adv. Stud. Biol. 4 (2012) 119-152.PDF.

  3. R. Sanchez. Symmetric Group of the Genetic-Code Cubes. Effect of the Genetic-Code Architecture on the Evolutionary Process MATCH Commun. Math. Comput. Chem. 79 (2018) 527-560.

See also

Author

Robersy Sanchez https://genomaths.com

Examples

## A triplet with a letter not from DNA/RNA alphabet
## 'NA' is introduced by coercion!
base2int("UDG")
#> Warning: NAs introduced by coercion
#> [1]  3 NA  2

## The base replacement in cube "ACGT and group "Z4"
base2int("ACGT")
#> [1] 0 1 2 3

## The base replacement in cube "ACGT and group "Z5"
base2int("ACGT", group = "Z5")
#> [1] 1 2 3 4

## A vector of DNA base triplets
base2int(c("UTG", "GTA"))
#>      [,1] [,2] [,3]
#> [1,]    3    3    2
#> [2,]    2    3    0

##  A vector of DNA base triplets with different number of triplets.
##  Codon 'GTA' is recycled!
base2int(base = c("UTGGTA", "CGA"), group = "Z5")
#>      [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,]    4    4    3    3    4    1
#> [2,]    2    3    1    2    3    1

## data.frames must carry only single letters
# \donttest{
base2int(data.frame(x1 = c("UTG", "GTA"), x2 = c("UTG", "GTA")))
#> Error in .local(base, ...): *** Argument 'x' must carry only single letters.
# }