[ensembl-dev] Ensembl API Error: fail to retrieve data with gene ID
Andy Yates
ayates at ebi.ac.uk
Wed Mar 7 09:49:46 GMT 2012
Hi,
I have just run your code against the latest release of Ensembl Genomes (release 13 based on Ensembl 66 code) with your submitted tests (C.ele & C45B2.4) and both queries work fine. I can also confirm that "special" characters in this instance will not cause the API to fail.
Could you confirm your API version please? You may have downloaded the HEAD or 66 release of the API; the former is not intended for public use yet & the later would have not worked with Ensembl Genomes until yesterday (due to their release). You may also want to add a -VERBOSE => 1 flag to your call to load_registry_from_db() which will force the API to tell you the databases and species it has found.
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 7 Mar 2012, at 01:50, 陈岗 wrote:
> Hi All
>
> I use Ensembl API to retrieve gene information, the script works well on Ensembl data. However, when try to retrieve some EnsemblGenomes's entries, error happens.
>
> I guess the gene Id which contain special character such as dot ('.') cause API fail to work. For example, species=Caenorhabditis_elegans&id=C45B2.4 . I also try to get data with display_label, instead of gene_id. Unfortunately, the method $sth->fetch() fails to work on the same entries.
>
> Is there anyone know the solution? If someone knows the way that find out the database name of a given species, I can use my own SQL sentence to do the task.
>
> Thanks.
>
> Code: retrieve data with gene_id
>
> use Bio::EnsEMBL::Registry;
> use DBConfig;
>
> my %my_host = &DBConfig::DBConfigure;
> my $my_specise;
> my $registry = "Bio::EnsEMBL::Registry";
> my $stable_id;
>
> $registry->load_registry_from_db(
> -host => $my_host{ip},
> -user => $my_host{user},
> -pass => $my_host{pass},
> -port => $my_host{port}
> );
>
> my $gene_adaptor = $registry->get_adaptor($my_specise, 'Core', 'gene' );
> my $gene = $gene_adaptor->fetch_by_stable_id($stable_id);
> my $transcripts = $gene->get_all_Transcripts();
> ......................
> ......................
> ......................
>
> Code: retrieve data with display_label
>
> use Bio::EnsEMBL::Registry;
> use DBConfig;
>
> my $my_specise;
> my $registry = "Bio::EnsEMBL::Registry";
> my $stable_id;
> my $display_label;
> my %my_host = &DBConfig::DBConfigure;
>
> $registry->load_registry_from_db(
> -host => $my_host{ip},
> -user => $my_host{user},
> -pass => $my_host{pass},
> -port => $my_host{port}
> );
>
> my $gene_adaptor = $registry->get_adaptor($my_specise, 'Core', 'gene' );
> my $dba= $registry->get_DBAdaptor($my_specise, "core");
>
> # Retrieve gene's display_label, according to the given gene_id
> my $sth = $dba->dbc->prepare( "select x.display_label from gene g,xref x where g.display_xref_id = x.xref_id and g.stable_id='$stable_id'");
> $sth->execute;
> $sth->bind_columns(\$display_label);
>
> if ($sth->fetch()){
> print $display_label;
> }
> else{ die "Cannot find this gene."; }
> ..............................
> ..............................
> ..............................
>
> --
> Gang Chen
> TILSI
> Taicang Institute For Life Science Information
> Address: A2/162, Renmin South Road, Taicang, 215400, Jiangsu Province, P.R.China
> Phone:(+86)512-82782588
>
> _______________________________________________
> 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