# please install package httr
library(httr)
# const values
url <- "http://ophid.utoronto.ca/mirDIP"
mapScore <- list("0", "1", "2", "3");
names(mapScore) <- c("Very High", "High", "Medium", "Low")
unidirectionalSearchOnGenes <- function(geneSymbols, minimumScore) {
parameters <- list(
genesymbol = geneSymbols,
microrna = "",
scoreClass = mapScore[minimumScore]
)
# ... send http POST
res <- POST(paste(url, "/Http_U", sep = ""), body = parameters, encode = "form", verbose())
}
unidirectionalSearchOnMicroRNAs <- function(microRNAs, minimumScore) {
parameters <- list(
genesymbol = "",
microrna = microRNAs,
scoreClass = mapScore[minimumScore]
)
# ... send http POST
res <- POST(paste(url, "/Http_U", sep = ""), body = parameters, encode = "form", verbose())
}
bidirectionalSearch <- function(geneSymbols, microRNAs, minimumScore, sources, occurrances) {
parameters <- list(
genesymbol = geneSymbols,
microrna = microRNAs,
scoreClass = mapScore[minimumScore],
dbOccurrences = occurrances,
sources = sources
)
# ... send http POST
res <- POST(paste(url, "/Http_B", sep = ""), body = parameters, encode = "form", verbose())
}
# make results-map as keyword - value
makeMap <- function(res) {
ENTRY_DEL = "\001"
KEY_DEL = "\002"
response = content(res, "text")
arr = unlist(strsplit(response, ENTRY_DEL, fixed = TRUE))
list_map <- list("")
vec_map_names <- c("");
for (str in arr) {
arrKeyValue = unlist(strsplit(str, KEY_DEL, fixed = TRUE));
if (length(arrKeyValue) > 1) {
list_map[length(list_map) + 1] <- arrKeyValue[2]
vec_map_names[length(vec_map_names) + 1] <- arrKeyValue[1]
}
}
names(list_map) <- vec_map_names
list_map
}
# ... Pick - up right sample for your search
# Note: Adjust 'ophid.utoronto.ca' if you are using our development server.
if (TRUE) { # change to FALSE to comment this sample
####################################################
# Example of Unidirectional search on Gene Symbols #
####################################################
# GeneSymbols
# - Comma delimited.
# - Follow to HUGO approved spelling.
geneSymbols = "AKAP17A,AKR1C2,APP,ZZZ3,MARK4,C17orf51"
# Minimum Score
# - Use one of those:'Very High', 'High', 'Medium', 'Low'.
# - Mind exact spelling.
minimumScore = "Very High";
res <- unidirectionalSearchOnGenes(geneSymbols, minimumScore)
responseCode = status_code(res)
if (responseCode != 200) {
cat("Error: Response Code : ", responseCode, "\r\n")
} else {
list_map <- makeMap(res)
# print results
cat("\r\n", "Unidirectional Search on Gene(s):", "\r\n")
cat("Generated at: ", unlist(list_map["generated_at"]), "\r\n")
cat("Gene Symbols: ", unlist(list_map["gene_symbols"]), "\r\n")
cat("Minimum Score: ", unlist(list_map["minimum_score"]), "\r\n")
cat("\r\n", "Results Size: ", unlist(list_map["results_size"]), "\r\n")
cat("Results: \r\n", unlist(list_map["results"]), "\r\n") # formatted as tab - delimited spreadsheet
}
}
if (TRUE) { # change to FALSE to comment this sample
#################################################
# Example of Unidirectional search on MicroRNAs #
#################################################
# MicroRMAs
# - Comma delimited.
# - Follow the notation as shown.
microRNAs = "hsa-miR-603, hsa-let-7a-3p, hsa-miR-625-5p, hsa-miR-7852-3p, hsa-miR-17-5p"
# Minimum Score
# - Use one of those:'Very High', 'High', 'Medium', 'Low' .
# - Mind exact spelling.
minimumScore = "Very High"
res <- unidirectionalSearchOnMicroRNAs(microRNAs, minimumScore)
responseCode = status_code(res)
if (responseCode != 200) {
cat("Error: Response Code : ", responseCode, "\r\n")
} else {
list_map <- makeMap(res)
# print results
cat("\r\n", "Unidirectional Search on MicroRNA(s):", "\r\n")
cat("Generated at: ", unlist(list_map["generated_at"]), "\r\n")
cat("Micro RNAs: ", unlist(list_map["micro_rnas"]), "\r\n")
cat("Minimum Score: ", unlist(list_map["minimum_score"]), "\r\n")
cat("\r\n", "Results Size: ", unlist(list_map["results_size"]), "\r\n")
cat("Results: \r\n", unlist(list_map["results"]), "\r\n") # formatted as tab - delimited spreadsheet
}
}
if (TRUE) { # change to FALSE to comment this sample
###################################
# Example of Bidirectional search #
###################################
# GeneSymbols
# - Comma delimited.
# - Follow to HUGO approved spelling.
geneSymbols = "AKAP17A,AKR1C2,APP,ZZZ3,MARK4, C17orf51"
# MicroRMAs
# - Comma delimited;
# - Follow the notation as shown.
microRNAs = "hsa-miR-603,hsa-let-7a-3p,hsa-miR-625-5p,hsa-miR-7852-3p,hsa-miR-17-5p,hsa-miR-4321,hsa-miR-758-3p"
# Minimum Score
# - Use one of those:'Very High', 'High', 'Medium', 'Low' .
# - Mind exact spelling.
minimumScore = "Very High"
# Sources
# - Use only combination of those:
# bitargeting_May_2021, BCmicrO, CoMeTa, Cupid, DIANA, miranda_May_2021,
# mirbase, mirCoX, mirmap_May_2021, mirzag, miRcode, miRDB_v6, miRTar2GO,
# MBStar, MirAncesTar, MirSNPInTarget, MirTar2, MiRNATIP, MultiMiTar, PACCMIT,
# PITA_May_2021, rnahybrid_May_2021, RNA22, TargetScan_v7_2
# -Mind exact spelling
sources <- toString(paste(
"bitargeting_May_2021, BCmicrO, CoMeTa, Cupid, DIANA, miranda_May_2021, ",
"mirbase, mirCoX, mirmap_May_2021, mirzag, miRcode, miRDB_v6, miRTar2GO, ",
"MBStar, MirAncesTar, MirSNPInTarget, MirTar2, MiRNATIP, MultiMiTar, PACCMIT, ",
"PITA_May_2021, rnahybrid_May_2021, RNA22, TargetScan_v7_2", collapse = ""))
# Data
# Database Occurrences(named as 'Number of Sources' on 'Bidirectional search' web page):
# - Use this option to select microRNA target predictions that are
# present in at least a given number of sources - irrespective
# of what those sources are.
# - The valid values are:from 1 to 24
occurrances = 2
res <- bidirectionalSearch(geneSymbols, microRNAs, minimumScore, sources, occurrances)
responseCode = status_code(res)
if (responseCode != 200) {
cat("\r\n", "Error: Response Code : ", responseCode, "\r\n")
} else {
list_map <- makeMap(res)
# print results
cat("\r\n", "Bidirectional Search:", "\r\n")
cat("Generated at: ", unlist(list_map["generated_at"]), "\r\n")
cat("Gene Symbols: ", unlist(list_map["gene_symbols"]), "\r\n")
cat("Micro RNAs: ", unlist(list_map["micro_rnas"]), "\r\n")
cat("Minimum Score: ", unlist(list_map["minimum_score"]), "\r\n")
cat("Database Occurrences: ", unlist(list_map["dbOccurrences"]), "\r\n")
cat("Source Filter: ", unlist(list_map["sources"]), "\r\n")
cat("\r\n", "Results Size: ", unlist(list_map["results_size"]), "\r\n")
cat("Results: \r\n", unlist(list_map["results"]), "\r\n") # formatted as tab - delimited spreadsheet
}
}