[ensembl-dev] gene centred info via slices

ian Longden ianlongden at gmail.com
Mon Oct 11 10:56:51 BST 2010


Hi Hardip,

This could be down to memory usage as well as we have all the slices
and all the genes and transcripts and exons etc all  in memory at the
same time.

You may want to try something like:-

  my $slice_adaptor = $registry->get_adaptor($spec, 'Core', 'slice');

  my $slices = $slice_adaptor->fetch_all( 'toplevel', undef,1, 0 )  || [];

  while(my $slice = shift @$slices){

     my @genes =  @{$slice->get_all_Genes(undef, undef, 1, undef, undef)};

     while(my $gene = shift @genes){
        foreach my $transcript (@{$gene->get_all_Transcripts()}) {
           foreach my $exon (@{$transcript->get_all_Exons}){
              # do what ever...
           }
        }
     }
  }

HTH,

-Ian Longden
Ensembl Developer.


On Mon, Oct 11, 2010 at 9:48 AM, Felix Kokocinski <fsk at sanger.ac.uk> wrote:
> Bronwen Aken wrote:
>>
>> Hi Hardip,
>>
>> At a glance your code looks fine. I'm not sure why it is slow. Are you
>> connecting to our MySQL (host ensembldb.ensembl.org
>> <http://ensembldb.ensembl.org> port 5306) or do you have local copies of the
>> databases?
>>
>> If you are only interested in one biotype eg. protein-coding then you
>> could modify your gene-fetch query like:
>> foreach my $gene (@{$slice->get_all_Genes(undef, undef, undef, undef,
>> 'protein_coding')}){
>>
>
> just to add to this: For specific biotypes you could also do:
> $genes = $slice->get_all_Genes_by_type($type);
>
> Actually the "get_all_Genes" method seems to be much slower than before (on
> the human core db) than previously for me as well...
>
>  Best, Felix
>
>
>
>> Cheers,
>> Bronwen
>>
>>
>> On 11 Oct 2010, at 06:06, Hardip Patel wrote:
>>
>>> Dear all
>>>
>>> I am trying to fetch gene centred information using following code. It
>>> takes a long time to extract information for all genes from human or mice at
>>> least.
>>>
>>> I was wondering if the following code could be optimized to get
>>> information faster.
>>>
>>> my $slice_adaptor = $registry->get_adaptor($spec, 'Core', 'slice');
>>>  foreach my $slice (@{$slice_adaptor->fetch_all('toplevel')}){
>>>    foreach my $gene (@{$slice->get_all_Genes}){
>>>      foreach my $transcript (@{$gene->get_all_Transcripts}){
>>>          foreach my $exon (@{$transcript->get_all_Exons}){
>>>            ####get transcript, UTR, exon, and intron start and end in
>>> cDNA coordinates and genomic coordinates
>>>        }
>>>      }
>>>    }
>>> }
>>> ------
>>>
>>> Regards
>>>
>>> --
>>> Hardip R. Patel
>>>
>
> _______________________________________________
> Dev mailing list
> Dev at ensembl.org
> http://lists.ensembl.org/mailman/listinfo/dev
>




More information about the Dev mailing list