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

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

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

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

private static void setLabel(TreeNode n, StringBuffer label, StringBuffer nhxB) {
  if (nhxB.length() > 0) {
    String nhx = nhxB.substring(6);
    String[] tags = nhx.split(":");
    HashMap<String, String> extLabel = new HashMap<String, String>();
    for (int k = 0; k < tags.length; k++) {
      String[] nameValue = tags[k].split("=");
      extLabel.put(nameValue[0], nameValue[1]);
    }
    createTaxonInfo(n, extLabel);
  }
  String l = label.toString();
  l = l.trim();
  if (l.length() > 0) {
    n.setLabel(l);
  }
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.consensus

/**
 * If not done allready, this creates a new TreeNode 
 * representing this bipartiton. This is used to create 
 * the consensus tree in the NConsensus Algorithm
 * 
 * @param tree the Tree for the node
 * @return TreeNode the node
 */
public TreeNode getNode(Tree tree, double count) {
  if(node == null){
    node = new TreeNode();
    tree.addVertex(node);
    if(label != null)
      node.setLabel(label);
    else if (count >= 0d)
      node.setLabel(Double.toString(count));
  }
  return node;		
}
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.model

/**
 * replaces all '_' with a space
 *
 * @param tree the tree
 */
public static void cleanLabels(Tree tree) {
  for (TreeNode n : tree.vertices()) {
    String label = n.getLabel();
    if (label != null && label.length() > 0) {
      label = label.trim();
      label = label.replaceAll("_", " ");
      n.setLabel(label);
    }
  }
}
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.utils

public static Tree addCladewiseSplitFit(List<WeightedTreePartitions> biparts, Tree tree) {
  Map<Set<String>, TreeNode> labelsToClade = getChildrenMap(tree);
  Set<String> all = getLeafLabels(tree);
  Map<WeightedTreePartitions, AtomicDouble> partitionsToConflicts = new HashMap<>(labelsToClade.size());
  for (Set<String> leafesInClade : labelsToClade.keySet()) {
    partitionsToConflicts.put(new WeightedTreePartitions(leafesInClade, all), new AtomicDouble(0));
  }
  double numberOfChars = 0;
  for (WeightedTreePartitions sourcePartition : biparts) {
    numberOfChars += sourcePartition.weight;
    for (Map.Entry<WeightedTreePartitions, AtomicDouble> e : partitionsToConflicts.entrySet()) {
      if (e.getKey().isIncompatible(sourcePartition)) {
        e.getValue().addAndGet(e.getKey().weight);
      }
    }
  }
  for (Map.Entry<WeightedTreePartitions, AtomicDouble> entry : partitionsToConflicts.entrySet()) {
    TreeNode first = labelsToClade.remove(entry.getKey().getGroupA());
    TreeNode second = labelsToClade.remove(entry.getKey().getGroupB());
    String l = String.valueOf(1 - (entry.getValue().doubleValue() / numberOfChars));
    if (first != null)
      first.setLabel(l);
    if (second != null)
      second.setLabel(l);
  }
  return tree;
}
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

/**
 * Clones this node.
 *
 * @return node the new node
 */
public TreeNode cloneNode() {
  TreeNode n = new TreeNode();
  n.setLabel(getLabel());
  n.setIndex(getIndex());
  return n;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

label = n.getLabel();
if (translateMap != null && translateMap.get(label) != null) {
  n.setLabel(translateMap.get(label));
} else if (intMap != null && intMap.get(label) != null) {
  n.setLabel(intMap.get(label));
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

/**
 * Creates a copy of the given tree and renames all vertices according to the translation table.
 * If strict pattersn is set, all source names are translated to valid nexus taxon names.
 *
 * @param tree           the source tree
 * @param translation    the translation table
 * @param strictPatterns use only valid nexus taxon names
 * @return tree translated tree
 */
public static Tree renameNodes(Tree tree, Map<String, String> translation, boolean strictPatterns) {
  Tree t = tree.cloneTree();
  for (TreeNode node : t.vertices()) {
    if (node.getLabel() != null) {
      String newName = null;
      if (strictPatterns)
        newName = translation.get(NexusTaxaBlock.translate(node.getLabel()));
      else {
        newName = translation.get(node.getLabel());
      }
      if (newName != null) {
        node.setLabel(newName);
      }
    }
  }
  return t;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

private static void moveUP(Edge<TreeNode> edgeForLabelMove, String label) {
  String newLabel = edgeForLabelMove.getSource().getLabel();
  edgeForLabelMove.getSource().setLabel(label);
  if (newLabel != null)
    moveUP(edgeForLabelMove.getSource().getEdgeToParent(), newLabel);
}
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;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

private static void stepUp(Tree tree, TreeNode child, TreeNode parent, String oldChildLabel) {
  TreeNode newParent = parent.getParent();
  String newOldLabel = parent.getLabel();
  double weight = child.getDistanceToParent();
  tree.removeEdge(parent, child);
  tree.addEdge(child, parent).setWeight(weight);
  parent.setLabel(oldChildLabel);
  if (newParent != null) {
    stepUp(tree, parent, newParent, newOldLabel);
  }
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

newNode.setLabel(n.getLabel());
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

root.setLabel(null);
tree.addVertex(old);
tree.addEdge(root, old);
phylo.tree.modelTreeNodesetLabel

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.
  • 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.
  • getLevel,
  • getDistanceToParent,
  • getLeaves,
  • cloneNode,
  • equalsNode,
  • getChildAt,
  • getGraph,
  • getIndex,
  • getPartition

Popular in Java

  • Creating JSON documents from java classes using gson
  • addToBackStack (FragmentTransaction)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • onRequestPermissionsResult (Fragment)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Socket (java.net)
    Provides a client-side TCP socket.
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • CodeWhisperer alternatives
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