This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Unable To Get Exon Coordinates With A Bioperl Ensembl Api

I am unable to get the exon co-ordinates for some of the transcript ids (for example: ENST00000603632, ENST00000604885, ENST00000604930) using perl API program.

part of the code is shown below,

$stable_id='ENST00000603632';
$transcript = $transcript_adaptor->fetch_by_stable_id($stable_id);

But using Ensembl browser, I can browse the same transcript id with all the exon details.

api perl ensembl

Is that because you mis-spelled "stable" in the first line of code? Or is that typo only in this question?

it was the typo error, but it is $stable_id only

try removing the quotes in the first line?

No, it's a string variable in Perl, they are necessary.

I did a little test, looks like you can try adding an argument for the fetch function. It looks like fetch_by_source_stable_id("ENSEMBLPEP",$stable_id);

I am getting the following error

Can't locate object method "fetch_by_source_stable_id" via package "Bio::EnsEMBL::DBSQL::TranscriptAdaptor"

I think I made a mistake here, it should be fetch_by_stable_id instead of fetch_by_source_stable_id, as fetch_by_source_stable_id is not a method for transcript adaptor.

I don't understand what your question is. What exactly is going wrong?

That bit of code looks fine to me. What do you do with $transcript next?

I am trying to get all the exon features from that $transcript

for example :

foreach my $exon ( @{ $transcript->get_all_Exons( ) } ) 
{
            my $estring = feature2string($exon);
            print "\t\t$estring\n"; 
}

but I am getting the following error :

Can't call method "get_all_Exons" on an undefined value

This is because when I am printing the variable $transcript with this id "ENST00000603632" it was empty but with other id's e.g. "ENST00000441232" the $transcript variable contains hash value "Bio::EnsEMBL::Transcript=HASH(0x7fdd1b757bf8)"

I've just tried a simple script with that transcript and it seems to work fine:

#!/usr/bin/perl
use strict;
use warnings;
use Bio::EnsEMBL::Registry;

my $reg = "Bio::EnsEMBL::Registry";

$reg->load_registry_from_db(
   -host => 'ensembldb.ensembl.org',
   -user => 'anonymous'
);

my $transcript_adaptor = $reg->get_adaptor ('human', 'core', 'transcript');

my $stable_id='ENST00000603632';
my $transcript = $transcript_adaptor->fetch_by_stable_id($stable_id);

foreach my $exon ( @{ $transcript->get_all_Exons( ) } ) {
    print
        $exon->stable_id, "\t",
        $exon->seq_region_name, "\t",
        $exon->start, "\t",
        $exon->end, "\n";
    }

gives:

ENSE00003627650    HG1592_PATCH    106237449    106237742
ENSE00003551731    HG1592_PATCH    106237006    106237056
ENSE00003532911    HG1592_PATCH    106236818    106236862
ENSE00003612253    HG1592_PATCH    106236630    106236674
ENSE00003580644    HG1592_PATCH    106236442    106236486
ENSE00003615633    HG1592_PATCH    106235994    106236323
ENSE00003466309    HG1592_PATCH    106235439    106235896

Which version of the API are you using? If you're using the latest version (72), it should work fine. If it's an older version you won't get any data, as this transcript is new in version 72.

I am currently using API version 69. I have now updated the Ensembl API version from 69 to 72.

It’s working for all the transcript ids,

Thank you very much for the support.

Also, you're more likely to get answers more quickly if you add the name of the tool you're using as a tag. I have a bunch of favourite tags set up and only occasionally skim through the stuff that isn't tagged with my favourite stuff. If you'd have tagged this with "Ensembl" when you posted it, I would have replied yesterday.

0 answers

No answers yet.

Log in to answer this question.