Last active
June 17, 2016 23:33
-
-
Save cmdcolin/4758167bdd89e6c9c055 to your computer and use it in GitHub Desktop.
intermine API with R
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
# intermine gives you code for downloading search results in many languages including Perl,Python,Java,and even Javascript | |
# by default, no R code is given, but it does provide a XML query string which can be easily be downloaded with RCurl or httr | |
library(httr) | |
library(jsonlite) | |
query='<query model="genomic" view="Gene.chromosome.primaryIdentifier Gene.exons.chromosomeLocation.start Gene.exons.chromosomeLocation.end" ><constraint path="Gene.symbol" op="=" value="eve" /><constraint path="Gene.organism" op="LOOKUP" value="D. melanogaster" /></query>' | |
ret=POST('http://www.flymine.org/flymine/service/query/results', | |
body=list(query=query, format='json'), | |
encode='form') | |
response=fromJSON(content(ret,as='text')) | |
if(response$wasSuccessful) { | |
print(response$results) | |
} | |
# Output is a data frame | |
# [,1] [,2] [,3] | |
#[1,] "2R" "5866824" "5867058" | |
#[2,] "2R" "5867130" "5868300" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See InterMineR also https://github.com/intermine/intermineR