This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Retrieving only ENST ids linked to an ENSG ids using the Ensembl REST API

Hi,

Let's say that I want to programmatically retrieve in json format the 4 Ensembl transcripts IDs that are linked to the Ensembl gene ENSG00000133703 (KRAS) that are listed on the following webpage :

http://www.ensembl.org/Homo_sapiens/Gene/Summary?db=core;g=ENSG00000133703;r=12:25357723-25403870

I did give it a try with the following link that gave me extra 9 transcripts that I was not expecting :

http://beta.rest.ensembl.org/feature/id/ENSG00000133703?feature=transcript;content-type=application/json

Does any one know what is the link that returned only the expectes 4 transcripts listed in the first link.

Thanks for your help.

Fred

ensembl api rest

1 answer

The feature/id command in the Beta version of the REST API retrieves all features that overlap the ID that you've put in, not just transcripts of that gene. If we look at the region of the gene, we can see that it overlaps five other transcripts (two genes) on the opposite strand. The feature/id command has been renamed the overlap/id command in the newer full release of the REST API.

At present, I'm afraid there is no command in the REST API to get all transcripts of a gene. You'll have to use the Perl API instead to get this kind of data. It would be something like:

use strict;
use warnings;
 
use Bio::EnsEMBL::Registry;
use Bio::EnsEMBL::SeqFeature;
my $reg = "Bio::EnsEMBL::Registry";
 
$reg->load_registry_from_db(
   -host => 'ensembldb.ensembl.org',
   -user => 'anonymous'
);

my $gene_adaptor = $reg->get_adaptor ('human', 'core', 'gene');
my $gene = $gene_adaptor->fetch_by_stable_id( 'ENSG00000133703' );
my @transcripts = @{ $gene->get_all_Transcripts };
while (my $transcript = shift @transcripts) {
# print some stuff
}

Thanks for this nice workaround. Even if it would be nicer to have a lighter way to have these transcripts IDs.

Thanks for you answers. That's a pity that this simple feature is not available through the REST API. Do you know if improvement are planned concerning the REST API.

I can feed this back to the developers and see what happens.

Log in to answer this question.