Using the Phylo package in Python3, I am trying to compute distances between two terminal nodes (leaves) of a neighbour-joining tree. To do this, the package implements a distance function. However, the distance function gives me a different result from what is in my newick file (the difference is very light but quite important in my work). Here is my code:
#Libraries
import os
from Bio import Phylo
from io import StringIO
# Tree
handleD = StringIO("((E:0.2,D:0.1,C:0.1,B:0.3)2:0.3,A:0.5)1;")
treeD = Phylo.read(handleD,"newick")
# Distance
treeD.distance("E","D")
The distance returns 0.30000000000000004 and not 0.3 as describe in the newick format.
I tried to look at the source code: http://biopython.org/DIST/docs/api/Bio.Phylo.BaseTree.TreeMixin-class.html#distance that leads to that function : http://biopython.org/DIST/docs/api/Bio.Nexus.Trees-pysrc.html#Tree.sum_branchlength but it doesn't explain why there is a difference in the values.
Have you got an explanation why the function returns 0.30000000000000004 instead of 0.3 as described in the newick format?
Thanks in advance.