This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Ensembl Compara Perl Api Taxon->Classification Error

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

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...

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

1 answer

There is a modified version of the NCBITaxon.pm module that should fix your problem: http://cvs.sanger.ac.uk/cgi-bin/viewvc.cgi/ensembl-compara/modules/Bio/EnsEMBL/Compara/NCBITaxon.pm?root=ensembl&revision=1.19&content-type=text%2Fplain

Log in to answer this question.