Skip to content

Instantly share code, notes, and snippets.

@jokergoo
Last active August 29, 2015 13:55
Show Gist options
  • Save jokergoo/8789282 to your computer and use it in GitHub Desktop.
Save jokergoo/8789282 to your computer and use it in GitHub Desktop.
bedtools = function(cmd, envir = parent.frame()) {
gr = gsub("^.*@\\{(.*?)\\}.*$", "\\1", cmd)
gr = get(gr, envir = envir)
file = tempfile(fileext = ".bed")
write.table(gr, file = file, sep = "\t", quote = FALSE, row.names = FALSE, col.names = FALSE)
cmd = gsub("@\\{.*?\\}", file, cmd)
try(tb <- read.table(pipe(cmd), stringsAsFactors = FALSE))
file.remove(file)
return(tb)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment