[Bioperl-l] Does $tree->remove_Node prune or splice?
Jim Hu
jimhu at tamu.edu
Thu Oct 21 17:52:32 UTC 2010
I'm trying to take an unreadable tree from PFAM and prune it down to just show the paralogs from E. coli.
When you run remove_Node on an internal node, is it supposed to reconnect the ancestors to the descendants? This seems to be way to aggressive in what it's removing.
while( my $tree = $treeio->next_tree ) {
for my $node ( $tree->get_nodes ) {
if ($node->id =~ m/_ECOLI/){
# leave this node alone
# print $node->id."\n";
}else{
if ($node->is_Leaf){
$tree->remove_Node($node);
}else{
my $num_children = scalar($node->each_Descendent);
if ($num_children == 1){
print "removing ".$node->id."\n";
$tree->remove_Node($node);
}
}
}
}
$treeio_out->write_tree($tree);
}
The idea is that when I've pruned the non-ECOLI leaves, some internal nodes will not be branches anymore. But at the end, all the ECOLI nodes are gone, presumably because an ancestor got removed and the whole branch was lost. Is there a way to remove just a node and graft the tree back together? My plan, once I get that working is to repeat the traversal until the output stops changing.
Jim
=====================================
Jim Hu
Associate Professor
Dept. of Biochemistry and Biophysics
2128 TAMU
Texas A&M Univ.
College Station, TX 77843-2128
979-862-4054
More information about the Bioperl-l
mailing list