Commit e274e22a authored by Marek Ostaszewski's avatar Marek Ostaszewski
Browse files

new map

parent f672b03c
...@@ -12,7 +12,7 @@ library(jsonlite) ...@@ -12,7 +12,7 @@ library(jsonlite)
### Utility function using httr:POST to send queries to a given MINERVA Platform instance ### Utility function using httr:POST to send queries to a given MINERVA Platform instance
ask_POST <- function(mnv_base, query, body) { ask_POST <- function(mnv_base, query, body) {
resp <- httr::POST(url = paste0(mnv_base, query), resp <- httr::GET(url = URLencode(paste0(mnv_base, query)),
body = body, body = body,
httr::add_headers('Content-Type' = "application/x-www-form-urlencoded"), httr::add_headers('Content-Type' = "application/x-www-form-urlencoded"),
httr::verbose()) httr::verbose())
...@@ -30,7 +30,7 @@ login <- "username" ...@@ -30,7 +30,7 @@ login <- "username"
password <- "userpassword" password <- "userpassword"
### log in the user ### log in the user
resp <- ask_POST(base, "doLogin", body = paste0("login=",login,"&password=",password)) resp <- ask_POST(base, "doLogin", body = paste0("login=",login,"&password=",URLencode(password, reserved = T)))
### Get the cookie token from the login response; if NULL the loogin was unsuccessfull ### Get the cookie token from the login response; if NULL the loogin was unsuccessfull
token <- fromJSON(resp)$token token <- fromJSON(resp)$token
......
...@@ -22,7 +22,7 @@ ask_GET <- function(mnv_base, query) { ...@@ -22,7 +22,7 @@ ask_GET <- function(mnv_base, query) {
} }
### Base URL of the map, we use Parkinson's disease map ### Base URL of the map, we use Parkinson's disease map
base_url <- "https://pdmap.uni.lu/minerva/api/projects/pd_map_autumn_19/" base_url <- "https://pdmap.uni.lu/minerva/api/projects/pd_map_winter_22/"
### Query for the drug targets, our drug of choice, 'aspirin', ### Query for the drug targets, our drug of choice, 'aspirin',
### is provided directly in the query; this is a one-target example ### is provided directly in the query; this is a one-target example
...@@ -40,7 +40,7 @@ aspirin_map_hgncs <- sapply(aspirin_targets$targets[[1]]$targetParticipants[map_ ...@@ -40,7 +40,7 @@ aspirin_map_hgncs <- sapply(aspirin_targets$targets[[1]]$targetParticipants[map_
### Uniprot identifiers ### Uniprot identifiers
#Define UniProt identifiers to be matched in model elements #Define UniProt identifiers to be matched in model elements
uniprot_examples <- c("Q92793", "P16220") uniprot_examples <- c("P14416", "P07101")
### Request identifiers of models for a given project (main map and submaps) ### Request identifiers of models for a given project (main map and submaps)
models <- ask_GET(base_url, "models/") models <- ask_GET(base_url, "models/")
...@@ -67,4 +67,4 @@ for (m in 1:length(model_elements)) { ...@@ -67,4 +67,4 @@ for (m in 1:length(model_elements)) {
drugs <- sapply(identifiers, drugs <- sapply(identifiers,
function(x) fromJSON(ask_GET(base_url,paste0("drugs:search?target=ALIAS:", x)))$name) function(x) fromJSON(ask_GET(base_url,paste0("drugs:search?target=ALIAS:", x)))$name)
### Display unique results ### Display unique results
unique(drugs) unique(unlist(drugs))
\ No newline at end of file
...@@ -12,6 +12,7 @@ library(jsonlite) ...@@ -12,6 +12,7 @@ library(jsonlite)
### Utility function using httr:GET to send queries to a given MINERVA Platform instance ### Utility function using httr:GET to send queries to a given MINERVA Platform instance
ask_GET <- function(mnv_base, query) { ask_GET <- function(mnv_base, query) {
message("API query: ", paste0(mnv_base, query))
resp <- httr::GET(url = paste0(mnv_base, query), resp <- httr::GET(url = paste0(mnv_base, query),
httr::add_headers('Content-Type' = "application/x-www-form-urlencoded")) httr::add_headers('Content-Type' = "application/x-www-form-urlencoded"))
if(httr::status_code(resp) == 200) { if(httr::status_code(resp) == 200) {
...@@ -21,15 +22,15 @@ ask_GET <- function(mnv_base, query) { ...@@ -21,15 +22,15 @@ ask_GET <- function(mnv_base, query) {
} }
### Base URL of the map, we use Parkinson's disease map ### Base URL of the map, we use Parkinson's disease map
base_url <- "https://pdmap.uni.lu/minerva/api/projects/pd_map_autumn_19/" base_url <- "https://pdmap.uni.lu/minerva/api/projects/pd_map_winter_22/"
### For each model, retrieve elements with columns including references ### For each model, retrieve elements with columns including references
model_elements <- fromJSON(ask_GET(paste0(base_url,"models/*/"), model_elements <- fromJSON(ask_GET(paste0(base_url,"models/*/"),
"bioEntities/elements/?columns=id,name,type,references"), "bioEntities/elements/"),
flatten = F) flatten = F)
#Define UniProt identifiers to be matched in model elements #Define UniProt identifiers to be matched in model elements
uniprot_examples <- c("O43521", "P63167") uniprot_examples <- c("P14416", "P07101")
### For results in each model, find element identifiers that have the selected uniprot id ### For results in each model, find element identifiers that have the selected uniprot id
### then find reactions having at least one of these elements, and append them to the output vector ### then find reactions having at least one of these elements, and append them to the output vector
...@@ -52,7 +53,7 @@ model_reactions <- fromJSON(ask_GET(base_url, ...@@ -52,7 +53,7 @@ model_reactions <- fromJSON(ask_GET(base_url,
visualize_reactions <- "https://pdmap.uni.lu/minerva/?search=" visualize_reactions <- "https://pdmap.uni.lu/minerva/?search="
### Get searchable reaction identifiers from the search results ### Get searchable reaction identifiers from the search results
searchable_identifiers <- paste(paste0("reaction:", reaction_identifiers$reaction_id), collapse = ";") searchable_identifiers <- paste(paste0("reaction:", model_reactions$reactionId), collapse = ";")
### Create the final link ### Create the final link
print(paste0(visualize_reactions, searchable_identifiers)) print(paste0(visualize_reactions, searchable_identifiers))
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