-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlncdid
More file actions
executable file
·28 lines (21 loc) · 827 Bytes
/
lncdid
File metadata and controls
executable file
·28 lines (21 loc) · 827 Bytes
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
#!/usr/bin/env Rscript
suppressMessages(library(magrittr))
d <- data.frame(id=commandArgs(trailingOnly=T))
# input into sql approprate string. eg " '11523','10931' "
l_in <-
d$id %>%
gsub("[^0-9A-Za-z]", "", .) %>% # sanatize
gsub("^", "'", .) %>% # add begin quote
gsub("$", "'", .) %>% # add ending quote
unique %>%
paste(collapse=",") # put commas between
query <- sprintf("
select i.id as id, e.id as other, e.etype as etype
from enroll e
join enroll i on e.pid = i.pid
where i.id in (%s)", l_in)
r <- LNCDR::db_query(query)
if(nrow(r) == 0L) stop(paste(collapse=",", d$id) %>% sprintf('#no ids found! %s', .))
f <- merge(r, d, by='id', all=T)
# spit out results
write.table(f, file=stdout(), row.names=F, sep="\t", quote=F)