[ensembl-dev] getting gene exons and transcripts that overlap only the original slice

Andrea Edwards edwardsa at cs.man.ac.uk
Tue Jan 11 21:14:28 GMT 2011


Sorry, missed the last bit off my last message. This was what i did but 
was wondering if there was more efficient way as I have such a lot of data.
I have just given an example for one locus as i'm sure you can imagine 
this code will be looped millions of times

$slice = $slice_adaptor->fetch_by_region( 'chromosome', '9', 21816758,  
21816758 );
$exons = $slice->get_all_Exons;
while (my $exon = shift @{$exons}) {

     my $gene = $gene_adaptor->fetch_by_exon_stable_id($exon->stable_id);
    #process gene
     my $transcripts = $transcript_adaptor->fetch_all_by_exon_stable_id 
($exon->stable_id);

       while (my $transcript = shift @{$transcripts}) {
       #process transcript
     }

}




On 11/01/2011 19:38, Andrea Edwards wrote:
> Hello
>
> i have this code below taken from the core api tutorial which gets me 
> all the exons and transcripts for the gene(s) that overlap a slice.
>
>  I was hoping for an easy way to get those features of the gene that 
> only overlap the original one bp slice; this code gets all exons and 
> transcripts
> associated with the gene
>
> I thought you might be able to call 'get_all_Object' methods with a 
> parameter which represents a region of sequence overlap but it seems not.
> I also thought they might be filtered automatically based on the 
> underlying slice but it seems not.
>
> Naturally i can filter the features in the list based on their start 
> and end positions but for speed it would be easier not to retrieve 
> them all at.
> I have a lot of data so speed is important. Please can you advise the 
> best way to do this.
>
> $slice = $slice_adaptor->fetch_by_region( 'chromosome', '9', 
> 21816758,  21816758 );
>
> my $genes = $slice->get_all_Genes();
> while ( my $gene = shift @{$genes} ) {
>     my $gstring = feature2string($gene);
>     print "$gstring\n";
>
>     my $transcripts = $gene->get_all_Transcripts();
>     while ( my $transcript = shift @{$transcripts} ) {
>         my $tstring = feature2string($transcript);
>         print "\t$tstring\n";
>
>         foreach my $exon ( @{ $transcript->get_all_Exons() } ) {
>             my $estring = feature2string($exon);
>             print "\t\t$estring\n";
>         }
>     }
> }
>
> print "done\n";
>
> Many thanks
>
> _______________________________________________
> Dev mailing list
> Dev at ensembl.org
> http://lists.ensembl.org/mailman/listinfo/dev





More information about the Dev mailing list