[ensembl-dev] error in getting EntrezGene IDs from Ensembl $gene

th3 th3 at sanger.ac.uk
Thu Aug 30 11:50:42 BST 2012


Hi Jerry,

We only get external reference (xref) like the EntrezGene ID for the 
core databases.
So for every gene from the rnaseq database you need to get the gene 
from core that overlaps your rnaseq gene and then you can check if they 
have an xref of your choice.

# You will need a GeneAdaptor on your core DB
$coredbga = $coredb->get_GeneAdaptor;
# You will need a SliceAdaptor on your core DB
$coredbsa = $coredb->get_SliceAdaptor;
foreach my $slice (@$slices) {
   # fetch genes from rnaseq
   my $genes = $slice->get_all_Genes($logic_name);
   foreach my $gene (@$genes) {
     $coreslice = $coresa->fetch_by_name($gene->feature_Slice()->name);
     foreach my $cgene 
(@{$coredbga->fetch_all_by_Slice_and_external_dbname_link($coreslice, 
undef, undef, "EntrezGene")}) {
       foreach my $dbes ($cgene->get_all_DBLinks("EntrezGene")){
         foreach my $dbe (@{$dbes}){
           print $dbe->primary_id(), "\t";
         }
       }
     }
   }
}

Hope this helps

Thibaut

On 2012-08-30 04:24, Jerry Li wrote:
> Hi All,
> Sorry to bother you all on this topic but I can really use some
> advice.
>  
> Based on an example I found in the email archive
> http://lists.ensembl.org/pipermail/dev/2010-September/005130.html [1]
> I put together the following code to retrieve the EntrezGene IDs 
> based
> on Ensembl $gene.  However, no result was returned. 
> The database I accessed was homo_sapiens_rnaseq_68_37, and logic_name
> is ovary_rnaseq.
> Can anyone provide some pointer on how I can get this data?
>  
> foreach my $slice (@$slices) {
>   # fetch genes from rnaseq
>   my $genes = $slice->get_all_Genes($logic_name);
>   foreach my $gene (@$genes) {
>         foreach my $dbes ($gene->get_all_DBLinks("EntrezGene")){
>             foreach my $dbe (@{$dbes}){
>                 print $dbe->primary_id(), "t";
>             }
>         }
>     }
> }
>
>  
> Thanks,
> Jerry
>
>
> Links:
> ------
> [1] http://lists.ensembl.org/pipermail/dev/2010-September/005130.html





More information about the Dev mailing list