Ensembl Compara Perl Api Taxon->Classification Error
1
1
Entering edit mode
14.7 years ago
Cassj ★ 1.3k

I've hit a problem with the Ensembl compara API. I'm just trying to grab all the orthologs of a gene and print out the classification of the species to which they belong. See script below for illustration - it just loops through the members of a homology object and tries to call $member->taxon->classification. It always fails on the second attempt, regardless of the genes / species involved. If you pass it a number, it will skip over that many members of the homology before successfully fetching the classification of the next one and failing with a "MSG: Can't classification on a multifurcating tree" error on the one after that. API modules I'm using should be up to date with the CVS.

Can anyone see what I'm missing?

Cheers
Cass

#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;

use Bio::EnsEMBL::Registry;

my $num = $ARGV[0];

my $ensembl_host = 'ensembldb.ensembl.org';
my $ensembl_user = 'anonymous';

my $REGISTRY = 'Bio::EnsEMBL::Registry';
$REGISTRY->load_registry_from_db(
                                 '-host' => $ensembl_host,
                                 '-user' => $ensembl_user,
                                );


my $member_adaptor = $REGISTRY->get_adaptor('Multi', 'compara', 'Member');
my $member = $member_adaptor->fetch_by_source_stable_id('ENSEMBLGENE', 'ENSMUSG00000031575');

my $homology_adaptor = $REGISTRY->get_adaptor('Multi', 'compara', 'Homology');
my $homologies = $homology_adaptor->fetch_all_by_Member($member);


#count for testing - for some reason, calling classification only works
#the first time you call it - but it doesn't seem to matter
my $count = 0;

foreach my $homology (@$homologies) {
  $count++;
  next if ( $num && ( $count < $num) );

  foreach my $member_attribute (@{$homology->get_all_Member_Attribute}) {
      my ($member, $attribute) = @{$member_attribute};

      #first member is the query gene.
      next if $member->stable_id eq 'ENSMUSG00000031575';

      warn $member->stable_id;

      #fetch classification info
      my $taxon = $member->taxon;
      my $classification_string = $taxon->classification;
      my %classification = map {$_ => 1} split /\s+/, $classification_string;
      warn Dumper \%classification;

  }

}
api ensembl perl bioperl • 3.4k views
ADD COMMENT
0
Entering edit mode

I am not using this package but there is something broken in the displayed code:

next if ( $num && ( $count get_all_Member_Attribute}) {

Looks like stackexchange has some problems with perl code...

ADD REPLY
0
Entering edit mode

don't you need to define the web port along with the address ensembldb.ensembl.org:3306 or something like that) ?

ADD REPLY
1
Entering edit mode
ADD COMMENT

Login before adding your answer.

Traffic: 1540 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6