Learn R Programming

spgs (version 1.0-4)

reverseComplement: Reverse Complement of a DNA/RNA Sequence

Description

Compute the reverse complement of a DNA or RNA sequence.

Usage

# S3 method for default
reverseComplement(x, content=c("dna", "rna"), case=c("lower", "upper", "as is"), ...)
# S3 method for SeqFastadna
reverseComplement(x, ...)
# S3 method for list
reverseComplement(x, ...)

Value

According to the input x, a character vector, SeqFastadna object or list containing the reverse complement(s) of the sequence(s) in x.

Arguments

x

A character vector, an object that can be coersed to a character vector or a list of objects that canbe be converted to character vectors. this argument can also be a SeqFastadna object provided by the seqinr package.

content

The content type of sequence(s). At present, supported types include “dna” and “rna”. the default type is “dna”.

case

Determines how symbols in x should be treated before translating them into their complements. “lower”, the default behaviour, converts all symbols to lowercase while “upper” converts them to uppercase. “as is” allows the symbols to pass unchanged so that the case of each output symbol matches that of the corresponding input symbol.

...

Arguments to be passed from or to other functions.

Author

Andrew Hart and Servet Martínez

Details

If x is a SeqFastadna object or a character vector in which each element is a single nucleobase, then it represents a single sequence and its reverse- complementary sequence will be returned in the same form.

On the other hand, if x is a vector of character strings, each of which represents a nucleic sequence, then the result will bea a character vector in which each element contains the reverse complement of the corresponding element in x as a character string.

See Also

complement

Examples

Run this code
reverseComplement("actg")
reverseComplement(c("t", "g", "a"))

#List of sequences
some.dna <- list("atgcgtcgttaa", c("g", "t", "g", "a", "a", "a"))
reverseComplement(some.dna)

#RNA sequence example
reverseComplement(c("a", "u", "g"), content="rna")

#Examples of lowercase, uppercase and as-is conversion
mixed.case <- c("t", "G", "g", "C", "a")
reverseComplement(mixed.case)
reverseComplement(mixed.case, case="upper")
reverseComplement(mixed.case, case="as is")

Run the code above in your browser using DataLab