I'm trying to remove a node from a newick tree using bioperl. The tree file contains this data :
(((A:5,B:5)90:2,C:4)25:3,D:10);
Below is the code:
use Bio::TreeIO;
use Bio::Tree::TreeFunctionsI;
use strict;
use warnings;
my $input = new Bio::TreeIO(-file => "tree.newick", -format => "newick");
my $tree = $input->next_tree;
my $bool = $tree-> remove_Node('B');
print $bool;
output: 1;
So the remove_Node is working, but the problem is when I open the tree file I find the node is still present!... What is wrong with the code ? how to remove the node from the tree??
Thanks in advance.
use strict;
use warnings;
use Bio::TreeIO;
use Bio::Tree::TreeFunctionsI;
my $in = Bio::TreeIO->new( -format => 'newick',
-file => 'tree.newick' );
my $out = Bio::TreeIO->new( -format => 'newick' );
while ( my $tree = $in->next_tree ) {
$tree->remove_Node('B');
$out->write_tree($tree);
}