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

traverse_rootdistorder(): unsupported operand type #12

Closed mahermassoud closed 3 years ago

mahermassoud commented 4 years ago
ttree = ts.read_tree_newick("(A:3.2,(B:2.1,(C:1,D:1)));")
b_parent = ttree.root.child_nodes()[1]
neigh_iter = b_parent.traverse_rootdistorder()

Produces

Traceback (most recent call last):
  File "scratch_tree.py", line 20, in <module>
    for neighbor in neigh_iter:
  File "/Users/maherm/Documents/Code/TreeSwift/treeswift/Node.py", line 369, in traverse_rootdistorder
    d = dist_from_root[node.parent] + node.edge_length
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
niemasd commented 3 years ago

Thanks for catching that, and sorry for the delay! Fixed in TreeSwift v1.1.17:

https://github.com/niemasd/TreeSwift/blob/ea90060a1570fbdf013762504a83fec3741e436e/treeswift/Node.py#L370-L372