File: comp.Rd

package info (click to toggle)
r-cran-seqinr 3.3-3-1~bpo8+1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 5,844 kB
  • sloc: ansic: 1,955; makefile: 13
file content (64 lines) | stat: -rw-r--r-- 1,693 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
\name{comp}
\alias{comp}
\title{ complements a nucleic acid sequence }
\description{
    Complements a sequence, for instance if the sequence is 
    \code{"a","c","g","t"} it returns \code{"t","g","c","a"}. 
    This is not the reverse complementary strand. This function
    can handle ambiguous bases if required.
}
\usage{
comp(seq, forceToLower = TRUE, ambiguous = FALSE)
}
\arguments{
  \item{seq}{ a DNA sequence as a vector of single chars }
  \item{forceToLower}{ if TRUE characters in \code{seq} are forced to lower case}
  \item{ambiguous}{ if TRUE ambiguous bases in \code{seq} are handled} 
}
\value{
  a vector of characters which is the complement of the sequence,
  not the reverse complementary strand. Undefined values are
  returned as NA.
}
\author{D. Charif, J.R. Lobry}
\references{
  \code{citation("seqinr")}
}
\seealso{ Because ssDNA sequences are always written in the 5'->3'
direction, use rev(comp(seq)) to get the reverse complementary
strand (see \code{\link{rev}}).
}
\examples{
##
## Show that comp() does *not* return the reverve complementary strand:
##

c2s(comp(s2c("aaaattttggggcccc")))

##
## Show how to get the reverse complementary strand:
##

c2s(rev(comp(s2c("aaaattttggggcccc"))))

##
## Show what happens with non allowed values:
##

c2s(rev(comp(s2c("aaaaXttttYggggZcccc"))))

##
## Show what happens with ambiguous bases:
##

allbases <- s2c("abcdghkmstvwn")
comp(allbases) # NA are produced
comp(allbases, ambiguous = TRUE) # No more NA

##
## Routine sanity checks:
##

stopifnot(identical(comp(allbases, ambiguous = TRUE), s2c("tvghcdmksabwn")))
stopifnot(identical(comp(c("A", "C", "G", "T"), forceToLower = FALSE), c("T", "G", "C", "A")))
}