Guest User

Untitled

a guest
Oct 15th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. library(plyr)
  2. library(Rsamtools)
  3. library(GenomicRanges)
  4. library(Biostrings)
  5. library(knitr)
  6.  
  7. matcher <- function(pattern, x) {
  8. ind = gregexpr(pattern, x)[[1]]
  9. start = as.numeric(ind)
  10. end = start + attr(ind, "match.length")- 2
  11. apply(cbind(start,end), 1, function(y) substr(x, start=y[1], stop=y[2]));
  12. }
  13. doone <- function(c, cigar) {
  14. pat <- paste("\\d+", c , sep="")
  15. sum(as.numeric(matcher(pat, cigar)), na.rm=T)
  16. }
Add Comment
Please, Sign In to add comment