congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
TreeNode.childCount
Code IndexAdd Tabnine to your IDE (free)

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

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

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

public static Tree findMostCompatibleRootToScaffoldTree(Tree inputTree, Tree model) {
  List<Tree> bothTrees = new ArrayList<>(Arrays.asList(TreeUtils.cloneAndPruneTrees(new Tree[]{inputTree, model})));
  Tree tree = bothTrees.get(0);
  Tree prunedModel = bothTrees.get(1);
  if (bothTrees.size() < 2) {
    if (TreeUtils.VERBOSE_ROOTING) {
      System.out.println("[RerootByModelTree] Rooting by Modeltree not possible for tree: " + tree.getName() + " because trees have no overlapping taxa!");
    }
    return null;
  }
  if (prunedModel.getRoot().childCount() == 2) {
    findMostCompatibleRoot(tree, prunedModel);
  } else {
    findMostCompatibleFakeRoot(tree, prunedModel);
  }
  return tree;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

private static void removePolytomies(Tree tree, Comparator<TreeNode> comp) {
  tree.getRoot().depthFirstIterator().forEach(node -> {
    int toRemove = node.childCount() - 2;
    if (toRemove > 0) {
      ArrayList<TreeNode> children = node.getChildren();
      sortChildren(children, comp);
      for (int i = 0; i < toRemove; i++) {
        TreeNode remove = children.get(i);
        tree.removeSubtree(remove);
      }
    }
  });
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

private void checkBinaryClade(TreeNode cladeToCheck, Tree supertree, Set<Object> parentTaxa, Map<Set<Object>, TreeNode> partition, Map<TreeNode, Set<Object>> leafMap) {
  Set<Set<Object>> supported = new HashSet<>(cladeToCheck.childCount());
  for (PPCharacter ppCharacter : ppSet) {
    if (cladeToCheck.childCount() < 2) {
      if (cladeToCheck.childCount() == 0) {
        supertree.removeVertex(cladeToCheck);
      } else {
origin: de.unijena.bioinf.phylo/flipcut-core

TreeNode node = scaffoldCharacterMapping.get(character);
if (node != null) {
  Set<N> toInsert = new HashSet(node.childCount());
  for (TreeNode child : node.getChildren()) {
    if (child.isInnerNode()) {
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.utils

private static int findMostCompatibleRoot(Tree tree, Tree prunedModel) {
  List<Set<String>> rootEdges = new ArrayList<>(prunedModel.getRoot().childCount()); //should be 2 otherwise method will not work
  for (TreeNode child : prunedModel.getRoot().getChildren()) {
    rootEdges.add(TreeUtils.getLeafLabels(child));
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

Set<Object> cladeTaxa = leafMap.get(cladeToCheck);
Map<Set<Object>, TreeNode> partition = new HashMap<>(cladeToCheck.childCount());
for (TreeNode child : cladeToCheck.getChildren()) {
  if (child.isInnerNode()) {
if (parent.childCount() > 2) {
  Collection<TreeNode> toRemove = checkNonBinaryClade(parent, supertree, leafMap);
  innerNodes.removeAll(toRemove);
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

List<Set<String>> rootEdge = new ArrayList<Set<String>>(prunedModel.getRoot().childCount());
for (TreeNode child : prunedModel.getRoot().getChildren()) {
  rootEdge.add(TreeUtils.getLeafLabels(child));
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

private static int findMostCompatibleFakeRoot(Tree tree, Tree prunedModel) {
  List<Set<String>> rootEdges = new ArrayList<>(prunedModel.getRoot().childCount()); //should be >2 otherwise use the real root method
  for (TreeNode child : prunedModel.getRoot().getChildren()) {
    rootEdges.add(TreeUtils.getLeafLabels(child));
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

List<Set<String>> rootEdges = new ArrayList<Set<String>>(prunedModel.getRoot().childCount());
for (TreeNode child : prunedModel.getRoot().getChildren()) {
  rootEdges.add(TreeUtils.getLeafLabels(child));
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

/**
 * Computes the number of the given child for this node.
 * This number is 0 {@literal <=} childNum {@literal <} 'number of children', if the child is a real child of this node.
 * It is childNum = 'number of children', if the given child is parent of this node.
 *
 * @param child: the child, for that its number has to be computed
 * @return the child number for the  given node
 */
public int getChildNumber(TreeNode child) {
  if (this.getParent().equalsNode(child)) {
    return childCount();
  } else if (child.isChildOf(this)) {
    int num = 0;
    for (TreeNode nodesChild : this.children()) {
      if (!nodesChild.equalsNode(child)) {
        num++;
      } else {
        break;
      }
    }
    return num;
  } else {
    throw new RuntimeException("Given child is no child of this node!");
  }
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

TreeNode root = (TreeNode) t.getRoot();
pruneTraverse(nt, root, null, labels);
if (nt.vertexCount() > 0 && ((TreeNode) nt.getRoot()).childCount() > 0) {
  newTrees.add(nt);
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

Tree[] forRooting = TreeUtils.cloneAndPruneTrees(new Tree[]{tree, rootedModel});
if (forRooting[1].getRoot().childCount() == 2) {
  sumOfErrorScores += findMostCompatibleRoot(forRooting[0], forRooting[1]);
} else {
origin: de.unijena.bioinf.phylo/gscm-lib

final int childCount = node.childCount();
List<TreeNode> children = new ArrayList<>(childCount);
for (TreeNode child : node.children()) {
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

  cc += taxonCounter.get(treeNode);
if (cc == node.childCount()) {
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.utils

double damage_per_child = parent_score / n.childCount();
origin: de.unijena.bioinf.phylo/phyloTree-lib.consensus

Partition[] childPartitions = new Partition[treeNodes[i].childCount()];
int z = 0;
for (TreeNode n : treeNodes[i].children()) {
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

if (node.isInnerNode() && node.childCount() == 1) {
  TreeNode child = node.getChildAt(0);
  TreeNode parent = node.getParent();
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

if (newNode.childCount() == 0) {
  t.removeVertex(newNode);
} else if (newNode.childCount() == 1) {
  TreeNode child = newNode.getChildAt(0);
  t.removeVertex(newNode);
phylo.tree.modelTreeNodechildCount

Javadoc

Returns the number of children of this node.

Popular methods of TreeNode

  • <init>
    Create a new node with given label
  • 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.
  • isInnerNode
    Returns true if this is not a leaf.
  • 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

  • Updating database using SQL prepared statement
  • getSharedPreferences (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • onRequestPermissionsResult (Fragment)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Top 17 Plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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