2
|
1 #!/usr/bin/env Rscript
|
|
2
|
|
3 suppressPackageStartupMessages(library("optparse"))
|
|
4
|
|
5 option_list <- list(
|
|
6 make_option(c("-i", "--input"), action="store", dest="input", help="Input .bed.gz file produced by prepMat"),
|
|
7 make_option(c("-o", "--output"), action="store", dest="output", help="Output file"),
|
16
|
8 make_option(c("-w", "--work_dir"), action="store", dest="work_dir", help="Working directory")
|
2
|
9 )
|
|
10
|
|
11 parser <- OptionParser(usage="%prog [options] file", option_list=option_list)
|
|
12 args <- parse_args(parser, positional_arguments=TRUE)
|
|
13 opt <- args$options
|
|
14
|
21
|
15 #data_table <- read.table(opt$input)
|
|
16 #as.matrix(data_table)
|
|
17 #status <- match(data_table[,3], missing)
|
|
18 #data_table[,3] <- paste(opt$work_dir, data_table[,1], ".", data_table[,2], ".bed.gz", sep="")
|
|
19 #data_table <- data_table[is.na(status)==TRUE,]
|
|
20 #write.table(array(data_table, dim=c(length(data_table)/3, 3)), file=opt$output, quote=FALSE, row.names=FALSE, col.names=FALSE)
|
|
21
|
|
22 x=as.matrix(read.table(opt$input))
|
|
23 t=match(x[,3],missing)
|
|
24 x[,3]=paste(opt$work_dir, x[,1],".",x[,2],".bed.gz", sep="")
|
|
25 x=x[is.na(t)==T,]
|
|
26 write.table(array(x,dim=c(length(x)/3,3)), opt$output, quote=F,row.names=F,col.names=F)
|