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.


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.

| improve this answer | |
  • $\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$ – Sidra Younas Sep 10 '18 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 '18 at 17:01
  • $\begingroup$ I have studies biopython module and I found that _get_neighbors() function generates all NNI neighbor trees of the given tree. $\endgroup$ – Sidra Younas Sep 11 '18 at 6:07
  • $\begingroup$ You can upvote my answer if you think it has been helpful $\endgroup$ – NatWH Sep 11 '18 at 6:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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