[Bioperl-l] remove_Node leaves parenthesis after deleting internal leaf

Kevin Beckmann kgb11 at psu.edu
Wed Sep 28 15:38:21 EDT 2005


This bug is listed as Bug 1870 under Bugzilla:

I've come across a bug in TreeIO:
Using this as a model tree (file is named "model_tree.phy"):
(Arabidopsis,(BNGI,(PPLGI,(csa,(GMGI,MTGI)))));

I run this script:

#!/usr/bin/perl -w
### remove_Node_bug.pl ###
# Created: Wed Sep 28 13:10:00 EDT 2005
# creator- Kevin Beckmann

use strict;
use Bio::TreeIO;

my $file = "model_tree.phy";

my $treein = new Bio::TreeIO(-file => $file, -format => "newick");
my $tree = $treein->next_tree();
my $treestart = new Bio::TreeIO(-format => 'tabtree');
print "Starting tree:\n";
$treestart->write_tree($tree);

foreach my $node ( $tree->get_leaf_nodes() ) {
        my $leaf_id = $node->id();
        next if ($leaf_id ne "csa");

        $tree->remove_Node($node);
}

my $treeout = new Bio::TreeIO(-format => 'tabtree');
print "Tree w/ deleted node:\n";
$treeout->write_tree($tree);

$treeout = new Bio::TreeIO(-format => 'newick');
print "Extra set of parentheses:\n";
$treeout->write_tree($tree);
print "\n";
exit;
##########

The script searches through the leaf nodes of the tree to delete the node
labelled "csa".
When it does so, it leaves in the parenthesis that surround that node and
produces a tree:
(Arabidopsis,(BNGI,(PPLGI,((GMGI,MTGI)))));
instead of a tree:
(Arabidopsis,(BNGI,(PPLGI,(GMGI,MTGI))));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: model_tree.phy
Type: application/octet-stream
Size: 48 bytes
Desc: not available
Url : http://portal.open-bio.org/pipermail/bioperl-l/attachments/20050928/a7c125f7/model_tree.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: remove_Node_bug.pl
Type: application/octet-stream
Size: 806 bytes
Desc: not available
Url : http://portal.open-bio.org/pipermail/bioperl-l/attachments/20050928/a7c125f7/remove_Node_bug.obj


More information about the Bioperl-l mailing list