Reverse given list of sequences.

reverse(x, ...)

# S3 method for sq
reverse(x, ..., NA_letter = getOption("tidysq_NA_letter"))

Arguments

x

[sq]
An object this function is applied to.

...

further arguments to be passed from or to other methods.

NA_letter

[character(1)]
A string that is used to interpret and display NA value in the context of sq class. Default value equals to "!".

Value

An sq object of the same type as input object but each sequence is reversed.

Details

reverse() function reverses each sequence in supplied sq object (e.q. transforms "MIAANYTWIL" to "LIWTYNAAIM"). This operation does not alter the type of the input object nor its alphabet.

See also

Functions that affect order of elements: bite(), collapse(), paste()

Examples

# Creating objects to work on:
sq_ami <- sq(c("MIAANYTWIL","TIAALGNIIYRAIE", "NYERTGHLI", "MAYXXXIALN"),
             alphabet = "ami_ext")
sq_dna <- sq(c("ATGCAGGA", "GACCGAACGAN", ""), alphabet = "dna_ext")
sq_unt <- sq(c("ATGCAGGA?", "TGACGAGCTTA", "", "TIAALGNIIYRAIE"))

# Reversing sequences:
reverse(sq_ami)
#> Error in (function (classes, fdef, mtable) {    methods <- .findInheritedMethods(classes, fdef, mtable)    if (length(methods) == 1L)         return(methods[[1L]])    else if (length(methods) == 0L) {        cnames <- paste0("\"", vapply(classes, as.character,             ""), "\"", collapse = ", ")        stop(gettextf("unable to find an inherited method for function %s for signature %s",             sQuote(fdef@generic), sQuote(cnames)), domain = NA)    }    else stop("Internal error in finding inherited methods; didn't return a unique method",         domain = NA)})(list("sq_ami_ext"), new("standardGeneric", .Data = function (x,     ...) standardGeneric("reverse"), generic = structure("reverse", package = "IRanges"),     package = "IRanges", group = list(), valueClass = character(0),     signature = "x", default = NULL, skeleton = (function (x,         ...)     stop("invalid call in method dispatch to 'reverse' (no default method)",         domain = NA))(x, ...)), <environment>): unable to find an inherited method for function ‘reverse’ for signature ‘"sq_ami_ext"’
reverse(sq_dna)
#> Error in (function (classes, fdef, mtable) {    methods <- .findInheritedMethods(classes, fdef, mtable)    if (length(methods) == 1L)         return(methods[[1L]])    else if (length(methods) == 0L) {        cnames <- paste0("\"", vapply(classes, as.character,             ""), "\"", collapse = ", ")        stop(gettextf("unable to find an inherited method for function %s for signature %s",             sQuote(fdef@generic), sQuote(cnames)), domain = NA)    }    else stop("Internal error in finding inherited methods; didn't return a unique method",         domain = NA)})(list("sq_dna_ext"), new("standardGeneric", .Data = function (x,     ...) standardGeneric("reverse"), generic = structure("reverse", package = "IRanges"),     package = "IRanges", group = list(), valueClass = character(0),     signature = "x", default = NULL, skeleton = (function (x,         ...)     stop("invalid call in method dispatch to 'reverse' (no default method)",         domain = NA))(x, ...)), <environment>): unable to find an inherited method for function ‘reverse’ for signature ‘"sq_dna_ext"’
reverse(sq_unt)
#> Error in (function (classes, fdef, mtable) {    methods <- .findInheritedMethods(classes, fdef, mtable)    if (length(methods) == 1L)         return(methods[[1L]])    else if (length(methods) == 0L) {        cnames <- paste0("\"", vapply(classes, as.character,             ""), "\"", collapse = ", ")        stop(gettextf("unable to find an inherited method for function %s for signature %s",             sQuote(fdef@generic), sQuote(cnames)), domain = NA)    }    else stop("Internal error in finding inherited methods; didn't return a unique method",         domain = NA)})(list("sq_unt"), new("standardGeneric", .Data = function (x,     ...) standardGeneric("reverse"), generic = structure("reverse", package = "IRanges"),     package = "IRanges", group = list(), valueClass = character(0),     signature = "x", default = NULL, skeleton = (function (x,         ...)     stop("invalid call in method dispatch to 'reverse' (no default method)",         domain = NA))(x, ...)), <environment>): unable to find an inherited method for function ‘reverse’ for signature ‘"sq_unt"’