Skip to content

Instantly share code, notes, and snippets.

@grimbough
Last active October 28, 2017 22:16
Show Gist options
  • Save grimbough/7e7a47b7a4f64915220ce35cc1ce8f39 to your computer and use it in GitHub Desktop.
Save grimbough/7e7a47b7a4f64915220ce35cc1ce8f39 to your computer and use it in GitHub Desktop.
Query BioMart with httr and RCurl
fullXmlQuery <- "<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE Query>
<Query virtualSchemaName = 'default' uniqueRows = '1' count = '0' datasetConfigVersion = '0.6' header='1' requestid= 'biomaRt'>
<Dataset name = 'hsapiens_gene_ensembl'>
<Attribute name = 'ensembl_transcript_id'/>
<Attribute name = 'ensembl_exon_id'/>
<Attribute name = 'rank'/>
<Attribute name = 'genomic_coding_start'/>
<Attribute name = 'cds_start'/>
<Attribute name = '5_utr_start'/>
</Dataset>
</Query>"
rcurl_return <- RCurl::postForm(uri = "http://www.ensembl.org:80/biomart/martservice?",
"query" = fullXmlQuery)
httr_return <- httr::content(httr::POST(url = "http://www.ensembl.org:80/biomart/martservice?",
body = list(query = fullXmlQuery)))
grep('ENST00000485971', rcurl_return)
grep('ENST00000485971', httr_return)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment