You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bio.Phylo: "neighbor joining" tree construction fails for minimal alignment #1323
The "neighbor joining" algorithm for the construction of phylogenetic trees, implemented in Bio.Phylo.TreeConstruction.DistanceTreeConstructor.nj fails with the following error, if applied to a minimal sequence alignment containing only two sequences:
File "...\Bio\Phylo\TreeConstruction.py", line 703, in nj
if clades[0] == inner_clade:
UnboundLocalError: local variable 'inner_clade' referenced before assignment
This is with BioPython version 1.68, but looking at the code, the cause of the problem seems to be still present in the "master" branch: Following from here (1.68) or here ("master"), the code that sets the inner_clade variable is only executed for distance matrices of size > 2.
A simple check could be added to avoid the error. However, since the UPGMA algorithm is able to successfully generate a (trivial) tree for such a minimal alignment, it would be great if the NJ algorithm could be adapted to do the same.
Activity
peterjc commentedon Jul 13, 2017
CC @lijax, @etal
Special cases for minimum alignment matrices in the NJ algorithm (#1891)
peterjc commentedon Feb 12, 2019
This should be closed via #1891.