shave: Shave ends from DNA and amino acid sequences

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/utilities.R

Description

This function uses the Viterbi algorithm to semi-globally align a motif to a DNA or AA sequence, and removes all nucleotides to the left and/or right of the motif.

Usage

1
shave(x, motif, direction = "both", cores = 1, ...)

Arguments

x

an object of class DNAbin or AAbin.

motif

a DNAbin, AAbin or PHMM object.

direction

character string indicating the direction of the shave. Options are "forward" (shaves everything to the right of the motif), "backward" (shaves everything to the left of the motif) or "both" (retains the motif region only).

cores

integer giving the number of processors for multithreading. Defaults to 1, and reverts to 1 if x is not a list. This argument may alternatively be a 'cluster' object, in which case it is the user's responsibility to close the socket connection at the conclusion of the operation, for example by running parallel::stopCluster(cores). The string 'autodetect' is also accepted, in which case the maximum number of cores to use is one less than the total number of cores available. Note that in this case there may be a tradeoff in terms of speed depending on the number and size of sequences to be processed, due to the extra time required to initialize the cluster.

...

further arguments to be passed to Viterbi (not including 'type').

Details

This functions finds the optimal semiglobal alignment (a.k.a. "glocal" alignment or global alignment with free end gaps) between a sequence "x" and a shorter sequence "motif", returning the motif region of x along with the nucleotides to the left or right if direction is set to "reverse" or "forward", respectively.

Value

an object of class DNAbin or AAbin (depending on the input object).

Author(s)

Shaun Wilkinson

See Also

virtualPCR.

Examples

1
2
3
  data(whales)
  motif = char2dna("AAGTGTAGCATCACTTATTGATCCAAATT")
  shave(whales, motif = motif, direction = "both")

shaunpwilkinson/insect documentation built on Aug. 9, 2021, 5 a.m.