I implemented this relatively simple type of tree surgery in Python. The example is the one we talked about last time (here). The plot of the result is above, and for reference, the original tree is below:
The output shows the logic:
The first section is the initial tree. The middle part documents the changes we're making and the last prints out the result. I parsed the tree using our previous code, and plotted it using R's ape. I also added the code (
nni.py
) to the zipped files for the project. It's been fun, but I probably won't do the others for a while, if at all. I'm ready for new challenges.