Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix get_distance() for topology_only=True #742

Open
wants to merge 1 commit into
base: ete3
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions ete3/coretype/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,11 +1023,13 @@ def get_distance(self, target, target2=None, topology_only=False):
current = n
while current != ancestor:
if topology_only:
if current!=target:
dist += 1
dist += 1
else:
dist += current.dist
current = current.up
if topology_only and target != target2:
# counted ancestor once more than needed in while loop
dist -= 1
return dist

def get_farthest_node(self, topology_only=False):
Expand Down