I am working on protein sequence data files for reconstructing phylogenetic tree and I need to generate all NNI-neighbours of the tree (two trees are NNI-neighbours if one can be transformed into another by one nearest neighbour interchange operation). Is there any python package/sorce code I can access to, which can retrieve all NNI neighbors of a tree. Earlier I have used biopython 1.72 to generate tree from my dataset. But for now I'm looking for a python package which can do NNI search on my tree and return all NNI-neighbors.


1 Answer 1


Both the ETE Toolkit and DendroPy offer methods of node removal and reattachment - I would think it would be easy enough to hack together an NNI movement function with them.

You could also investigate the source code of BioPython's NNITreeSearcher() function.

  • $\begingroup$ I have used biopython among them, but my concern is to return all the trees which are reconstructed before the best tree is reached, and biopython NNITreeSearcher() results one best scored tree. $\endgroup$ Sep 10, 2018 at 16:53
  • $\begingroup$ That is why I suggested searching the source code to see if you can find the code controlling the NNI moves and use that. $\endgroup$
    – NatWH
    Sep 10, 2018 at 17:01
  • 1
    $\begingroup$ I have studies biopython module and I found that _get_neighbors() function generates all NNI neighbor trees of the given tree. $\endgroup$ Sep 11, 2018 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.