Skip to content

Instantly share code, notes, and snippets.

@cmdcolin
Last active June 17, 2016 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmdcolin/4758167bdd89e6c9c055 to your computer and use it in GitHub Desktop.
Save cmdcolin/4758167bdd89e6c9c055 to your computer and use it in GitHub Desktop.
intermine API with R
# 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"
@cmdcolin
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment