Skip to content

Commit

Permalink
add pubmed search plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Miachol committed Aug 15, 2018
1 parent 926e151 commit 6904fea
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 31 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2018-08-16 Li Jianfeng <[email protected]>

* add pubmed search tool

2018-08-15 Li Jianfeng <[email protected]>

* add datasets2tools plugin
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: BioInstaller
Title: Integrator of Bioinformatics Resources
Version: 0.3.5.3000
Version: 0.3.5.4000
Authors@R: person("Jianfeng", "Li", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-2349-208X"))
Maintainer: Jianfeng Li <[email protected]>
Description:
Expand Down
4 changes: 2 additions & 2 deletions R/web.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#'
#' @examples
#' \dontrun{
#' web()
#' web(auto_create = TRUE)
#' }
web <- function(appDir = system.file("extdata", "shiny", package = "BioInstaller"),
auto_create = FALSE, ...) {
Expand All @@ -34,7 +34,7 @@ check_shiny_dep <- function(install = FALSE) {
pkgs_meta[,2] <- as.character(pkgs_meta[,2])
cran_pkgs <- c("shinycssloaders", "shinydashboard", "configr",
"data.table", "shinyjs", "DT", "stringr", "liteq",
"benchmarkme", "rmarkdown", "markdown")
"benchmarkme", "rmarkdown", "markdown", "rentrez")
cran_lowest_version <- list(configr = "0.3.2", data.table = "1.11.2")
github_pkgs <- c()
github_lowest_version <- list()
Expand Down
5 changes: 5 additions & 0 deletions inst/extdata/config/shiny/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
all: build

build:
cp *.parameters.toml ~/.BioInstaller/plugins/ && \
cp shiny.config.yaml ~/.BioInstaller
30 changes: 15 additions & 15 deletions inst/extdata/config/shiny/shiny.bioinstaller.parameters.toml
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
[bioinstaller.ui.sections]
order = ["input_box", "output_table", "output_text"]
order = ["bioinstaller_input_box", "bioinstaller_output_table", "bioinstaller_output_text"]
[bioinstaller.ui.sections.ui_basic]
input_box = "title = 'Input', status = 'primary', width = 12, collapsed = FALSE, collapsible = TRUE"
output_text = "title = 'Output of bioinstaller', status = 'primary', width = 12, collapsed = FALSE, collapsible = TRUE"
output_table = "title = 'Output of bioinstaller (Table)', status = 'primary', width = 12, collapsed = FALSE, collapsible = TRUE"
bioinstaller_input_box = "title = 'Input', status = 'primary', width = 12, collapsed = FALSE, collapsible = TRUE"
bioinstaller_output_text = "title = 'Output of bioinstaller', status = 'primary', width = 12, collapsed = FALSE, collapsible = TRUE"
bioinstaller_output_table = "title = 'Output of bioinstaller (Table)', status = 'primary', width = 12, collapsed = FALSE, collapsible = TRUE"

[bioinstaller.paramters.input_box]
[bioinstaller.paramters.bioinstaller_input_box]
# For reading annovarR shiny APP bioinstaller tool input files
section_type = "input"
rcmd_last = """
"""
progressbar_message = "Running BioInstaller functions."
render_id = "bioinstaller_input_box"
render_id = "bioinstaller_bioinstaller_input_box"

#!!!!! input_ui_order required related section
input_ui_order = ["single_input", "start_analysis"]

[bioinstaller.paramters.input_box.input.single_input]
[bioinstaller.paramters.bioinstaller_input_box.input.single_input]
title = "Parameters:"
title_control = "class = 'input-section-p'"
varname = ["object_type"]
input_id = ["input_bioinstaller_1"]
type = ["shiny::selectInput"]
label = ["Query type"]

[bioinstaller.paramters.input_box.input.single_input.choices]
[bioinstaller.paramters.bioinstaller_input_box.input.single_input.choices]
object_type = ["github", "nongithub", "db", "all"]

[bioinstaller.paramters.input_box.input.start_analysis]
[bioinstaller.paramters.bioinstaller_input_box.input.start_analysis]
input_id = "start_bioinstaller_analysis"
type = "shiny::actionButton"
label = "Run"

[bioinstaller.paramters.output_text]
[bioinstaller.paramters.bioinstaller_output_text]
section_type = "output"
rcmd_last = "BioInstaller::install.bioinfo(show.all.names = TRUE)[1:10]"
render_type = "shiny::renderPrint"
render_id = "bioinstaller_output_text"
render_id = "bioinstaller_bioinstaller_output_text"
output_type = "shiny::verbatimTextOutput"
progressbar_message = "BioInstaller output_text"
progressbar_message = "BioInstaller bioinstaller_output_text"

[bioinstaller.paramters.output_table]
[bioinstaller.paramters.bioinstaller_output_table]
section_type = "output"
rcmd_last = """
get_dt <- function(item) {
Expand Down Expand Up @@ -77,6 +77,6 @@ if (object_type != "all") {
obj <- cbind(obj, resources_db)
"""
render_type = "DT::renderDataTable"
render_id = "bioinstaller_output_table"
render_id = "bioinstaller_bioinstaller_output_table"
output_type = "DT::dataTableOutput"
progressbar_message = "BioInstaller output_table"
progressbar_message = "BioInstaller bioinstaller_output_table"
12 changes: 10 additions & 2 deletions inst/extdata/config/shiny/shiny.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,24 @@ shiny_queue:
shiny_tools:
pipeline: easy_project
instant:
- maftools
- bioinstaller
- conda
- spack
- datasets2tools
- pubmed
- maftools
shiny_tools_params:
require:
maftools: maftools
bioinstaller: BioInstaller
conda: BioInstaller
spack: BioInstaller
datasets2tools:
- RCurl
- jsonlite
pubmed:
- rentrez
- XML
maftools: maftools
shiny_upload:
upload_dir: ~/.BioInstaller/upload
supported_genome_version:
Expand Down
18 changes: 9 additions & 9 deletions inst/extdata/config/shiny/shiny.datasets2tools.parameters.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[datasets2tools.ui.sections]
order = ["dataset2tools_in", "dataset2tools_out"]
order = ["dataset2tools_input_box", "dataset2tools_out_box"]
[datasets2tools.ui.sections.ui_basic]
dataset2tools_in = "title = 'Datasets2tools API (http://amp.pharm.mssm.edu/datasets2tools/api)', status = 'primary', width = 12, collapsed = FALSE, collapsible = TRUE"
dataset2tools_out = "title = 'Output of Datasets2tools', status = 'primary', width = 12, collapsed = FALSE, collapsible = TRUE"
dataset2tools_input_box = "title = 'Datasets2tools API (http://amp.pharm.mssm.edu/datasets2tools/api)', status = 'primary', width = 12, collapsed = FALSE, collapsible = TRUE"
dataset2tools_out_box = "title = 'Output of Datasets2tools', status = 'primary', width = 12, collapsed = FALSE, collapsible = TRUE"

[datasets2tools.paramters.dataset2tools_in]
[datasets2tools.paramters.dataset2tools_input_box]
# For reading annovarR shiny APP datasets2tools tool input files
section_type = "input"
rcmd_last = """
Expand Down Expand Up @@ -32,7 +32,7 @@ render_id = "datasets2tools_cmds"
#!!!!! input_ui_order required related section
input_ui_order = ["single_input", "start_analysis"]

[datasets2tools.paramters.dataset2tools_in.input.single_input]
[datasets2tools.paramters.dataset2tools_input_box.input.single_input]
title = "Parameters:"
title_control = "class = 'input-section-p'"
varname = ["object_type", "q", "dataset_accession", "tool_name", "disease_name", "canned_analysis_accession", "geneset", "page_size"]
Expand All @@ -44,18 +44,18 @@ type = ["shiny::selectInput", "shiny::textInput", "shiny::textInput", "shiny::te
label = ["Query type", "Key Words", "Dataset Accession (e.g. GSE775)", "Tool name", "Disease name",
"Canned nalysis Cccession", "Geneset", "Page size"]

[datasets2tools.paramters.dataset2tools_in.input.single_input.choices]
[datasets2tools.paramters.dataset2tools_input_box.input.single_input.choices]
object_type = ["canned_analysis", "dataset", "tool"]

[datasets2tools.paramters.dataset2tools_in.input.single_input.value]
[datasets2tools.paramters.dataset2tools_input_box.input.single_input.value]
page_size = 100

[datasets2tools.paramters.dataset2tools_in.input.start_analysis]
[datasets2tools.paramters.dataset2tools_input_box.input.start_analysis]
input_id = "start_datasets2tools_analysis"
type = "shiny::actionButton"
label = "Submit"

[datasets2tools.paramters.dataset2tools_out]
[datasets2tools.paramters.dataset2tools_out_box]
section_type = "output"
rcmd_last = """json_dat"""
render_type = "DT::renderDataTable"
Expand Down
118 changes: 118 additions & 0 deletions inst/extdata/config/shiny/shiny.pubmed.parameters.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
[pubmed.ui.sections]
order = ["pubmed_input_box", "pubmed_output_table"]
[pubmed.ui.sections.ui_basic]
pubmed_input_box = "title = 'Input', status = 'primary', width = 12, collapsed = FALSE, collapsible = TRUE"
pubmed_output_table = "title = 'Output of pubmed (Table)', status = 'primary', width = 12, collapsed = FALSE, collapsible = TRUE"

[pubmed.paramters.pubmed_input_box]
# For reading annovarR shiny APP pubmed tool input files
section_type = "input"
rcmd_last = """
set_entrez_key(pubmed_account_key)
max_n_items <- as.numeric(max_n_items)
objs <- NULL
if (term != "") {
objs <- entrez_search(db = "pubmed", term = term, retmax = 99999, use_history=TRUE)
if (objs$count > 99999 && max_n_items > 99999) {
for( seq_start in seq(99999, objs$count, 99999)){
objs_tmp <- entrez_search(db = "pubmed", term = term,
retstart = seq_start, retmax = 99999)
objs$id <- c(objs$id, objs_tmp$id)
}
}
if (objs$count < max_n_items) max_n_items <- objs$count
}
result <- data.frame()
if (!is.null(objs) && (max_n_items >= 500)){
for(seq_start in seq(1,max_n_items,500)){
if ((max_n_items - seq_start) >= 500) {
fetch.pubmed.tmp <- entrez_fetch(db = "pubmed", web_history = objs$web_history,
rettype = "xml", parsed = T, retstart = seq_start, retmax = 500)
} else {
fetch.pubmed.tmp <- entrez_fetch(db = "pubmed", web_history = objs$web_history,
rettype = "xml", parsed = T, retstart = seq_start, retmax = max_n_items - seq_start + 1)
}
xL <- xmlToList(fetch.pubmed.tmp)
abstracts.tmp = xpathApply(fetch.pubmed.tmp, '//*//Article|//*//BookDocument', function(x)
xmlValue(xmlChildren(x)$Abstract))
title.tmp = xpathApply(fetch.pubmed.tmp, '//*//Article|//*//BookDocument', function(x)
xmlValue(xmlChildren(x)$ArticleTitle))
journal.name.tmp <- xpathApply(fetch.pubmed.tmp, '//*//Article//Journal|//*//BookDocument//Book',
function(x) xmlValue(xmlChildren(x)[["Title"]]))
book.name.tmp <- xpathApply(fetch.pubmed.tmp, '//*//Article//Journal|//*//BookDocument//Book',
function(x) xmlValue(xmlChildren(x)[["BookTitle"]]))
publish.year.tmp <- xpathApply(fetch.pubmed.tmp, '//*//Article//Journal//PubDate|//*//BookDocument//Book//PubDate',
function(x) xmlValue(x))
publish.year.tmp <- unlist(publish.year.tmp)
pmid.tmp <- xpathApply(fetch.pubmed.tmp, '//*/ArticleIdList//ArticleId[@IdType="pubmed"]', function(x) xmlValue(x))
pmid.tmp <- unlist(pmid.tmp)
journal.name.tmp <- unlist(journal.name.tmp)
book.name.tmp <- unlist(book.name.tmp)
abstracts.tmp <- unlist(abstracts.tmp)
abstracts.tmp[is.na(abstracts.tmp)] <- ""
title.tmp <- unlist(title.tmp)
title.tmp[is.na(title.tmp)] <- ""
res <- suppressWarnings(rentrez::parse_pubmed_xml(fetch.pubmed.tmp))
doi.tmp <- unlist(lapply(res, function(x) {if (length(x$doi) == 0) return(NA); x$doi}))
result.tmp <- cbind(pmid.tmp, doi.tmp, title.tmp, abstracts.tmp, publish.year.tmp, journal.name.tmp, book.name.tmp)
result <- rbind(result, result.tmp)
}
result <- result[1:max_n_items,]
} else if (!is.null(objs)) {
fetch.pubmed.tmp <- entrez_fetch(db = "pubmed", web_history = objs$web_history,
rettype = "xml", parsed = T, retmax = max_n_items)
abstracts.tmp = xpathApply(fetch.pubmed.tmp, '//*//Article|//*//BookDocument', function(x)
xmlValue(xmlChildren(x)$Abstract))
title.tmp = xpathApply(fetch.pubmed.tmp, '//*//Article|//*//BookDocument', function(x)
xmlValue(xmlChildren(x)$ArticleTitle))
pmid.tmp <- xpathApply(fetch.pubmed.tmp, '//*/ArticleIdList//ArticleId[@IdType="pubmed"]', function(x) xmlValue(x))
journal.name.tmp <- xpathApply(fetch.pubmed.tmp, '//*//Article//Journal|//*//BookDocument//Book',
function(x) xmlValue(xmlChildren(x)[["Title"]]))
book.name.tmp <- xpathApply(fetch.pubmed.tmp, '//*//Article//Journal|//*//BookDocument//Book',
function(x) xmlValue(xmlChildren(x)[["BookTitle"]]))
publish.year.tmp <- xpathApply(fetch.pubmed.tmp, '//*//Article//Journal//PubDate|//*//BookDocument//Book//PubDate',
function(x) xmlValue(x))
publish.year.tmp <- unlist(publish.year.tmp)
journal.name.tmp <- unlist(journal.name.tmp)
book.name.tmp <- unlist(book.name.tmp)
abstracts.tmp <- unlist(abstracts.tmp)
title.tmp <- unlist(title.tmp)
pmid.tmp <- unlist(pmid.tmp)
res <- suppressWarnings(rentrez::parse_pubmed_xml(fetch.pubmed.tmp))
doi.tmp <- unlist(lapply(res, function(x) {if (length(x$doi) == 0) return(NA); x$doi}))
result <- cbind(pmid.tmp, doi.tmp, title.tmp, abstracts.tmp, publish.year.tmp, journal.name.tmp, book.name.tmp)
}
colnames(result) <- c("PMID", "DOI", "Title", "Abstract", "PublishDate", "JournalName", "BookName")
"""
progressbar_message = "Running pubmed functions."
render_id = "pubmed_pubmed_input_box"

#!!!!! input_ui_order required related section
input_ui_order = ["single_input", "start_analysis"]

[pubmed.paramters.pubmed_input_box.input.single_input]
title = "Parameters:"
title_control = "class = 'input-section-p'"
varname = ["term", "max_n_items", "pubmed_account_key"]
input_id = ["input_pubmed_1", "input_pubmed_2", "input_pubmed_3"]
type = ["shiny::textInput", "shiny::numericInput", "shiny::textInput"]
label = ["Term (e.g. 30105797,30105798,B-ALL)", "Counts", "Pubmed Account Key"]
[pubmed.paramters.pubmed_input_box.input.single_input.value]
max_n_items = 100
pubmed_account_key = "193124979d2e7f360c150dadc5b1e3bfec09"

[pubmed.paramters.pubmed_input_box.input.start_analysis]
input_id = "start_pubmed_analysis"
type = "shiny::actionButton"
label = "Run"

[pubmed.paramters.pubmed_output_table]
section_type = "output"
rcmd_last = """
result
"""
render_type = "DT::renderDataTable"
render_id = "pubmed_output_table"
output_type = "DT::dataTableOutput"
progressbar_message = "PUBMED search ouput"
2 changes: 1 addition & 1 deletion inst/extdata/shiny/server_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ generate_server_object <- function(input, output, ui_server_config, toolname, pk
require(x, character.only = TRUE)
})}
shinyjs::disable(start_trigger)
msg <- sprintf("Running %s analysis steps, waiting please...", toolname)
msg <- sprintf("Running %s task steps, waiting please...", toolname)
for (i in 1:100) {
progress$set(message = msg, value = 1)
Sys.sleep(0.02)
Expand Down
2 changes: 1 addition & 1 deletion man/web.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6904fea

Please sign in to comment.