[Bioperl-l] Local flat file implementation of Bio::DB::Taxonomy

Gabriel Valiente valiente at lsi.upc.edu
Tue Feb 21 11:10:05 EST 2006


It works now, with the #!/usr/bin/perl -w switch. Sorry about that.

I'd like to contribute a couple of additional methods to
Bio::DB::Taxonomy. The first one returns a reference to an array with
the full lineage of a given node.

sub lineage {
  my $node = shift;
  my @PATH;
  while ($node->node_name ne "root") {
    $node = $node->get_Parent_Node;
    unshift @PATH, $node;
  }
  return \@PATH;
}

The second one uses the lineage method to return the most recent common
ancestor of two given nodes.

sub LCA {
  my $node1 = shift;
  my $node2 = shift;
  my @PATH1 = @{lineage($node1)};
  my @PATH2 = @{lineage($node2)};
  my $root1 = shift @PATH1;
  my $root2 = shift @PATH2;
  while ($root1->node_name eq $root2->node_name) {
    $root1 = shift @PATH1;
    $root2 = shift @PATH2;
  }
  return $root1;
}

Jason, shall I include them myself in Bio::DB::Taxonomy or can you take
care of this? I think, the right place for these methods might be
Bio::Taxonomy or Bio::Taxonomy::Node rather than Bio::DB::Taxonomy.

Thanks,

Gabriel




More information about the Bioperl-l mailing list