[ensembl-dev] LOC_ aliases

ian Longden ianl at ebi.ac.uk
Wed Nov 24 15:45:40 GMT 2010


There is no direct way to do this with the API, you may have to do
this in sql something like :-

select x.* from xref x, external_db e
  where x.external_db_id = e.external_db_id and
           e.db_name  = "EntrezGene" and
           x.display_label like "LOC%"
   limit 10;

you can do this from inside your scripts by dong something like:-

use Bio::EnsEMBL::Registry;
use strict;
my $reg = "Bio::EnsEMBL::Registry";

$reg->load_registry_from_db(
   -host => "ensembldb.ensembl.org",
   -user => "anonymous",
   -db_version => 60
);


my $dba = $reg->get_adaptor("human", "core", "dbentry");
my $gene_adaptor = $reg->get_adaptor("human", "core", "gene");

my $sql = 'select distinct(x.xref_id) from xref x, external_db e,
object_xref ox where x.external_db_id = e.external_db_id and
x.display_label like "LOC%" and ox.xref_id = x.xref_id and e.db_name
= "EntrezGene"';


my $sth = $dba->dbc->prepare($sql);
$sth->execute;

my $xref_id;
$sth->bind_columns(\$xref_id);

my $count = 0;
while($sth->fetch() and $count < 100){
  my $dbentry = $dba->fetch_by_dbID($xref_id);
  my @genes = @{$gene_adaptor->fetch_all_by_external_name($dbentry->display_id)};
  foreach my $gene (@genes){
    print $dbentry->display_id."\t".$gene->display_xref->display_id."\t".$gene->stable_id."\n";
  }
  $count++
}
$sth->finish;



HTH,
Ian Longden
Ensembl Developer.




More information about the Dev mailing list