The matchLRPatterns
function finds paired matches in a sequence
i.e. matches specified by a left pattern, a right pattern and a maximum
distance between the left pattern and the right pattern.
1 2 3 4  matchLRPatterns(Lpattern, Rpattern, max.gaplength, subject,
max.Lmismatch=0, max.Rmismatch=0,
with.Lindels=FALSE, with.Rindels=FALSE,
Lfixed=TRUE, Rfixed=TRUE)

Lpattern 
The left part of the pattern. 
Rpattern 
The right part of the pattern. 
max.gaplength 
The max length of the gap in the middle i.e the max distance between the left and right parts of the pattern. 
subject 
An XString, XStringViews or MaskedXString object containing the target sequence. 
max.Lmismatch 
The maximum number of mismatching letters allowed in the left part of the
pattern.
If nonzero, an inexact matching algorithm is used (see the

max.Rmismatch 
Same as 
with.Lindels 
If See the 
with.Rindels 
Same as 
Lfixed 
Only with a DNAString or RNAString subject can a
With

Rfixed 
Same as 
An XStringViews object containing all the matches, even when they are overlapping (see the examples below), and where the matches are ordered from left to right (i.e. by ascending starting position).
H. Pagès
matchPattern
,
matchProbePair
,
trimLRPatterns
,
findPalindromes
,
reverseComplement
,
XStringclass,
XStringViewsclass,
MaskedXStringclass
1 2 3 4 5 6 7 8 9 10 11 12 13  library(BSgenome.Dmelanogaster.UCSC.dm3)
subject < Dmelanogaster$chr3R
Lpattern < "AGCTCCGAG"
Rpattern < "TTGTTCACA"
matchLRPatterns(Lpattern, Rpattern, 500, subject) # 1 match
## Note that matchLRPatterns() will return all matches, even when they are
## overlapping:
subject < DNAString("AAATTAACCCTT")
matchLRPatterns("AA", "TT", 0, subject) # 1 match
matchLRPatterns("AA", "TT", 1, subject) # 2 matches
matchLRPatterns("AA", "TT", 3, subject) # 3 matches
matchLRPatterns("AA", "TT", 7, subject) # 4 matches

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.