<p>I would download the complete geneset FASTA file from <a href="http://www.ensembl.org/info/data/ftp/index.html" rel="nofollow noreferrer">ensembl</a> and then parse out the genes you want with a script.</p>

<p>Alternatively, you could do similarly with API. Get all the gene names, select the ones you want, and then pull down each sequence.</p>

CC BY-SA 3.0
2017-07-13T17:47:10.213Z
2017-07-13T17:47:10.213Z
ithinkiam
<p>I would like to be able to batch download FASTA files from ENSEMBL. I normally would use the API to download them from the ENSEMBL gene IDs. However, the IDs aren't ones I know, only ones I would get from searching on the ENSEMBL website and collecting the IDs manually.</p>

<p>Is there a way I can use the API to query search terms and collect all results that are returned?</p>

<p>So for example, if I use the ENSEMBL website to search "HLA" I could collect the list of IDs (ENSG00000204252 etc. etc.) manually. HLA works okay using the API to query gene IDs because there's only a few terms (A, B, C plus non-classical for class I) but I was wondering if there was a way to directly access the search query one the homepage programmatically, as I may need to do it for some messier examples.</p>

CC BY-SA 3.0
2017-07-13T12:54:38.440Z
Can you give an example of the sort of search you're running? There's lots of things in the API that might do what you want but don't think there's a generic "search" call.
agapow
CC BY-SA 3.0
2017-07-13T13:26:56.710Z
Yes, sorry I didn't think to do that. I want to search a term associated with a gene family, say "HLA" and retrieve ENSEMBL IDs (or the sequences associated with, but I already have some code to do that) of the results that come up from the search.
TW93
CC BY-SA 3.0
2017-07-13T15:24:07.750Z
What kind of terms are you looking for: Diseases terms, protein family names (KRT7,, KRT19, KRT11), ...? Why do you need to do so (maybe we can work around this problem) ?
llrs
CC BY-SA 3.0
2017-07-13T16:33:17.967Z
Please [edit] your question and give us a few example IDs and the output you would like to get from them.
terdon
CC BY-SA 3.0
2017-07-14T10:05:17.513Z
Yes, this is possible but you really need to give us specific examples. You say you query for HLA, OK, but what do you want to getr from it? The FASTA sequence of what? The gene? Primary transcript? All transcripts? Peptide? All peptides? What species? All species? This will almost certainly be possible either directly from the API or, at worst, by processing the HTML but we can't help unless you tell us what you need.
terdon
CC BY-SA 3.0
2017-07-14T10:18:40.547Z
Sorry I've been trying to keep it relatively agnostic. I just need the ENSEMBL gene IDs for the human alleles. The problem is not what happens downstream of that, I just wanted a way of getting IDs of genes and their alleles in one go rather than searching each indivdual gene and getting the gene ID.
TW93
CC BY-SA 3.0
2017-07-17T08:49:43.130Z
Yes, but it's hard to understand what you need without an example. You say you want to download FASTA, but also that you want to retrieve IDs. If you give us an example, we can show you how to do it in a way that is applicable to anything but we need an example to understand exactly what you need.
terdon
<database><reference-genome><ensembl><data-mining>
Is there a way to retrieve ENSEMBL IDs from a search query?
# Is there a way to retrieve ENSEMBL IDs from a search query?

(Asked by: username_0 on 2017-07-13)

I would like to be able to batch download FASTA files from ENSEMBL. I normally would use the API to download them from the ENSEMBL gene IDs. However, the IDs aren't ones I know, only ones I would get from searching on the ENSEMBL website and collecting the IDs manually.

Is there a way I can use the API to query search terms and collect all results that are returned?

So for example, if I use the ENSEMBL website to search "HLA" I could collect the list of IDs (ENSG00000204252 etc. etc.) manually. HLA works okay using the API to query gene IDs because there's only a few terms (A, B, C plus non-classical for class I) but I was wondering if there was a way to directly access the search query one the homepage programmatically, as I may need to do it for some messier examples.

**Tags:** database, reference-genome, ensembl, data-mining
> **Comments:**
> **username_1**: Can you give an example of the sort of search you're running? There's lots of things in the API that might do what you want but don't think there's a generic "search" call.  
> **username_0**: Yes, sorry I didn't think to do that. I want to search a term associated with a gene family, say "HLA" and retrieve ENSEMBL IDs (or the sequences associated with, but I already have some code to do that) of the results that come up from the search.  
> **username_2**: What kind of terms are you looking for: Diseases terms, protein family names (KRT7,, KRT19, KRT11), ...? Why do you need to do so (maybe we can work around this problem) ?  
> **username_3**: Please [edit] your question and give us a few example IDs and the output you would like to get from them.  
> **username_3**: Yes, this is possible but you really need to give us specific examples. You say you query for HLA, OK, but what do you want to getr from it? The FASTA sequence of what? The gene? Primary transcript? All transcripts? Peptide? All peptides? What species? All species? This will almost certainly be possible either directly from the API or, at worst, by processing the HTML but we can't help unless you tell us what you need.  
> **username_0**: Sorry I've been trying to keep it relatively agnostic. I just need the ENSEMBL gene IDs for the human alleles. The problem is not what happens downstream of that, I just wanted a way of getting IDs of genes and their alleles in one go rather than searching each indivdual gene and getting the gene ID.  
> **username_3**: Yes, but it's hard to understand what you need without an example. You say you want to download FASTA, but also that you want to retrieve IDs. If you give us an example, we can show you how to do it in a way that is applicable to anything but we need an example to understand exactly what you need.  

---

## 1 answers

### Answer by username_4 on 2017-07-13. Score: 1

I would download the complete geneset FASTA file from [ensembl](http://www.ensembl.org/info/data/ftp/index.html) and then parse out the genes you want with a script.

Alternatively, you could do similarly with API. Get all the gene names, select the ones you want, and then pull down each sequence.


---

