0

我正在尝试使用 bioperl 从 newick 树中删除一个节点。树文件包含以下数据:

(((A:5,B:5)90:2,C:4)25:3,D:10);

下面是代码:

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;

输出:1;

所以 remove_Node 正在工作,但问题是当我打开树文件时,我发现节点仍然存在!...... 代码有什么问题?如何从树中删除节点?

提前致谢。

4

1 回答 1

2
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);
}
于 2013-06-14T12:44:10.723 回答