\HeaderA{chartr}{Translating letters of a sequence}{chartr}
\aliasA{chartr,ANY,ANY,MaskedXString-method}{chartr}{chartr,ANY,ANY,MaskedXString.Rdash.method}
\aliasA{chartr,ANY,ANY,XString-method}{chartr}{chartr,ANY,ANY,XString.Rdash.method}
\aliasA{chartr,ANY,ANY,XStringSet-method}{chartr}{chartr,ANY,ANY,XStringSet.Rdash.method}
\aliasA{chartr,ANY,ANY,XStringViews-method}{chartr}{chartr,ANY,ANY,XStringViews.Rdash.method}
\keyword{methods}{chartr}
\keyword{manip}{chartr}
\begin{Description}\relax
Translate letters of a sequence.
\end{Description}
\begin{Usage}
\begin{verbatim}
  ## S4 method for signature 'ANY, ANY, XString':
  chartr(old, new, x)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{old}] A character string specifying the characters to be translated.

\item[\code{new}] A character string specifying the translations.

\item[\code{x}] The sequence or set of sequences to translate.
If \code{x} is an \LinkA{XString}{XString}, \LinkA{XStringSet}{XStringSet}, \LinkA{XStringViews}{XStringViews}
or \LinkA{MaskedXString}{MaskedXString} object, then the appropriate \code{chartr} method
is called, otherwise the standard \code{\LinkA{chartr}{chartr}} R function
is called.

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
See \code{?\LinkA{chartr}{chartr}} for the details.

Note that, unlike the standard \code{\LinkA{chartr}{chartr}} R function,
the methods for \LinkA{XString}{XString}, \LinkA{XStringSet}{XStringSet}, \LinkA{XStringViews}{XStringViews}
and \LinkA{MaskedXString}{MaskedXString} objects do NOT support character ranges in the
specifications.
\end{Details}
\begin{Value}
An object of the same class and length as the original object.
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{chartr}{chartr}},
\code{\LinkA{replaceLetterAt}{replaceLetterAt}},
\LinkA{XString-class}{XString.Rdash.class},
\LinkA{XStringSet-class}{XStringSet.Rdash.class},
\LinkA{XStringViews-class}{XStringViews.Rdash.class},
\LinkA{MaskedXString-class}{MaskedXString.Rdash.class},
\code{\LinkA{alphabetFrequency}{alphabetFrequency}},
\code{\LinkA{matchPattern}{matchPattern}},
\code{\LinkA{reverseComplement}{reverseComplement}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  x <- BString("MiXeD cAsE 123")
  chartr("iXs", "why", x)

  ## ---------------------------------------------------------------------
  ## TRANSFORMING DNA WITH BISULFITE (AND SEARCHING IT...)
  ## ---------------------------------------------------------------------

  library(BSgenome.Celegans.UCSC.ce2)
  chrII <- Celegans[["chrII"]]
  alphabetFrequency(chrII)
  pattern <- DNAString("TGGGTGTATTTA")

  ## Transforming and searching the + strand
  plus_strand <- chartr("C", "T", chrII)
  alphabetFrequency(plus_strand)
  matchPattern(pattern, plus_strand)
  matchPattern(pattern, chrII)

  ## Transforming and searching the - strand
  minus_strand <- chartr("G", "A", chrII)
  alphabetFrequency(minus_strand)
  matchPattern(reverseComplement(pattern), minus_strand)
  matchPattern(reverseComplement(pattern), chrII)
\end{ExampleCode}
\end{Examples}

