Remove left and right full and partial patterns — cutRseq • FastqCleaner
Description: This set of programs are internal, and the function adapter_filter is recommended for trimming. The programs can remove adapters and partial adapters from 3' and 5'. The adapters can be anchored or not. When indels are allowed, the error rate consists in the edit distance. IUPAC simbols are allowed. The methods use the trimLRpatterns function of the Biostrings package, with some additions to take into account e.g., partial adaptors. IUPAC symbols are allowed in all the cases. The present function also removes partial adapters, without the need of additional steps (for example, creating a padded adapter with 'Ns', etc). A similar result to the output of trimLRPatterns can be obtained with the option anchored = TRUE. When several matches are found, the function removes the subsequence that starts in the first match when cutRseq is used, or ends in the last match when cutLseq is used.

# Remove left and right full and partial patterns

`matching.Rd`

This set of programs are internal, and the function adapter_filter is recommended for trimming. The programs can remove adapters and partial adapters from 3' and 5'. The adapters can be anchored or not. When indels are allowed, the error rate consists in the edit distance. IUPAC simbols are allowed. The methods use the `trimLRpatterns` function of the Biostrings package, with some additions to take into account e.g., partial adaptors. IUPAC symbols are allowed in all the cases. The present function also removes partial adapters, without the need of additional steps (for example, creating a padded adapter with 'Ns', etc). A similar result to the output of `trimLRPatterns` can be obtained with the option anchored = TRUE. When several matches are found, the function removes the subsequence that starts in the first match when cutRseq is used, or ends in the last match when cutLseq is used.

    cutRseq(subject, Rpattern, with.indels = FALSE, fixed = "subject",
      error_rate = 0.2, anchored = TRUE, ranges = FALSE, checks = TRUE,
      min_match_flank = 2L, ...)

    cutLseq(subject, Lpattern, with.indels = FALSE, fixed = "subject",
      error_rate = 0.2, anchored = TRUE, ranges = FALSE,
      min_match_flank = 3L, checks = TRUE, ...)

## Arguments

subject | `DNAString` or `DNAStringSet` object
Rpattern | 3' pattern, `DNAString` object
with.indels | Allow indels?
fixed | Parameter passed to `trimLRpatterns` Default 'subject', ambiguities in the pattern only are interpreted as wildcard. See the argument fixed in `trimLRpatterns`
error_rate | Error rate (value in [0, 1]). The error rate is the proportion of mismatches allowed between the adapter and the aligned portion of the subject. For a given adapter A, the number of allowed mismatches between each subsequence s of A and the subject is computed as: error_rate * L_s, where L_s is the length of the subsequence s.
anchored | Can the adapter or partial adapter be within the sequence? (anchored = FALSE) or only in the terminal regions of the sequence? (anchored = TRUE). Default TRUE (trim only flanking regions)
ranges | Return ranges? Default FALSE
checks | Perform internal checks? Default TRUE
min_match_flank | Do not trim in flanks of the subject, if a match has min_match_flank of less length. Default 1L (only trim with >=2 coincidences in a flank match)
... | additional parameters passed to `trimLRpatterns]`
Lpattern | 5' pattern, `DNAString` object

## Value

Edited `DNAString` or `DNAStringSet` object

## Examples

    library(Biostrings)

    subject <- DNAStringSet(c('ATCATGCCATCATGAT',
    'CATGATATTA', 'TCATG', 'AAAAAA', 'AGGTCATG'))

    Lpattern <- Rpattern <- 'TCATG'

    cutLseq(subject, Lpattern)#> Error in cutLseq(subject, Lpattern): could not find function "cutLseq"cutLseq(subject, Lpattern, ranges = TRUE)#> Error in cutLseq(subject, Lpattern, ranges = TRUE): could not find function "cutLseq"cutRseq(subject, Rpattern)#> Error in cutRseq(subject, Rpattern): could not find function "cutRseq"

    cutLseq(subject, Lpattern, anchored = FALSE)#> Error in cutLseq(subject, Lpattern, anchored = FALSE): could not find function "cutLseq"cutLseq(subject, Lpattern,  error_rate = 0.2)#> Error in cutLseq(subject, Lpattern, error_rate = 0.2): could not find function "cutLseq"cutLseq(subject, Lpattern,  error_rate = 0.2,
    with.indels = TRUE)#> Error in cutLseq(subject, Lpattern, error_rate = 0.2, with.indels = TRUE): could not find function "cutLseq"