I would like to compare each node of a phylogenetic tree with another tree and get the distance between these two. Eventually I also would want that only the distances that are smaller than a certain level are printed. (Pycharm)

This is an example tree I am using to get the code and afterwards I will use this for a "real" tree.

from ete3 import Tree

nw = '(((A:0.1, B:0.01):0.001, C:0.0001):1.0, (((((D:0.00001, I:0):0, F:0):0,G:0),H:0): E:0.000001):0.0000001):2.0;'

t = Tree(nw)

print(t)

print("The distance between A and C is", t.getdistance("A", "C))

The result is: The distance between A and C is 0.10110000000000001

So I would like to get this for each node, so A vs B, A vs D, A vs E, D vs E, F vs G,...

And afterwards I would like to eliminate the results of which the distance is larger than 0.8

0 Answers