[Bioperl-l] getting a subtree

Jason Stajich jason at cgt.duhs.duke.edu
Thu Mar 4 16:15:22 EST 2004


Deng - here is some code to answer your question.

use Bio::Tree::Tree;
use Bio::TreeIO;

# get a tree somehow
# choose the subnodes for finding the lca somehow

# get the least common ancestor
my $node = $tree->get_lca( -nodes => \@nodes );

# build a new tree with its root at $node
my $subtree = Bio::Tree::Tree->new(-root => $node, -nodelete => 1);

my $out = Bio::TreeIO->new(-format=>'newick');
$out->write_tree($subtree);

-jason

--
Jason Stajich
Duke University
jason at cgt.mc.duke.edu


More information about the Bioperl-l mailing list