Skip to content

unroot doesn't preserve total branch lengths #269

@nomihadar

Description

@nomihadar

Hi,

The unroot() doesn't preserve total branch lengths:

from ete3 import Tree

#rooted tree
tree_newick = '((161100:0.00956962,4472:0.0109621)1:0.00420709,(161105:0.00616437,(161099:0.010252,161106:0.0064157)1:0.0143586)1:0.00315984);'

rooted = Tree(tree_newick)

#sum of branch lengths
d_rooted = 0
for node in rooted.traverse():
	d_rooted += node.dist
	
#unroot tree
unrooted = Tree(tree_newick)
unrooted.unroot()

#sum of branch lengths
d_unrooted = 0
for node in unrooted.traverse():
	d_unrooted += node.dist
	
#comapre sums
print d_rooted == d_unrooted #false

thanks!
Nomi

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions