Skip to content

Bio.Phylo: "neighbor joining" tree construction fails for minimal alignment #1323

Closed

Description

@hendrikweisser

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

  1. peterjc commented on Jul 13, 2017

    @peterjc
    Member
  2. peterjc commented on Feb 12, 2019

    @peterjc
    Member

    This should be closed via #1891.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions