-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGBQuickSearch.R
37 lines (21 loc) · 879 Bytes
/
GBQuickSearch.R
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
#!/usr/bin/env Rscript
# If you don't plan on using it from the command line, you can import it all as a function from the file GBQuickSearchFunc.R
library("rentrez")
# For testing purposes
# args<-"DQ061874"
args = commandArgs(trailingOnly=TRUE)
r<-entrez_summary(db="nuccore", id=args)
p<-entrez_link(dbfrom="nuccore", id=args, db="all")
pub<-p$links$nuccore_pubmed
if(is.null(pub)){
pub= 'No article found'
} else {
pub=paste('https://www.ncbi.nlm.nih.gov/pubmed/?term=',pub, sep="")
}
gbl<-paste('https://www.ncbi.nlm.nih.gov/nuccore/', args, sep="")
pubm<-entrez_summary(db="pubmed", id=p$links$nuccore_pubmed)
if(is.null(pubm)){
pubm= 'No article found'
}
auth<-do.call(paste,pubm$authors[1])
cat('Title:', r$title, "\n", 'Organism: ', r$organism, "\n", 'PubMed: ', pubm$title, "\n", 'Authors: ', auth, "\n",pub, "\n", 'GenBank: ', gbl, "\n")