\HeaderA{align-utils}{Utility functions related to sequence alignment}{align.Rdash.utils}
\aliasA{compareStrings}{align-utils}{compareStrings}
\aliasA{compareStrings,AlignedXStringSet0,AlignedXStringSet0-method}{align-utils}{compareStrings,AlignedXStringSet0,AlignedXStringSet0.Rdash.method}
\aliasA{compareStrings,character,character-method}{align-utils}{compareStrings,character,character.Rdash.method}
\aliasA{compareStrings,PairwiseAlignedXStringSet,missing-method}{align-utils}{compareStrings,PairwiseAlignedXStringSet,missing.Rdash.method}
\aliasA{compareStrings,XString,XString-method}{align-utils}{compareStrings,XString,XString.Rdash.method}
\aliasA{compareStrings,XStringSet,XStringSet-method}{align-utils}{compareStrings,XStringSet,XStringSet.Rdash.method}
\aliasA{consensusMatrix,PairwiseAlignedFixedSubject-method}{align-utils}{consensusMatrix,PairwiseAlignedFixedSubject.Rdash.method}
\aliasA{coverage,AlignedXStringSet0-method}{align-utils}{coverage,AlignedXStringSet0.Rdash.method}
\aliasA{coverage,PairwiseAlignedFixedSubject-method}{align-utils}{coverage,PairwiseAlignedFixedSubject.Rdash.method}
\aliasA{coverage,PairwiseAlignedFixedSubjectSummary-method}{align-utils}{coverage,PairwiseAlignedFixedSubjectSummary.Rdash.method}
\aliasA{mismatch,AlignedXStringSet0,missing-method}{align-utils}{mismatch,AlignedXStringSet0,missing.Rdash.method}
\aliasA{mismatchSummary}{align-utils}{mismatchSummary}
\aliasA{mismatchSummary,AlignedXStringSet0-method}{align-utils}{mismatchSummary,AlignedXStringSet0.Rdash.method}
\aliasA{mismatchSummary,PairwiseAlignedFixedSubject-method}{align-utils}{mismatchSummary,PairwiseAlignedFixedSubject.Rdash.method}
\aliasA{mismatchSummary,PairwiseAlignedFixedSubjectSummary-method}{align-utils}{mismatchSummary,PairwiseAlignedFixedSubjectSummary.Rdash.method}
\aliasA{mismatchSummary,QualityAlignedXStringSet-method}{align-utils}{mismatchSummary,QualityAlignedXStringSet.Rdash.method}
\aliasA{mismatchTable}{align-utils}{mismatchTable}
\aliasA{mismatchTable,AlignedXStringSet0-method}{align-utils}{mismatchTable,AlignedXStringSet0.Rdash.method}
\aliasA{mismatchTable,PairwiseAlignedXStringSet-method}{align-utils}{mismatchTable,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{mismatchTable,QualityAlignedXStringSet-method}{align-utils}{mismatchTable,QualityAlignedXStringSet.Rdash.method}
\aliasA{nedit}{align-utils}{nedit}
\aliasA{nedit,PairwiseAlignedFixedSubjectSummary-method}{align-utils}{nedit,PairwiseAlignedFixedSubjectSummary.Rdash.method}
\aliasA{nedit,PairwiseAlignedXStringSet-method}{align-utils}{nedit,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{nmatch,PairwiseAlignedFixedSubjectSummary,missing-method}{align-utils}{nmatch,PairwiseAlignedFixedSubjectSummary,missing.Rdash.method}
\aliasA{nmatch,PairwiseAlignedXStringSet,missing-method}{align-utils}{nmatch,PairwiseAlignedXStringSet,missing.Rdash.method}
\aliasA{nmismatch,AlignedXStringSet0,missing-method}{align-utils}{nmismatch,AlignedXStringSet0,missing.Rdash.method}
\aliasA{nmismatch,PairwiseAlignedFixedSubjectSummary,missing-method}{align-utils}{nmismatch,PairwiseAlignedFixedSubjectSummary,missing.Rdash.method}
\aliasA{nmismatch,PairwiseAlignedXStringSet,missing-method}{align-utils}{nmismatch,PairwiseAlignedXStringSet,missing.Rdash.method}
\keyword{methods}{align-utils}
\begin{Description}\relax
A variety of different functions used to deal with sequence alignments.
\end{Description}
\begin{Usage}
\begin{verbatim}
  nedit(x) # also nmatch and nmismatch

  mismatchTable(x, shiftLeft=0L, shiftRight=0L, ...)
  mismatchSummary(x, ...)
  ## S4 method for signature 'AlignedXStringSet0':
  coverage(x, shift=0L, width=NULL, weight=1L)
  ## S4 method for signature 'PairwiseAlignedFixedSubject':
  coverage(x, shift=0L, width=NULL, weight=1L)
  compareStrings(pattern, subject)

  ## S4 method for signature 'PairwiseAlignedFixedSubject':
  consensusMatrix(x,
                  as.prob=FALSE, freq=FALSE, shift=0L, width=NULL,
                  baseOnly=FALSE, gapCode="-", endgapCode="-")
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] A \code{character} vector or matrix, \code{XStringSet}, \code{XStringViews},
\code{PairwiseAlignedXStringSet}, or \code{list} of FASTA records containing
the equal-length strings.

\item[\code{shiftLeft, shiftRight}] Non-positive and non-negative integers respectively that specify how many
preceding and succeeding characters to and from the mismatch position to
include in the mismatch substrings.

\item[\code{...}] Further arguments to be passed to or from other methods.

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

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

\item[\code{pattern, subject}] The strings to compare. Can be of type \code{character}, \code{XString},
\code{XStringSet}, \code{AlignedXStringSet}, or, in the case of
\code{pattern}, \code{PairwiseAlignedXStringSet}. If \code{pattern} is a
\code{PairwiseAlignedXStringSet} object, then \code{subject} must be
missing.

\item[\code{as.prob}] If \code{TRUE} then probabilities are reported,
otherwise counts (the default).

\item[\code{freq}] This argument is deprecated.
Please use the \code{as.prob} argument instead.

\item[\code{baseOnly}] \code{TRUE} or \code{FALSE}.
If \code{TRUE}, the returned vector only contains frequencies for the
letters in the "base" alphabet i.e. "A", "C", "G", "T" if \code{x}
is a "DNA input", and "A", "C", "G", "U" if \code{x} is "RNA input".
When \code{x} is a \LinkA{BString}{BString} object (or an \LinkA{XStringViews}{XStringViews}
object with a \LinkA{BString}{BString} subject, or a \LinkA{BStringSet}{BStringSet} object),
then the \code{baseOnly} argument is ignored.

\item[\code{gapCode, endgapCode}] The codes in the appropriate \code{\LinkA{alphabet}{alphabet}} to use for the internal
and end gaps.

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{mismatchTable}:  a data.frame containing the positions and substrings
of the mismatches for the \code{AlignedXStringSet} or
\code{PairwiseAlignedXStringSet} object.

\code{mismatchSummary}:  a list of data.frame objects containing counts and
frequencies of the mismatches for the \code{AlignedXStringSet} or
\code{PairwiseAlignedFixedSubject} object.

\code{compareStrings} combines two equal-length strings that are assumed to be
aligned into a single character string containing that replaces mismatches
with \code{"?"}, insertions with \code{"+"}, and deletions with \code{"-"}.
\end{Details}
\begin{SeeAlso}\relax
\code{\LinkA{pairwiseAlignment}{pairwiseAlignment}},
\code{\LinkA{consensusMatrix}{consensusMatrix}},
\LinkA{XString-class}{XString.Rdash.class}, \LinkA{XStringSet-class}{XStringSet.Rdash.class}, \LinkA{XStringViews-class}{XStringViews.Rdash.class},
\LinkA{AlignedXStringSet-class}{AlignedXStringSet.Rdash.class}, \LinkA{PairwiseAlignedXStringSet-class}{PairwiseAlignedXStringSet.Rdash.class},
\LinkA{match-utils}{match.Rdash.utils}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  ## Compare two globally aligned strings
  string1 <- "ACTTCACCAGCTCCCTGGCGGTAAGTTGATC---AAAGG---AAACGCAAAGTTTTCAAG"
  string2 <- "GTTTCACTACTTCCTTTCGGGTAAGTAAATATATAAATATATAAAAATATAATTTTCATC"
  compareStrings(string1, string2)

  ## Create a consensus matrix
  nw1 <-
    pairwiseAlignment(AAStringSet(c("HLDNLKGTF", "HVDDMPNAL")), AAString("SMDDTEKMSMKL"),
      substitutionMatrix = "BLOSUM50", gapOpening = -3, gapExtension = -1)
  consensusMatrix(nw1)

  ## Examine the consensus between the bacteriophage phi X174 genomes
  data(phiX174Phage)
  phageConsmat <- consensusMatrix(phiX174Phage, baseOnly = TRUE)
  phageDiffs <- which(apply(phageConsmat, 2, max) < length(phiX174Phage))
  phageDiffs
  phageConsmat[,phageDiffs]
\end{ExampleCode}
\end{Examples}

