\HeaderA{matchProbePair}{Find "theoretical amplicons" mapped to a probe pair}{matchProbePair}
\aliasA{matchProbePair,DNAString-method}{matchProbePair}{matchProbePair,DNAString.Rdash.method}
\aliasA{matchProbePair,MaskedDNAString-method}{matchProbePair}{matchProbePair,MaskedDNAString.Rdash.method}
\aliasA{matchProbePair,XStringViews-method}{matchProbePair}{matchProbePair,XStringViews.Rdash.method}
\keyword{methods}{matchProbePair}
\begin{Description}\relax
In the context of a computer-simulated PCR experiment, one wants to find
the amplicons mapped to a given primer pair.
The \code{matchProbePair} function can be used for this: given a forward and a
reverse probe (i.e. the chromosome-specific sequences of the forward and
reverse primers used for the experiment) and a target sequence (generally a
chromosome sequence), the \code{matchProbePair} function will return all
the "theoretical amplicons" mapped to this probe pair.
\end{Description}
\begin{Usage}
\begin{verbatim}
  matchProbePair(Fprobe, Rprobe, subject, algorithm="auto", logfile=NULL, verbose=FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{Fprobe}] The forward probe.

\item[\code{Rprobe}] The reverse probe.

\item[\code{subject}] A \code{\LinkA{DNAString}{DNAString}} object (or an \code{\LinkA{XStringViews}{XStringViews}} object
with a \code{\LinkA{DNAString}{DNAString}} subject) containing the target sequence.

\item[\code{algorithm}] One of the following: \code{"auto"}, \code{"naive-exact"},
\code{"naive-inexact"}, \code{"boyer-moore"} or \code{"shift-or"}.
See \code{\LinkA{matchPattern}{matchPattern}} for more information.

\item[\code{logfile}] A file used for logging.

\item[\code{verbose}] \code{TRUE} or \code{FALSE}.

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The \code{matchProbePair} function does the following: (1) find all
the "plus hits" i.e. the Fprobe and Rprobe matches on the "plus" strand,
(2) find all the "minus hits" i.e. the Fprobe and Rprobe matches on the
"minus" strand and (3) from the set of all (plus\_hit, minus\_hit) pairs,
extract and return the subset of "reduced matches" i.e. the (plus\_hit, minus\_hit)
pairs such that (a) plus\_hit <= minus\_hit and (b) there are no hits (plus
or minus) between plus\_hit and minus\_hit.
This set of "reduced matches" is the set of "theoretical amplicons".
\end{Details}
\begin{Value}
An \LinkA{XStringViews}{XStringViews} object containing the set of "theoretical amplicons".
\end{Value}
\begin{Author}\relax
H. Pages
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{matchPattern}{matchPattern}},
\code{\LinkA{matchLRPatterns}{matchLRPatterns}},
\code{\LinkA{findPalindromes}{findPalindromes}},
\code{\LinkA{reverseComplement}{reverseComplement}},
\code{\LinkA{XStringViews}{XStringViews}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  library(BSgenome.Dmelanogaster.UCSC.dm3)
  subject <- Dmelanogaster$chr3R

  ## With 20-nucleotide forward and reverse probes:
  Fprobe <- "AGCTCCGAGTTCCTGCAATA"
  Rprobe <- "CGTTGTTCACAAATATGCGG"
  matchProbePair(Fprobe, Rprobe, subject) # 1 "theoretical amplicon"

  ## With shorter forward and reverse probes, the risk of having multiple
  ## "theoretical amplicons" increases:
  Fprobe <- "AGCTCCGAGTTCC"
  Rprobe <- "CGTTGTTCACAA"
  matchProbePair(Fprobe, Rprobe, subject) # 2 "theoretical amplicons"
  Fprobe <- "AGCTCCGAGTT"
  Rprobe <- "CGTTGTTCACA"
  matchProbePair(Fprobe, Rprobe, subject) # 9 "theoretical amplicons"
\end{ExampleCode}
\end{Examples}

