[ensembl-dev] Ensembl API Error: fail to retrieve data with gene ID

陈岗 danielchen06 at gmail.com
Wed Mar 7 01:50:44 GMT 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ensembl.org/pipermail/dev_ensembl.org/attachments/20120307/a029b027/attachment.html>


More information about the Dev mailing list