Commit 8ad134cb authored by liiskolb's avatar liiskolb

get_version_info

parent 7f83f443
Package: gprofiler2 Package: gprofiler2
Type: Package Type: Package
Title: Interface to the 'g:Profiler' Toolset Title: Interface to the 'g:Profiler' Toolset
Version: 0.2.0 Version: 0.2.1
Author: Liis Kolberg <liis.kolberg@ut.ee>, Uku Raudvere <uku.raudvere@ut.ee> Author: Liis Kolberg <liis.kolberg@ut.ee>, Uku Raudvere <uku.raudvere@ut.ee>
Maintainer: Liis Kolberg <liis.kolberg@ut.ee> Maintainer: Liis Kolberg <liis.kolberg@ut.ee>
Description: A toolset for functional enrichment analysis and visualization, gene/protein/SNP identifier conversion and mapping orthologous genes across species via 'g:Profiler' (<https://biit.cs.ut.ee/gprofiler>). Description: A toolset for functional enrichment analysis and visualization, gene/protein/SNP identifier conversion and mapping orthologous genes across species via 'g:Profiler' (<https://biit.cs.ut.ee/gprofiler>).
......
...@@ -4,6 +4,7 @@ export(gconvert) ...@@ -4,6 +4,7 @@ export(gconvert)
export(get_base_url) export(get_base_url)
export(get_tls_version) export(get_tls_version)
export(get_user_agent) export(get_user_agent)
export(get_version_info)
export(gorth) export(gorth)
export(gost) export(gost)
export(gostplot) export(gostplot)
......
...@@ -214,7 +214,7 @@ gost <- function(query, ...@@ -214,7 +214,7 @@ gost <- function(query,
"Content-Type" = "application/json", "Content-Type" = "application/json",
"charset" = "UTF-8", "charset" = "UTF-8",
"Expect" = "") "Expect" = "")
oldw <- getOption("warn") oldw <- getOption("warn")
options(warn = -1) options(warn = -1)
h1 = RCurl::basicTextGatherer(.mapUnicode = FALSE) h1 = RCurl::basicTextGatherer(.mapUnicode = FALSE)
h2 = RCurl::getCurlHandle() # Get info about the request h2 = RCurl::getCurlHandle() # Get info about the request
...@@ -1473,3 +1473,59 @@ set_base_url = function(url) { ...@@ -1473,3 +1473,59 @@ set_base_url = function(url) {
assign("base_url", url, envir = gp_globals) assign("base_url", url, envir = gp_globals)
} }
#' Get version info of g:Profiler data sources
#'
#' @param organism organism name. Organism names are constructed by concatenating the first letter of the name and the family name. Example: human - 'hsapiens', mouse - 'mmusculus'.
#' @return A named nested list that includes the versions for all the data sources (GO, KEGG, Reactome, WP, etc) at the time of the data extraction for the given organism.
#' The versions correspond to the g:Profiler version embedded in the base_url which is also returned by this function under the name 'gprofiler_version'.
#' @author Liis Kolberg <liis.kolberg@@ut.ee>
#' @examples
#' \dontrun{version_info <- get_version_info(organism = "hsapiens")}
#'
#' @export
get_version_info <- function(organism = "hsapiens"){
url = file.path(gprofiler2::get_base_url(), "api", "util", "data_versions")
body <- jsonlite::toJSON((
list(
organism = jsonlite::unbox(organism)
)
),
auto_unbox = FALSE,
null = "null")
# Headers
headers <-
list("Accept" = "application/json",
"Content-Type" = "application/json",
"charset" = "UTF-8",
"Expect" = "")
oldw <- getOption("warn")
options(warn = -1)
h1 = RCurl::basicTextGatherer(.mapUnicode = FALSE)
h2 = RCurl::getCurlHandle() # Get info about the request
# Request
r = RCurl::curlPerform(
url = url,
postfields = body,
httpheader = headers,
customrequest = 'POST',
verbose = FALSE,
ssl.verifypeer = FALSE,
writefunction = h1$update,
curl = h2,
.opts = gp_globals$rcurl_opts
)
options(warn = 0)
rescode = RCurl::getCurlInfo(h2)[["response.code"]]
txt <- h1$value()
if (rescode != 200) {
stop("Bad request, response code ", rescode)
}
version_info <- jsonlite::fromJSON(txt)
return(version_info)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment