<p>I&#39;ve got a list of rs SNPs I&#39;d like to enter into the David functional annotation tool. Since it does not support rsids I need to get the refseq gene id (or something similar) of the genes these SNPs overlap with first.</p>

<p>Is there a simple way of getting a gene ID for a SNP? Solution in BioPython or R is fine.</p>

<p>Since I have 22k snps I need an automatic way. And if a text file that maps these values exist, a link to it would be enough.</p>

<p>Ps. preferably looking for a solution that does not use the position of the SNPs; I would be able to solve the problem this way myself.</p>

It looks like DAVID can convert from Ensembl Gene IDs, so you can get to those from rs IDs using [R/biomaRt][1], like this:

```
library(biomaRt)
mart.snp <- useMart("snp", "hsapiens_snp")

getENSG <- function(rs = "rs3043732", mart = mart.snp) {
  results <- getBM(attributes = c("refsnp_id", "ensembl_gene_stable_id"),
                   filters    = "snp_filter", values = rs, mart = mart)
  return(results)
}

# default parameters
getENSG()
  refsnp_id ensembl_gene_stable_id
1 rs3043732        ENSG00000175445

# or supply rs ID
getENSG(rs = "rs224550")
  refsnp_id ensembl_gene_stable_id
1  rs224550        ENSG00000262304
2  rs224550        ENSG00000196689
```

 [1]: http://www.bioconductor.org/packages/release/bioc/html/biomaRt.html