string2dna

The string2dna provides a function to encode strings as nucleotide sequences and decode nucleotide sequences into their original text.

Installation

You can install the development version of string2dna from GitHub with:

# install.packages("devtools")
# devtools::install_github("stephenturner/string2dna")
install.packages("string2dna", repos = c('https://stephenturner.r-universe.dev', 'https://cloud.r-project.org'))

Example

The code below shows a simple example to encode a string and decode the same DNA sequence back to the original text.

library(string2dna)
string2dna("Stephen Turner", method="encode")
#> [1] "TGATAGCTAGAGCGTCTACTCAGCTAGGATCACCTCCTACAC"
string2dna("TGATAGCTAGAGCGTCTACTCAGCTAGGATCACCTCCTACAC", method="decode")
#> [1] "STEPHEN TURNER"

Download the full text of Pride and Prejudice by Jane Austen, and encode it into a ~2 megabase DNA sequence.

pride <- readr::read_lines("https://www.gutenberg.org/cache/epub/1342/pg1342.txt")
pride <- paste(pride, collapse=" ")
string2dna(pride, method="encode")

Shiny App

A simple Shiny app is available at stephenturner.shinyapps.io/string2dna.