Mercurial > repos > artbio > ngsplot
annotate bin/remove.db.tables.r @ 0:3ca58369469c draft
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
author | artbio |
---|---|
date | Wed, 06 Dec 2017 19:01:53 -0500 |
parents | |
children |
rev | line source |
---|---|
0
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
1 #!/usr/bin/env Rscript |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
2 # Remove the genome entries from two ngs.plot system files: |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
3 # default.tbl and dbfile.tbl. |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
4 |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
5 args <- commandArgs(T) |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
6 if(length(args)>1){ |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
7 gname.to.rm <- args[1] |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
8 feature.to.rm <- args[2] |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
9 }else{ |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
10 gname.to.rm <- args[1] |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
11 } |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
12 |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
13 # Save to text output. |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
14 progpath <- Sys.getenv('NGSPLOT') |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
15 if(progpath == "") { |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
16 stop("Set environment variable NGSPLOT before run the program. See README for details.\n") |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
17 } |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
18 default.file <- file.path(progpath, 'database', 'default.tbl') |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
19 dbfile.file <- file.path(progpath, 'database', 'dbfile.tbl') |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
20 default.tbl <- read.delim(default.file) |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
21 dbfile.tbl <- read.delim(dbfile.file) |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
22 |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
23 if(exists("feature.to.rm")){ |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
24 default.tbl <- subset(default.tbl, !(Genome==gname.to.rm & Region==feature.to.rm)) |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
25 dbfile.tbl <- subset(dbfile.tbl, !(Genome==gname.to.rm & Region==feature.to.rm)) |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
26 }else{ |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
27 default.tbl <- default.tbl[default.tbl$Genome != gname.to.rm, ] |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
28 dbfile.tbl <- dbfile.tbl[dbfile.tbl$Genome != gname.to.rm, ] |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
29 } |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
30 |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
31 |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
32 write.table(default.tbl, file=default.file, row.names=F, sep="\t", quote=F) |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
33 write.table(dbfile.tbl, file=dbfile.file, row.names=F, sep="\t", quote=F) |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
34 |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
35 |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
36 # getScore <- function(i, db.fi, default.fi){ |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
37 # score <- 3 - length(intersect(as.matrix(default.fi[db.fi[i, "tag"], ]), as.matrix(db.fi[i, ]))) |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
38 # return(score) |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
39 # } |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
40 |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
41 # for (i in (1:dim(db.fi)[1])){ |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
42 # anno.db.tbl[i, "dbScore"] <- getScore(i, db.fi, default.fi) |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
43 # } |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
44 |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
45 # anno.version="0.01" |
3ca58369469c
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/ngsplot commit b'e9fcc157a7f2f2fa9d6ac9a58d425ff17c975f5c\n'
artbio
parents:
diff
changeset
|
46 # save(anno.tbl, anno.db.tbl, anno.version, file="database.RData") |