Tabnine Logo
TreeNode.isInnerNode
Code IndexAdd Tabnine to your IDE (free)

How to use
isInnerNode
method
in
phylo.tree.model.TreeNode

Best Java code snippets using phylo.tree.model.TreeNode.isInnerNode (Showing top 20 results out of 315)

origin: de.unijena.bioinf.phylo/gscm-lib

private boolean isSubtree() {
  return insertionPoint.isInnerNode();
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

/**
 * Traverses the tree rooted at this node and counts all inner-vertices/clades .
 *
 * @return clades under this node
 */
public int cladeCount(){
  int i = 0;
  for (TreeNode node : depthFirstIterator()) {
    if (node.isInnerNode())
      i++;
  }
  return i;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

private void reApplyLabels(List<Tree> trees, Map<TreeNode, String> labels) {
  for (Tree tree : trees) {
    for (TreeNode node : tree.vertices()) {
      if (node.isInnerNode()) {
        node.setLabel(labels.get(node));
      }
    }
  }
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

public void init(List<Tree> sourceTrees) {
  nameToObject = new HashMap<>();
  ppSet = new HashSet<>();
  for (Tree tree : sourceTrees) {
    Set<TreeNode> taxa = new HashSet<>(Arrays.asList(tree.getLeaves()));
    for (TreeNode treeNode : tree.vertices()) {
      if (treeNode.isInnerNode() && !treeNode.equals(tree.getRoot())) {
        ppSet.add(new PPCharacter(treeNode, new HashSet<>(taxa)));
      }
    }
  }
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

  private static Set<TreePartition> getPartitions(Tree tree, Set<String> allTaxa){
    Set<TreePartition> partitions = new HashSet<TreePartition>();
    for (TreeNode current : tree.vertices()) {
      if (current.isInnerNode()) {
//                if (!current.equals(calculated.getRoot())) {
        TreeNode[] leafes = current.getLeaves();
        if ((allTaxa.size() - leafes.length) > 1)
          partitions.add(new TreePartition(leafes, allTaxa));
//                }
      }
    }
    return partitions;
  }

origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

private Map<TreeNode, Set<Object>> getNodeToLeafMap(Tree tree) {
  Map<TreeNode, Set<Object>> map = new HashMap<>(tree.getNumTaxa());
  for (TreeNode node : tree.vertices()) {
    if (node.isInnerNode()) {
      Set<Object> leafSet = new HashSet<>();
      for (TreeNode taxon : node.getLeaves()) {
        leafSet.add(nameToObject.get(taxon.getLabel()));
      }
      map.put(node, leafSet);
    }
  }
  return map;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

/**
 * Sets all labels of nodes in the tree to s
 *
 * @param s the string the labels are set to
 */
public void setAllLabels(String s) {
  for (TreeNode v : vertices()) {
    if (v.isInnerNode()) {
      v.setLabel(s);
    }
  }
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

private Map<TreeNode, String> removeAndMapInnerLabels(List<Tree> trees) {
  Map<TreeNode, String> labels = new HashMap();
  for (Tree tree : trees) {
    for (TreeNode treeNode : tree.vertices()) {
      if (treeNode.isInnerNode()) {
        String label = treeNode.getLabel();
        treeNode.setLabel(null);
        if (label != null) {
          labels.put(treeNode, label);
        }
      }
    }
  }
  return labels;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

public static boolean containsInnerLabels(Tree tree) {
  for (TreeNode node : tree.vertices()) {
    if (node.isInnerNode()) {
      if (!((node.getLabel() == null) || (node.getLabel().equals(TreeNodeProperties.PROPERTY_LABEL)))) {
        return true;
      }
    }
  }
  return false;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

private static List<TreeNode> checkForBootstrapErrors(Tree tree) {
  List<TreeNode> errorNodes = new LinkedList<>();
  for (TreeNode node : tree.getRoot().depthFirstIterator()) {
    if (!node.equals(tree.getRoot()) && node.isInnerNode()) {
      String label = node.getLabel();
      if (node.getLabel() != null) {
        try {
          int bs = Integer.valueOf(node.getLabel());
        } catch (NumberFormatException e) {
          e.printStackTrace();
          errorNodes.add(node);
        }
      } else {
        errorNodes.add(node);
      }
    }
  }
  if (errorNodes.isEmpty())
    return null;
  return errorNodes;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

public static List<WeightedTreePartitions> getBiparts(Tree sourceTree){
  List<WeightedTreePartitions> biparts = new LinkedList<>();
  final TreeNode r = sourceTree.getRoot();
  Set<String> sourceLeafes = getLeafLabels(r);
  for (TreeNode treeNode : sourceTree.getRoot().depthFirstIterator()) {
    if (treeNode != r && treeNode.isInnerNode()) {
      biparts.add(new WeightedTreePartitions(getLeafLabels(treeNode), sourceLeafes));
    }
  }
  return biparts;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

/**
 * Clones the tree and removes al inner vertices on the tree. Due to cloning
 * the given tree is not modified
 *
 * @param sourceTree the source tree
 * @return clone clone of the soruce treee without any innter vertex labels
 */
public static Tree deleteInnerLabels(Tree sourceTree) {
  Tree tree = sourceTree.cloneTree();
  for (TreeNode node : tree.vertices()) {
    if (node.isInnerNode()) {
      node.setLabel(null);
    }
  }
  return tree;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

/**
 * Returns true if all trees are binary.
 *
 * @param trees the trees
 * @return True, if trees are binary
 */
public static boolean isBinary(Tree[] trees) {
  for (Tree tree : trees) {
    for (TreeNode node : tree.getRoot().depthFirstIterator()) {
      if (node.isInnerNode() && node.childCount() > 2) {
        return false;
      }
    }
  }
  return true;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

public static Tree deleteRootNode(Tree sourceTree, boolean clone) {
  if (clone)
    sourceTree = sourceTree.cloneTree();
  TreeNode r = sourceTree.getRoot();
  if (r.childCount() == 2) {
    List<TreeNode> children = r.getChildren();
    sourceTree.removeVertex(r);
    TreeNode c1 = children.get(0);
    TreeNode c2 = children.get(1);
    if (c1.isInnerNode()) {
      sourceTree.addEdge(c1, c2);
      sourceTree.setRoot(c1);
    } else if (c2.isInnerNode()) {
      sourceTree.addEdge(c2, c1);
      sourceTree.setRoot(c2);
    } else {
      System.out.println("Could not unroot tree. Tree seems not to be a tree!");
      return null;
    }
  }
  return sourceTree;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

public static double claculateMinumCharaterDeletionCosts(Tree tree, List<Tree> sourceTrees) {
  Set<TreeNode> deletedNodes = new HashSet<TreeNode>();
  for (Tree sourceTree : sourceTrees) {
    for (TreeNode treeNode : sourceTree.vertices()) {
      if (treeNode.isInnerNode() && treeNode != sourceTree.getRoot()) {
        Set<String> sourceLeafLabels = getLeafLabels(treeNode);
        Set<TreeNode> superLeafes = getLeafesFromLabels(sourceLeafLabels, tree);
        TreeNode lca = tree.findLeastCommonAncestor(new ArrayList<TreeNode>(superLeafes));
        Set<String> superLeafLabels = getLeafLabels(lca);
        if (!sourceLeafLabels.equals(superLeafLabels)) {
          deletedNodes.add(treeNode);
        }
      }
    }
  }
  double costs = 0;
  for (TreeNode deletedNode : deletedNodes) {
    costs += deletedNode.getDistanceToParent();
  }
  return costs;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

/**
 * Removes al inner vertices on the tree and sets branch length to 1
 * the given tree is modified
 *
 * @param tree the source tree
 */
public static void cleanTree(Tree tree) {
  for (TreeNode node : tree.getRoot().depthFirstIterator()) {
    if (!node.equals(tree.getRoot()))
      node.getEdgeToParent().setWeight(1d);
    if (node.isInnerNode())
      node.setLabel(null);
  }
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

public static void reorderingBootstrapLabelsForRooting(Edge<TreeNode> edgeToReroot) {
  TreeNode outGroup = edgeToReroot.getTarget();
  String startingLabel;
  //reordering inner labels for bootstrap Values
  if (outGroup.isInnerNode()) {
    startingLabel = outGroup.getLabel();
  } else {
    startingLabel = edgeToReroot.getSource().getLabel();
  }
  if (startingLabel != null) {
    moveUP(edgeToReroot, startingLabel);
  }
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

public static Map<Set<String>, TreeNode> getChildrenMap(final Tree tree, final boolean setEdgeweightsToZero) {
  Map<Set<String>, TreeNode> childrenSets = new HashMap<Set<String>, TreeNode>(tree.vertexCount());
  for (TreeNode node : tree.vertices()) {
    if (node.isInnerNode()) {
      if (node != tree.getRoot()) {
        if (setEdgeweightsToZero)
          node.getEdgeToParent().setWeight(0d);
        childrenSets.put(getLeafLabels(node), node);
      }
    } else {
      if (setEdgeweightsToZero)
        node.getEdgeToParent().setWeight(0d);
    }
  }
  return childrenSets;
}
origin: de.unijena.bioinf.phylo/flipcut-core

  public static void addCladewiseSplitFit(List<Tree> sourceTrees, FlipCutWeights.Weights weighting, Collection<Tree> trees) {
    final SimpleCosts comp;
    if (weighting == FlipCutWeights.Weights.UNIT_COST) {
      comp =  new UnitCostComputer(sourceTrees,null);
    } else {
      comp = new WeightCostComputer(sourceTrees,weighting);
    }

    List<WeightedTreePartitions> biparts = new LinkedList<>();
    for (Tree sourceTree : sourceTrees) {
      final TreeNode r = sourceTree.getRoot();
      Set<String> sourceLeafes = getLeafLabels(r);
      for (TreeNode treeNode : sourceTree.getRoot().depthFirstIterator()) {
        if (treeNode != r && treeNode.isInnerNode()) {
          biparts.add(new WeightedTreePartitions(getLeafLabels(treeNode), sourceLeafes, comp.getEdgeWeight(treeNode)));
        }
      }
    }

    for (Tree tree : trees) {
      addCladewiseSplitFit(biparts, tree);
    }
  }
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

public static boolean moveFakeRoot(Tree tree, TreeNode newRoot) {
  if (tree.containsVertex(newRoot) && newRoot.isInnerNode()) {
    TreeNode oldRoot = tree.getRoot();
    TreeNode parent = newRoot.getParent();
    if (parent != null) {
      String label = newRoot.getLabel();
      newRoot.setLabel(null);
      stepUp(tree, newRoot, parent, label);
      tree.setRoot(newRoot);
    }// if not node is already root
  }
  return false;
}
phylo.tree.modelTreeNodeisInnerNode

Javadoc

Returns true if this is not a leaf.

Popular methods of TreeNode

  • <init>
    Create a new node with given label
  • childCount
    Returns the number of children of this node.
  • depthFirstIterator
    Returns a depth first Iterable. This enables iterating the subtree rooted at this node in post order
  • getLabel
    The label of this node. If the label is not set, this looks for a label property TreeNodeProperties#
  • getParent
    Return the parent of this node.
  • isLeaf
    Returns true if this node is a leaf.
  • children
    Returns an Iterable over all children of this node. This allow using nodes in foreach loop: for(Tre
  • getChildren
    Get a list of all children of this node. It is helpful if one wants to iterate over all children and
  • getEdgeToParent
    Return the edge to the parent node or null.
  • getLevel
    Lazy and one time computation of the level of this node.
  • getDistanceToParent
    Returns the distance to the parent node. If the node has no parent (root node ) -1 is returned.
  • getLeaves
    Returns the leaves under this node in depths first traversal order.
  • getDistanceToParent,
  • getLeaves,
  • setLabel,
  • cloneNode,
  • equalsNode,
  • getChildAt,
  • getGraph,
  • getIndex,
  • getPartition

Popular in Java

  • Reading from database using SQL prepared statement
  • onRequestPermissionsResult (Fragment)
  • getSupportFragmentManager (FragmentActivity)
  • getExternalFilesDir (Context)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now