Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matUtils extract --reroot: retain rerooted leaf, rename leaf from former internal node #380

Merged
merged 1 commit into from
Oct 4, 2024

Commits on Sep 28, 2024

  1. matUtils extract --reroot: retain rerooted leaf, rename leaf from for…

    …mer internal node
    
    This addresses two corner cases that we hadn't thought through yet for --reroot:
    
    * First, when rerooting to a leaf node, that node was converted into an internal node (the new root), losing its leaf status, so when the result was written out, the tree no longer had that leaf.  To fix this, when rerooting to a leaf, we add a new leaf with the same name on the new root node.
    
    * Second, when the old root had no leaf children and only one internal node child, after rerooting it became a new leaf node, keeping its original ID of 'node_1'.  However, the saved protobuf could not be read back in by matUtils because when parsing the Newick string, 'node_1' is assigned to the first node encountered, and it is an error for any subsequent node to have the name 'node_1' (even a leaf) because node_1 is already in the tree.  To prevent that error, when the old root becomes a leaf node, we change the old root's name to former_root -- unless there is already a former_root in the tree, in which case we make a new former_root_<serialNumber> that does not already exist in the tree.
    AngieHinrichs committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    2fd2617 View commit details
    Browse the repository at this point in the history