\HeaderA{match-utils}{Utility functions operating on the matches returned by a
high-level matching function}{match.Rdash.utils}
\aliasA{coverage,MaskedXString-method}{match-utils}{coverage,MaskedXString.Rdash.method}
\aliasA{coverage,MIndex-method}{match-utils}{coverage,MIndex.Rdash.method}
\aliasA{mismatch}{match-utils}{mismatch}
\aliasA{mismatch,ANY,XStringViews-method}{match-utils}{mismatch,ANY,XStringViews.Rdash.method}
\aliasA{nmatch}{match-utils}{nmatch}
\aliasA{nmatch,ANY,XStringViews-method}{match-utils}{nmatch,ANY,XStringViews.Rdash.method}
\aliasA{nmismatch}{match-utils}{nmismatch}
\aliasA{nmismatch,ANY,XStringViews-method}{match-utils}{nmismatch,ANY,XStringViews.Rdash.method}
\keyword{methods}{match-utils}
\begin{Description}\relax
Miscellaneous utility functions operating on the matches returned by a
high-level matching function like \code{\LinkA{matchPattern}{matchPattern}},
\code{\LinkA{matchPDict}{matchPDict}}, etc...
\end{Description}
\begin{Usage}
\begin{verbatim}
  mismatch(pattern, x, fixed=TRUE)
  nmatch(pattern, x, fixed=TRUE)
  nmismatch(pattern, x, fixed=TRUE)
  ## S4 method for signature 'MIndex':
  coverage(x, shift=0L, width=NULL, weight=1L)
  ## S4 method for signature 'MaskedXString':
  coverage(x, shift=0L, width=NULL, weight=1L)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{pattern}] The pattern string.

\item[\code{x}] An \LinkA{XStringViews}{XStringViews} object for \code{mismatch} (typically, one returned
by \code{matchPattern(pattern, subject)}).

An \LinkA{MIndex}{MIndex} object for \code{coverage}, or any object for
which a \code{coverage} method is defined. See \code{?\LinkA{coverage}{coverage}}.

\item[\code{fixed}] See \code{?`\LinkA{lowlevel-matching}{lowlevel.Rdash.matching}`}.

\item[\code{shift, width}] See \code{?\LinkA{coverage}{coverage}}.

\item[\code{weight}] An integer vector specifying how much each element in \code{x} counts.

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The \code{mismatch} function gives the positions of the mismatching
letters of a given pattern relatively to its matches in a given subject.

The \code{nmatch} and \code{nmismatch} functions give the number of
matching and mismatching letters produced by the \code{mismatch} function.

The \code{coverage} function computes the "coverage" of a subject
by a given pattern or set of patterns.
\end{Details}
\begin{Value}
\code{mismatch}:  a list of integer vectors.

\code{nmismatch}:  an integer vector containing the length of the vectors
produced by \code{mismatch}.

\code{coverage}:  an \LinkA{Rle}{Rle} object indicating
the coverage of \code{x}.
See \code{?\LinkA{coverage}{coverage}} for the details.
If \code{x} is an \LinkA{MIndex}{MIndex} object, the coverage of a given position
in the underlying sequence (typically the subject used during the search
that returned \code{x}) is the number of matches (or hits) it belongs to.
\end{Value}
\begin{SeeAlso}\relax
\LinkA{lowlevel-matching}{lowlevel.Rdash.matching},
\code{\LinkA{matchPattern}{matchPattern}},
\code{\LinkA{matchPDict}{matchPDict}},
\LinkA{XString-class}{XString.Rdash.class},
\LinkA{XStringViews-class}{XStringViews.Rdash.class},
\LinkA{MIndex-class}{MIndex.Rdash.class},
\LinkA{coverage}{coverage},
\LinkA{align-utils}{align.Rdash.utils}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  ## ---------------------------------------------------------------------
  ## mismatch() / nmismatch()
  ## ---------------------------------------------------------------------
  subject <- DNAString("ACGTGCA")
  m <- matchPattern("NCA", subject, max.mismatch=1, fixed=FALSE)
  mismatch("NCA", m)
  nmismatch("NCA", m)

  ## ---------------------------------------------------------------------
  ## coverage()
  ## ---------------------------------------------------------------------
  coverage(m)

  ## See ?matchPDict for examples of using coverage() on an MIndex object...
\end{ExampleCode}
\end{Examples}

