[Bioperl-l] "richer" tree nodes

Aaron J Mackey Aaron J. Mackey" <amackey@virginia.edu
Mon, 15 Jul 2002 17:11:29 -0400 (EDT)


On Mon, 15 Jul 2002, Jason Stajich wrote:

> But attatching whole sequences objects will call for new type of factories
> - hence the whole factory design in the first place as I imagine won't be
> pulling this info from a generic newick file....

Right - You could imagine that Bio::Tools::Phylo::PAML is an odd type of
TreeFactory that produces regular old Bio::Tree::Tree objects that have
Bio::Tools::Phylo::PAML::Node nodes (which are themselves containers of
Bio::PrimarySeq objects for ancestral sequences and other simple
statistical data structures) ... or did you imagine the Node's using a
SeqFactory themselves?

> oh yes - I really want these in there, I just haven't had a chance to
> program them in.  I'd like to work on the monophyletic one if you haven't
> already...

Go ahead, it's all yours.  Note that my example wasn't very good: to
determine monophylogeny you need a reference to some "root" of the
monophylogeny:

my $tree = new Bio::Tree::Taxonomy source => 'NCBI'; # imaginary
my $bact = $tree->find_node("Bacteria");
my @nodes = map { $tree->find_node($_) } ('Escherichia coli', 'Salmonella
paratyphi A', 'Klebsiella pneumoniae');
if($tree->monophyletic(-root => $bact, -test => \@nodes)) {
    # all @nodes are under this root.
}

Otherwise, if you don't specify a root, you could go this route:

$newroot = $tree->lca(@nodes);
if($newroot->descendentOf($bact)) {
   # all @nodes are under this root.
} elsif ( $newroot == $tree->get_root_node ) {
   # any two nodes in the same tree are monophyletic with respect to the
   # root node!
}

Sorry, random musings.

-Aaron