Question: Ensembl Compara Perl Api Taxon->Classification Error
1
gravatar for Cassj
9.3 years ago by
Cassj1.3k
London
Cassj1.3k wrote:

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;

  }

}
bioperl api ensembl perl • 2.0k views
ADD COMMENTlink modified 11 months ago by RamRS23k • written 9.3 years ago by Cassj1.3k

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 REPLYlink modified 11 months ago by RamRS23k • written 9.3 years ago by Michael Dondrup46k

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

ADD REPLYlink written 9.3 years ago by Giovanni M Dall'Olio26k
1
gravatar for 2184687-1231-83-
9.1 years ago by
2184687-1231-83-5.0k wrote:

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

ADD COMMENTlink modified 11 months ago by RamRS23k • written 9.1 years ago by 2184687-1231-83-5.0k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1694 users visited in the last hour