1 |
vcf.file |
|
n |
|
directory |
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (vcf.file, n = 1e+05, directory = NULL)
{
write.file = function(f, file.list = c()) {
tmpdir = paste(directory, "/", "part", floor(length(file.list)/100),
sep = "")
if (!file.exists(tmpdir))
dir.create(tmpdir)
lines = scanTabix(f)[[1]]
if (length(lines) > 0) {
output.file = paste(tempfile(tmpdir = tmpdir), ".vcf.gz",
sep = "")
o = pipe(paste("bgzip -c >", output.file, sep = ""),
open = "w")
writeLines(header, o)
writeLines(lines, o)
close(o)
write.file(f, file.list = c(file.list, output.file))
}
else file.list
}
index.file = function(filename) {
system(paste("tabix", filename))
filename
}
if (!file.exists(paste(vcf.file, "tbi", sep = "")))
index.file(vcf.file)
directory = if (is.null(directory))
gsub(".vcf.gz$", "", vcf.file)
else directory
if (!file.exists(directory))
dir.create(directory)
header = headerTabix(vcf.file)$header
f = TabixFile(vcf.file, yieldSize = n)
open(f)
files = write.file(f)
close(f)
sapply(files, index.file)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.