**40**wrote:

Hi,

I would like to count the number of disjoint matches for a given pattern and character vector where matches are sought. So, basically what gregexpr is doing. However I would like to do this for a set of patterns as well as a set of characters (such as XStringSet).

Right now I just apply gregexpr multiple times. Is there a more clever way to do this? I know about vcountPDict. However, I would like to count number of disjoint occurrences rather than total number of occurrences.

Any comment on this?

Toy example

library(Biostrings) data(yeastSEQCHR1) yeast1 <- DNAString(yeastSEQCHR1) x = Views(yeast1, start = sample(length(yeast1),20), width=20) # returns number of disjoint matches for a given pattern gregexpr("AAA",x) # vectorized way to get the number of matches for each motif in the dictionary vcountPDict(DNAStringSet(c("AAA","TTT")), x)

Best,

Stefanie

**13k**• written 2.7 years ago by Stefanie Tauber •

**40**