[Bioperl-l] branch length score - total length of the spanning subtree
Daniel Gerlach
Daniel.Gerlach at medecine.unige.ch
Tue Mar 4 16:12:53 UTC 2008
Hello,
Thanks for the quick answer. I tried:
use Bio::TreeIO;
my $treeio = Bio::TreeIO->new(-format => 'newick',
-fh => \*DATA);
my $tree = $treeio->next_tree;
print $tree->total_branch_length,"\n";
$tree->splice(-keep_id => [A,B,E]);
print $tree->total_branch_length,"\n";
__DATA__
(((A:5,B:5)x:2,(C:4,D:4)y:1)z:3,E:10);
Which gives me the message "MSG: After splicing, the original root was
removed but there are multiple candidates for the new root!" however the
root E was not removed.
If I do it the complementary way by splicing out all unwanted nodes -
splice(-remove_id => [C,D]) - I get what I want:
34
25
Greetings, Daniel
Sendu Bala wrote:
> Daniel Gerlach wrote:
>> Hello,
>>
>> I would like to use bioperl to calculate a branch length score for a
>> given set of nodes and a tree. I know how to get the total branch
>> length by using $tree->total_branch_length, but how could I get the
>> length of the subtree spanning some given nodes which are dispersed
>> over the whole tree (a subset of nodes from the tree which are not
>> monophyletic)?
>
> One 'cheat' way of doing it might be to use splice(-keep_ids =>
> \@node_ids) or similar, then run total_branch_length() on that. No idea
> if it will actually give you the right answer though. Let us know! :)
More information about the Bioperl-l
mailing list