niemasd / TreeSwift

TreeSwift: Fast tree module for Python 3
https://niema.net/TreeSwift
GNU General Public License v3.0
75 stars 14 forks source link

Rerooting error #24

Closed smirarab closed 1 year ago

smirarab commented 1 year ago

In this line, we should have node.edge_length = length not node.edge_length -= length. As is, length is subtracted from both sides, which is incorrect. The total length after should be the same as total length before. https://github.com/niemasd/TreeSwift/blob/53c752e0f738627774fad70b3ca6c1725cc606e9/treeswift/Tree.py#L1069

smirarab commented 1 year ago

The previous code happens to be correct for one case: length = node.edge_length/2; I suspect only that case is tested.

niemasd commented 1 year ago

Thanks for catching that! Fixed in TreeSwift v1.1.30 via commit https://github.com/niemasd/TreeSwift/commit/2d045fb90503a1963a6b312d47bb7f7bc35ab1e8

You should be able to update via pip, e.g. pip install --upgrade treeswift (might take a few tries since the update is fresh)