Created
June 21, 2018 14:28
-
-
Save egonw/3b10da2b783c86f9aff8dd3677bf430a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(jsonlite) | |
library("curl") | |
mapUriService = "http://localhost:8081/QueryExpander/mapUri" | |
# gene to variants | |
gene = "http://rdf.ebi.ac.uk/resource/ensembl/ENSG00000198947" | |
targetUriPattern = "http://identifiers.org/dbsnp" | |
h <- new_handle() | |
handle_setopt(h, customrequest = "POST") | |
handle_setform(h, Uri=gene, format = "application/json", targetUriPattern = targetUriPattern) | |
r <- curl_fetch_memory(mapUriService, h) | |
jsonReply = rawToChar(r$content) | |
data = fromJSON(jsonReply) | |
variantCount = length(data$Mapping$targetUri) | |
head(data$Mapping$targetUri) | |
# variants to gene | |
gene = "http://identifiers.org/dbsnp/rs769658853" | |
targetUriPattern = "http://identifiers.org/ensembl" | |
h <- new_handle() | |
handle_setopt(h, customrequest = "POST") | |
handle_setform(h, Uri=gene, format = "application/json", targetUriPattern = targetUriPattern) | |
r <- curl_fetch_memory(mapUriService, h) | |
jsonReply = rawToChar(r$content) | |
data = fromJSON(jsonReply) | |
gene = data$Mapping$targetUri |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment