[ensembl-dev] Gene get_all_Transcripts returns null second time

ian Longden ianl at ebi.ac.uk
Thu Jul 7 10:26:01 BST 2011


This is becouse we pass back a reference to a cache that is used. By
shifting each transcript you
remove the transcripts from the cache hence the second time you call
it the cache is empty.
if you do a foreach instead of the shift @$transcripts} this will
work. Also i think you can reset the cache
manually. $gene_adaptor->clear_cache.

-Ian

On Thu, Jul 7, 2011 at 10:12 AM,  <cj5 at sanger.ac.uk> wrote:
> Hi,
> Could somebody please advise why calling get_all_Transcripts for the same
> gene fails the second time in the following code:
>
> my $gene_id = 'ENSG00000223972';
> my $gene = $gene_adaptor->fetch_by_stable_id($gene_id);
> print "GENE: ". $gene->stable_id ." start ". $gene->start . " end ".
> $gene->end ."\n";
>
> my $transcripts = $gene->get_all_Transcripts();
> print "RETRIEVED TRANSCRIPTS:" . scalar(@{$transcripts})."\n";
> while ( my $tr = shift @{$transcripts} ) {
>    print "TRANSCRIPT:" . $tr->stable_id ." start ". $tr->seq_region_start
> ." end ". $tr->seq_region_end ."\n";
> }
>
> $gene = $gene_adaptor->fetch_by_stable_id($gene_id);
> $transcripts = $gene->get_all_Transcripts();
> print "RETRIEVED TRANSCRIPTS:" . scalar(@{$transcripts})."\n";
> while ( my $tr = shift @{$transcripts} ) {
>    print "TRANSCRIPT:" . $tr->stable_id ." start ". $tr->seq_region_start
> ." end ". $tr->seq_region_end ."\n";
> }
>
> ie output is
> GENE: ENSG00000223972 start 11869 end 14409
> RETRIEVED TRANSCRIPTS:2
> TRANSCRIPT:ENST00000456328 start 11869 end 14409
> TRANSCRIPT:ENST00000450305 start 12010 end 13670
> RETRIEVED TRANSCRIPTS:0
> I'm using ensembl version 62
> Thanks
>
>
>
> --
> Chris Joyce
> Team 136, Medical Sequencing
> Wellcome Trust Sanger Institute
> Tel: 01223 834244 Ext. 6859
>
>
>
>
> _______________________________________________
> Dev mailing list    Dev at ensembl.org
> List admin (including subscribe/unsubscribe): http://lists.ensembl.org/mailman/listinfo/dev
> Ensembl Blog: http://www.ensembl.info/
>




More information about the Dev mailing list