[ensembl-dev] gene to coords code issue
Sean O'Keeffe
so2346 at columbia.edu
Fri Apr 20 04:49:02 BST 2012
Hi,
I've used the code below on multiple occasions to convert external gene
names to chromosome coords and it worked fine.
However when I tried it just now I get the error for the very first gene
DNAI2 and the script crashes:
Can't call method "seq_region_name" on unblessed reference
When I tried fetch_by_display_label($id) - I get:
Can't call method "seq_region_name" on an undefined value
Have I missed something?
Thanks for any help,
Sean.
p.s. I tried connecting to the
useastdb.ensembl.org,<http://useastdb.ensembl.org/>as I'm in the
states, but It gave the following (maybe the 2 issues are
related):
DBI connect('host=useastdb.ensembl.org;port=3306','anonymous',...) failed:
Can't connect to MySQL server on 'useastdb.ensembl.org' (111) at
/home/sean/tools/ensembl_53/modules/Bio/EnsEMBL/Registry.pm line 1329
Can't call method "selectall_arrayref" on an undefined value at
/home/sean/tools/ensembl_53/modules/Bio/EnsEMBL/Registry.pm line 1332.
==============
#!/usr/bin/perl
use strict;
use lib '/home/sean/tools/ensembl_53/modules';
use Bio::SeqIO;
use Bio::Root::IO;
use Bio::EnsEMBL::DBSQL::BaseAdaptor;
use Bio::EnsEMBL::Registry;
my $registry = 'Bio::EnsEMBL::Registry';
#$registry->load_registry_from_db(-host => 'useastdb.ensembl.org',-user =>
'anonymous');
$registry->load_registry_from_db(-host => 'ensembldb.ensembl.org',-user =>
'anonymous');
open OUT, ">$gene_file.coords";
for my $geneid ( @unique ) {
chomp $geneid;
($chr,$start, $end) = ensembl_coords($geneid);
print OUT join("\t", $chr,$start,$end,$geneid),"\n";
}
sub ensembl_coords {
my ($id) = @_;
my $adaptor = $registry->get_adaptor( 'Human', 'Core', 'gene' );
my $gene = $adaptor->fetch_all_by_external_name($id);
# my $gene = $adaptor->fetch_by_display_label($id);
$chr = $gene->seq_region_name();
$start = $gene->seq_region_start();
$end = $gene->seq_region_end();
return ($chr,$start,$end);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ensembl.org/pipermail/dev_ensembl.org/attachments/20120419/c915b540/attachment.html>
More information about the Dev
mailing list