[ensembl-dev] Gene adaptor returns nothing

Andy Yates ayates at ebi.ac.uk
Tue May 22 12:23:33 BST 2012


Hi Allan,

I think you were having some issues with the hash assignment parameter in the call to the registry. Please see a working version of your script below:

use strict;
use warnings;
use Bio::EnsEMBL::Registry;

# The hash assignment here should be => & not = as you had it
Bio::EnsEMBL::Registry->load_registry_from_db(
-host =>'ensembldb.ensembl.org',
-user =>'anonymous',
);
my $gene_adaptor=Bio::EnsEMBL::Registry->get_adaptor( "human", "core", "gene");

#If you want genes based on a single DB then specify it as the second parameter to this method. We support wildcards here as well
my @genes=@{ $gene_adaptor->fetch_all_by_external_name('BRCA1', 'EntrezGene') };

while (my $gene = shift @genes) {
  print $gene->stable_id(), "\n";
}

All the best,

Andy

Andrew Yates                   Ensembl Core Software Project Leader
EMBL-EBI                       Tel: +44-(0)1223-492538
Wellcome Trust Genome Campus   Fax: +44-(0)1223-494468
Cambridge CB10 1SD, UK         http://www.ensembl.org/

On 22 May 2012, at 12:05, Allan Kamau wrote:

> Hi,
> I have a list of gene names from EntrezGene for which I would like to
> obtain transcripts for.
> The code:
> @genes=@{ $gene_adaptor->fetch_all_by_external_name('BRCA1') };
> 
> returns nothing.
> 
> I have composed the test code below mainly from the sample code on the
> ensembl api documentation.
> 
> What am I overlooking?
> 
> 
> 
> 
> 
> 
> use Bio::EnsEMBL::Registry;
> 
> Bio::EnsEMBL::Registry->load_registry_from_db(
> -host ='ensembldb.ensembl.org',
> -user ='anonymous',
> );
> if(1==2)
> {
> 	$gene_adaptor=Bio::EnsEMBL::Registry->get_adaptor( "human", "core", "gene"
> );
> 	
> 	$gene=$gene_adaptor->fetch_by_dbID(1234);
> 	
> 	$gene=$gene_adaptor->fetch_by_stable_id('ENSG00000184129');
> }
> 
> @genes=@{ $gene_adaptor->fetch_all_by_external_name('BRCA1') };
> 
> if(1==2)
> {
> 	$slice_adaptor =
> 	Bio::EnsEMBL::Registry->get_adaptor( "human", "core", "slice" );
> 	
> 	$slice =
> 	$slice_adaptor->fetch_by_region( 'chromosome', '1', 1, 1000000 );
> 	
> 	@genes = @{ $gene_adaptor->fetch_all_by_Slice($slice)};
> }
> while (my $gene = shift @{$genes})
> {
> 	print "Here";
> 	#$gene.list_stable_ids();
> }
> 
> 
> Allan.
> 
> _______________________________________________
> 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