# Trim Flanking Patterns from Sequences

### Description

The `trimLRPatterns`

function trims left and/or right flanking patterns
from sequences.

### Usage

1 2 3 4 |

### Arguments

`Lpattern` |
The left pattern. |

`Rpattern` |
The right pattern. |

`subject` |
An XString object, XStringSet object, or character vector containing the target sequence(s). |

`max.Lmismatch` |
Either an integer vector of length When Otherwise, Once the integer vector is constructed using the rules given above, when
For a given element |

`max.Rmismatch` |
Same as For a given element |

`with.Lindels` |
If |

`with.Rindels` |
Same as |

`Lfixed, Rfixed` |
Whether IUPAC extended letters in the left or right pattern should
be interpreted as ambiguities (see |

`ranges` |
If |

### Value

A new XString object, XStringSet object, or character vector with the "longest" flanking matches removed, as described above.

### Author(s)

P. Aboyoun and H. Jaffee

### See Also

`matchPattern`

,
`matchLRPatterns`

,
lowlevel-matching,
XString-class,
XStringSet-class

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ```
Lpattern <- "TTCTGCTTG"
Rpattern <- "GATCGGAAG"
subject <- DNAString("TTCTGCTTGACGTGATCGGA")
subjectSet <- DNAStringSet(c("TGCTTGACGGCAGATCGG", "TTCTGCTTGGATCGGAAG"))
## Only allow for perfect matches on the flanks
trimLRPatterns(Lpattern = Lpattern, subject = subject)
trimLRPatterns(Rpattern = Rpattern, subject = subject)
trimLRPatterns(Lpattern = Lpattern, Rpattern = Rpattern, subject = subjectSet)
## Allow for perfect matches on the flanking overlaps
trimLRPatterns(Lpattern = Lpattern, Rpattern = Rpattern, subject = subjectSet,
max.Lmismatch = 0, max.Rmismatch = 0)
## Allow for mismatches on the flanks
trimLRPatterns(Lpattern = Lpattern, Rpattern = Rpattern, subject = subject,
max.Lmismatch = 0.2, max.Rmismatch = 0.2)
maxMismatches <- as.integer(0.2 * 1:9)
maxMismatches
trimLRPatterns(Lpattern = Lpattern, Rpattern = Rpattern, subject = subjectSet,
max.Lmismatch = maxMismatches, max.Rmismatch = maxMismatches)
## Produce ranges that can be an input into other functions
trimLRPatterns(Lpattern = Lpattern, Rpattern = Rpattern, subject = subjectSet,
max.Lmismatch = 0, max.Rmismatch = 0, ranges = TRUE)
trimLRPatterns(Lpattern = Lpattern, Rpattern = Rpattern, subject = subject,
max.Lmismatch = 0.2, max.Rmismatch = 0.2, ranges = TRUE)
``` |