\HeaderA{PairwiseAlignedXStringSet-class}{PairwiseAlignedXStringSet, PairwiseAlignedFixedSubject, and
PairwiseAlignedFixedSubjectSummary objects}{PairwiseAlignedXStringSet.Rdash.class}
\aliasA{aligned,PairwiseAlignedFixedSubject-method}{PairwiseAlignedXStringSet-class}{aligned,PairwiseAlignedFixedSubject.Rdash.method}
\aliasA{as.character,PairwiseAlignedFixedSubject-method}{PairwiseAlignedXStringSet-class}{as.character,PairwiseAlignedFixedSubject.Rdash.method}
\aliasA{as.matrix,PairwiseAlignedFixedSubject-method}{PairwiseAlignedXStringSet-class}{as.matrix,PairwiseAlignedFixedSubject.Rdash.method}
\aliasA{class:PairwiseAlignedFixedSubject}{PairwiseAlignedXStringSet-class}{class:PairwiseAlignedFixedSubject}
\aliasA{class:PairwiseAlignedFixedSubjectSummary}{PairwiseAlignedXStringSet-class}{class:PairwiseAlignedFixedSubjectSummary}
\aliasA{class:PairwiseAlignedXStringSet}{PairwiseAlignedXStringSet-class}{class:PairwiseAlignedXStringSet}
\aliasA{deletion,PairwiseAlignedXStringSet-method}{PairwiseAlignedXStringSet-class}{deletion,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{indel,PairwiseAlignedXStringSet-method}{PairwiseAlignedXStringSet-class}{indel,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{insertion,PairwiseAlignedXStringSet-method}{PairwiseAlignedXStringSet-class}{insertion,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{length,PairwiseAlignedFixedSubjectSummary-method}{PairwiseAlignedXStringSet-class}{length,PairwiseAlignedFixedSubjectSummary.Rdash.method}
\aliasA{length,PairwiseAlignedXStringSet-method}{PairwiseAlignedXStringSet-class}{length,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{nchar,PairwiseAlignedFixedSubjectSummary-method}{PairwiseAlignedXStringSet-class}{nchar,PairwiseAlignedFixedSubjectSummary.Rdash.method}
\aliasA{nchar,PairwiseAlignedXStringSet-method}{PairwiseAlignedXStringSet-class}{nchar,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{nindel,PairwiseAlignedFixedSubjectSummary-method}{PairwiseAlignedXStringSet-class}{nindel,PairwiseAlignedFixedSubjectSummary.Rdash.method}
\aliasA{nindel,PairwiseAlignedXStringSet-method}{PairwiseAlignedXStringSet-class}{nindel,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{PairwiseAlignedFixedSubject}{PairwiseAlignedXStringSet-class}{PairwiseAlignedFixedSubject}
\aliasA{PairwiseAlignedFixedSubject,character,character-method}{PairwiseAlignedXStringSet-class}{PairwiseAlignedFixedSubject,character,character.Rdash.method}
\aliasA{PairwiseAlignedFixedSubject,character,missing-method}{PairwiseAlignedXStringSet-class}{PairwiseAlignedFixedSubject,character,missing.Rdash.method}
\aliasA{PairwiseAlignedFixedSubject,XString,XString-method}{PairwiseAlignedXStringSet-class}{PairwiseAlignedFixedSubject,XString,XString.Rdash.method}
\aliasA{PairwiseAlignedFixedSubject,XStringSet,missing-method}{PairwiseAlignedXStringSet-class}{PairwiseAlignedFixedSubject,XStringSet,missing.Rdash.method}
\aliasA{PairwiseAlignedFixedSubject-class}{PairwiseAlignedXStringSet-class}{PairwiseAlignedFixedSubject.Rdash.class}
\aliasA{PairwiseAlignedFixedSubjectSummary}{PairwiseAlignedXStringSet-class}{PairwiseAlignedFixedSubjectSummary}
\aliasA{PairwiseAlignedFixedSubjectSummary-class}{PairwiseAlignedXStringSet-class}{PairwiseAlignedFixedSubjectSummary.Rdash.class}
\aliasA{PairwiseAlignedXStringSet}{PairwiseAlignedXStringSet-class}{PairwiseAlignedXStringSet}
\aliasA{PairwiseAlignedXStringSet,character,character-method}{PairwiseAlignedXStringSet-class}{PairwiseAlignedXStringSet,character,character.Rdash.method}
\aliasA{PairwiseAlignedXStringSet,character,missing-method}{PairwiseAlignedXStringSet-class}{PairwiseAlignedXStringSet,character,missing.Rdash.method}
\aliasA{PairwiseAlignedXStringSet,XString,XString-method}{PairwiseAlignedXStringSet-class}{PairwiseAlignedXStringSet,XString,XString.Rdash.method}
\aliasA{PairwiseAlignedXStringSet,XStringSet,missing-method}{PairwiseAlignedXStringSet-class}{PairwiseAlignedXStringSet,XStringSet,missing.Rdash.method}
\aliasA{pattern,PairwiseAlignedXStringSet-method}{PairwiseAlignedXStringSet-class}{pattern,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{rep,PairwiseAlignedXStringSet-method}{PairwiseAlignedXStringSet-class}{rep,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{score,PairwiseAlignedFixedSubjectSummary-method}{PairwiseAlignedXStringSet-class}{score,PairwiseAlignedFixedSubjectSummary.Rdash.method}
\aliasA{score,PairwiseAlignedXStringSet-method}{PairwiseAlignedXStringSet-class}{score,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{show,PairwiseAlignedFixedSubjectSummary-method}{PairwiseAlignedXStringSet-class}{show,PairwiseAlignedFixedSubjectSummary.Rdash.method}
\aliasA{show,PairwiseAlignedXStringSet-method}{PairwiseAlignedXStringSet-class}{show,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{subject,PairwiseAlignedXStringSet-method}{PairwiseAlignedXStringSet-class}{subject,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{summary,PairwiseAlignedFixedSubject-method}{PairwiseAlignedXStringSet-class}{summary,PairwiseAlignedFixedSubject.Rdash.method}
\aliasA{toString,PairwiseAlignedFixedSubject-method}{PairwiseAlignedXStringSet-class}{toString,PairwiseAlignedFixedSubject.Rdash.method}
\aliasA{type}{PairwiseAlignedXStringSet-class}{type}
\aliasA{type,PairwiseAlignedFixedSubjectSummary-method}{PairwiseAlignedXStringSet-class}{type,PairwiseAlignedFixedSubjectSummary.Rdash.method}
\aliasA{type,PairwiseAlignedXStringSet-method}{PairwiseAlignedXStringSet-class}{type,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{Views,PairwiseAlignedFixedSubject-method}{PairwiseAlignedXStringSet-class}{Views,PairwiseAlignedFixedSubject.Rdash.method}
\aliasA{xsbasetype,PairwiseAlignedXStringSet-method}{PairwiseAlignedXStringSet-class}{xsbasetype,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{[,PairwiseAlignedXStringSet-method}{PairwiseAlignedXStringSet-class}{[,PairwiseAlignedXStringSet.Rdash.method}
\aliasA{[<-,PairwiseAlignedXStringSet-method}{PairwiseAlignedXStringSet-class}{[<.Rdash.,PairwiseAlignedXStringSet.Rdash.method}
\keyword{methods}{PairwiseAlignedXStringSet-class}
\keyword{classes}{PairwiseAlignedXStringSet-class}
\begin{Description}\relax
The \code{PairwiseAlignedXStringSet} class is a container for storing an
elementwise pairwise alignment.
The \code{PairwiseAlignedFixedSubject} class is a container for storing a
pairwise alignment with a single subject.
The \code{PairwiseAlignedFixedSubjectSummary} class is a container for storing
the summary of an alignment.
\end{Description}
\begin{Usage}
\begin{verbatim}
  ## Constructors:
  ## When subject is missing, pattern must be of length 2
  ## S4 method for signature 'XString, XString':
  PairwiseAlignedXStringSet(pattern, subject,
    type = "global", substitutionMatrix = NULL, gapOpening = 0, gapExtension = -1)
  ## S4 method for signature 'XStringSet, missing':
  PairwiseAlignedXStringSet(pattern, subject,
    type = "global", substitutionMatrix = NULL, gapOpening = 0, gapExtension = -1)
  ## S4 method for signature 'character, character':
  PairwiseAlignedXStringSet(pattern, subject,
    type = "global", substitutionMatrix = NULL, gapOpening = 0, gapExtension = -1,
    baseClass = "BString")
  ## S4 method for signature 'character, missing':
  PairwiseAlignedXStringSet(pattern, subject,
    type = "global", substitutionMatrix = NULL, gapOpening = 0, gapExtension = -1,
    baseClass = "BString")
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{pattern}] a character vector of length 1 or 2, an \code{\LinkA{XString}{XString}},
or an \code{\LinkA{XStringSet}{XStringSet}} object of length 1 or 2.
\item[\code{subject}] a character vector of length 1 or an \code{\LinkA{XString}{XString}} object.
\item[\code{type}] type of alignment. One of \code{"global"}, \code{"local"},
\code{"overlap"}, \code{"global-local"}, and \code{"local-global"} where
\code{"global"} = align whole strings with end gap penalties,
\code{"local"} = align string fragments,
\code{"overlap"} = align whole strings without end gap penalties,
\code{"global-local"} = align whole strings with end gap penalties on
\code{pattern} and without end gap penalties on \code{subject}.
\code{"local-global"} = align whole strings without end gap penalties on
\code{pattern} and with end gap penalties on \code{subject}.
\item[\code{substitutionMatrix}] substitution matrix for the alignment. If NULL,
the diagonal values and off-diagonal values are set to 0 and 1 respectively.
\item[\code{gapOpening}] the cost for opening a gap in the alignment.
\item[\code{gapExtension}] the incremental cost incurred along the length of the gap
in the alignment.
\item[\code{baseClass}] the base \code{\LinkA{XString}{XString}} class to use in the alignment.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Before we define the notion of alignment, we introduce the notion of
"filled-with-gaps subsequence". A "filled-with-gaps subsequence" of
a string string1 is obtained by inserting 0 or any number of gaps in
a subsequence of s1. For example L-A--ND and A--N-D are
"filled-with-gaps subsequences" of LAND. An alignment between two strings
string1 and string2 results in two strings (align1 and align2) that have
the same length and are "filled-with-gaps subsequences" of string1 and string2.

For example, this is an alignment between LAND and LEAVES:
\begin{alltt}
    L-A
    LEA
\end{alltt}

An alignment can be seen as a compact representation of one set of basic
operations that transforms string1 into align1. There are 3 different kinds
of basic operations: "insertions" (gaps in align1), "deletions" (gaps in
align2),  "replacements".
The above alignment represents the following basic operations:
\begin{alltt}
    insert E at pos 2
    insert V at pos 4
    insert E at pos 5
    replace by S at pos 6 (N is replaced by S)
    delete at pos 7 (D is deleted)
\end{alltt}
Note that "insert X at pos i" means that all letters at a position >= i
are moved 1 place to the right before X is actually inserted.

There are many possible alignments between two given strings string1 and
string2 and a common problem is to find the one (or those ones) with the
highest score, i.e. with the lower total cost in terms of basic operations.
\end{Details}
\begin{Section}{Object extraction methods}
In the code snippets below,
\code{x} is a \code{PairwiseAlignedXStringSet} object, except otherwise noted.

\describe{
\item[] \code{pattern(x)}:
The \code{AlignedXStringSet} object for the pattern.

\item[] \code{subject(x)}:
The \code{AlignedXStringSet} object for the subject.

\item[] \code{summary(object, ...)}:
Generates a summary for the \code{PairwiseAlignedXStringSet}.

}
\end{Section}
\begin{Section}{General information methods}
In the code snippets below,
\code{x} is a \code{PairwiseAlignedXStringSet} object, except otherwise noted.

\describe{
\item[] \code{alphabet(x)}:
Equivalent to \code{alphabet(unaligned(subject(x)))}.

\item[] \code{length(x)}:
The length of the \code{aligned(pattern(x))} and
\code{aligned(subject(x))}. 
There is a method for \code{PairwiseAlignedFixedSubjectSummary} as well.

\item[] \code{type(x)}:
The type of the alignment (\code{"global"}, \code{"local"},
\code{"overlap"}, \code{"global-local"}, or \code{"local-global"}).
There is a method for \code{PairwiseAlignedFixedSubjectSummary} as well.

}
\end{Section}
\begin{Section}{Aligned sequence methods}
In the code snippets below,
\code{x} is a \code{PairwiseAlignedFixedSubject} object, except
otherwise noted. 

\describe{
\item[] \code{aligned(x, degap = FALSE, gapCode="-", endgapCode="-")}:
If \code{degap = FALSE}, "align" the alignments by returning an
\code{XStringSet} object containing the aligned patterns without
insertions. If \code{degap = TRUE}, returns
\code{aligned(pattern(x), degap=TRUE)}.
The \code{gapCode} and \code{endgapCode} arguments denote the code in the
appropriate \code{\LinkA{alphabet}{alphabet}} to use for the internal and end gaps.

\item[] \code{as.character(x)}:
Converts \code{aligned(x)} to a character vector.

\item[] \code{as.matrix(x)}:
Returns an "exploded" character matrix representation of \code{aligned(x)}.

\item[] \code{toString(x)}:
Equivalent to \code{toString(as.character(x))}.

}
\end{Section}
\begin{Section}{Subject position methods}
In the code snippets below,
\code{x} is a \code{PairwiseAlignedFixedSubject} object, except otherwise noted.

\describe{
\item[] \code{consensusMatrix(x, as.prob=FALSE, baseOnly=FALSE, gapCode="-",
        endgapCode="-")}
See `\LinkA{consensusMatrix}{consensusMatrix}` for more information.

\item[] \code{consensusString(x)}
See `\LinkA{consensusString}{consensusString}` for more information.

\item[] \code{coverage(x, shift=0L, width=NULL, weight=1L)}
See `\LinkA{coverage,PairwiseAlignedFixedSubject-method}{coverage,PairwiseAlignedFixedSubject.Rdash.method}` for more
information.

\item[] \code{Views(subject, start=NULL, end=NULL, width=NULL, names=NULL)}:
The \code{XStringViews} object that represents the pairwise alignments
along \code{unaligned(subject(subject))}. The \code{start} and \code{end}
arguments must be either \code{NULL}/\code{NA} or an integer vector
of length 1 that denotes the offset from \code{start(subject(subject))}.

}
\end{Section}
\begin{Section}{Numeric summary methods}
In the code snippets below,
\code{x} is a \code{PairwiseAlignedXStringSet} object, except otherwise noted.

\describe{
\item[] \code{nchar(x)}:
The nchar of the \code{aligned(pattern(x))} and \code{aligned(subject(x))}.
There is a method for \code{PairwiseAlignedFixedSubjectSummary} as well.

\item[] \code{insertion(x)}:
An \code{\LinkA{CompressedIRangesList}{CompressedIRangesList}}
object containing the 
locations of the insertions from the perspective of the \code{pattern}.

\item[] \code{deletion(x)}:
An \code{\LinkA{CompressedIRangesList}{CompressedIRangesList}}
object containing the 
locations of the deletions from the perspective of the \code{pattern}.

\item[] \code{indel(x)}:
An \code{InDel} object containing the locations of the insertions and
deletions from the perspective of the \code{pattern}.

\item[] \code{nindel(x)}:
An \code{InDel} object containing the number of insertions and deletions.

\item[] \code{score(x)}:
The score of the alignment.
There is a method for \code{PairwiseAlignedFixedSubjectSummary} as well.

}
\end{Section}
\begin{Section}{Subsetting methods}
\describe{
\item[] \code{x[i]}:
Returns a new \code{PairwiseAlignedXStringSet} object made of the selected
elements.

\item[] \code{rep(x, times)}:
Returns a new \code{PairwiseAlignedXStringSet} object made of the repeated
elements.

}
\end{Section}
\begin{Author}\relax
P. Aboyoun
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{pairwiseAlignment}{pairwiseAlignment}},
\code{\LinkA{AlignedXStringSet-class}{AlignedXStringSet.Rdash.class}},
\code{\LinkA{XString-class}{XString.Rdash.class}},
\code{\LinkA{XStringViews-class}{XStringViews.Rdash.class}},
\code{\LinkA{align-utils}{align.Rdash.utils}},
\code{\LinkA{pid}{pid}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  PairwiseAlignedXStringSet("-PA--W-HEAE", "HEAGAWGHE-E")
  pattern <- AAStringSet(c("HLDNLKGTF", "HVDDMPNAL"))
  subject <- AAString("SMDDTEKMSMKL")
  nw1 <- pairwiseAlignment(pattern, subject, substitutionMatrix = "BLOSUM50",
    gapOpening = -3, gapExtension = -1)
  pattern(nw1)
  subject(nw1)
  aligned(nw1)
  as.character(nw1)
  as.matrix(nw1)
  nchar(nw1)
  score(nw1)
  nw1
\end{ExampleCode}
\end{Examples}

