[Bioperl-l] Does $tree->remove_Node prune or splice?

Roy Chaudhuri roy.chaudhuri at gmail.com
Wed Nov 10 16:11:27 UTC 2010


Hi Jim,

I don't think you ever got a reply to this. I think you want 
$tree->splice() rather than $tree->remove_Node().

Cheers,
Roy.

On 21/10/2010 18:52, Jim Hu wrote:
> 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
>
>
>
> _______________________________________________ Bioperl-l mailing
> list Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l




More information about the Bioperl-l mailing list