Esempio n. 1
0
    /**
     * Number any nodes in a clade which were not explicitly numbered by the parsed string.
     *
     * @param node clade parent
     */
    private void numberUnnumberedNodes(Node node) {
      if (node.isLeaf()) return;

      for (Node child : node.getChildren()) {
        numberUnnumberedNodes(child);
      }

      if (node.getNr() < 0) node.setNr(numberedNodeCount);

      numberedNodeCount += 1;
    }
  /**
   * Disconnect node from root, discarding all colouring on <node,root> and <node's sister,root>.
   *
   * @param node
   */
  public void disconnectBranchFromRoot(Node node) {

    // Check argument validity:
    if (node.isRoot() || !node.getParent().isRoot())
      throw new IllegalArgumentException("Illegal argument to" + " disconnectBranchFromRoot().");

    // Implement topology change:
    Node parent = node.getParent();
    Node sister = getOtherChild(parent, node);
    sister.setParent(null);
    parent.getChildren().remove(sister);

    // Clear colour changes on new root:
    ((MultiTypeNode) sister).clearChanges();

    // Ensure BEAST knows to update affected likelihoods:
    parent.makeDirty(Tree.IS_FILTHY);
    sister.makeDirty(Tree.IS_FILTHY);
    node.makeDirty(Tree.IS_FILTHY);
  }