Tabnine Logo
TreeUtils.getLeafLabels
Code IndexAdd Tabnine to your IDE (free)

How to use
getLeafLabels
method
in
phylo.tree.model.TreeUtils

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

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

/**
 * The number of labels of all leafs in the input trees
 *
 * @param trees tree to get leafs from
 * @return number of leafs in this list of trees
 */
public static int getLeafCount(List<Tree> trees) {
  return getLeafLabels(trees).size();
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

/**
 * The set of labels of all leafs in the input trees
 *
 * @param trees tree to get leafs from
 * @return The Set of leaf labels
 */
public static Set<String> getLeafLabels(List<Tree> trees) {
  Set<String> leafs = new HashSet<>();
  for (Tree tree : trees) {
    leafs.addAll(getLeafLabels(tree));
  }
  return leafs;
}
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

/**
 * The set of labels of all leafs in the input tree
 *
 * @param tree tree to get leafs from
 * @return The Set of leaf labels
 */
public static Set<String> getLeafLabels(Tree tree) {
  return getLeafLabels(tree.getRoot());
}
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.utils

public static boolean treeEquals(Tree t1, Tree t2) {
  if (t1.equals(t2))
    return true;
  if (t1.vertexCount() != t2.vertexCount())
    return false;
  Set<String> l1 = TreeUtils.getLeafLabels(t1.getRoot());
  Set<String> l2 = TreeUtils.getLeafLabels(t2.getRoot());
  if (!l1.equals(l2))
    return false;
  double[] rates = FN_FP_RateComputer.calculateRates(t1, t2, false);
  if (rates[2] == 0d && rates[3] == 0d) {
    return true;
  }
  return false;
}
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.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));
  Set<String> allLabels = TreeUtils.getLeafLabels(tree.getRoot());
        p1 = TreeUtils.getLeafLabels(node);
      } else {
        p1 = new HashSet<>(1);
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.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));
  Set<String> allLabels = TreeUtils.getLeafLabels(tree.getRoot());
        Set<String> clade = TreeUtils.getLeafLabels(child);
        if (splitsCopy.contains(clade))
          splitsCopy.remove(clade);
        clade.removeAll(TreeUtils.getLeafLabels(node));
        if (splitsCopy.contains(clade))
          splitsCopy.remove(clade);
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

  rootEdges.add(TreeUtils.getLeafLabels(child));
Set<String> allLabels = TreeUtils.getLeafLabels(tree.getRoot());
boolean newRootFound = false;
      Set<String> p1;
      if (node.isInnerNode()) {
        p1 = TreeUtils.getLeafLabels(node);
      } else {
        p1 = new HashSet<String>(1);
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

  rootEdge.add(TreeUtils.getLeafLabels(child));
Set<String> allLabels = TreeUtils.getLeafLabels(tree.getRoot());
boolean newRootFound = false;
    Set<String> p1;
    if (node.isInnerNode()) {
      p1 = TreeUtils.getLeafLabels(node);
    } else {
      p1 = new HashSet<String>(1);
origin: de.unijena.bioinf.phylo/phyloTree-lib.model

Set<String> characterTaxa = getLeafLabels(character);
Tree sourceTree = (Tree) character.getGraph();
TreeNode[] sourceTreeTaxa = sourceTree.getLeaves();
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 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/gscm-lib

if (!sibling.equals(node)) {
  numOfSiblings++;
  siblingLeaves.addAll(TreeUtils.getLeafLabels(sibling));
origin: de.unijena.bioinf.phylo/phyloTree-lib.utils

Set<String> clade = TreeUtils.getLeafLabels(node);
if (clade.size() > 2 && (numTaxa - clade.size()) > 2) {
origin: de.unijena.bioinf.phylo/gscm-lib

if (singleTaxon.numOfSiblings == 1) {
  Set<String> s = new THashSet<>(TreeUtils.getLeafLabels(lca));
  s.retainAll(commonLeafes);
  Set<String> s2 = new HashSet<>(singleTaxon.siblingLeaves);
phylo.tree.modelTreeUtilsgetLeafLabels

Javadoc

The set of labels of all leafs in the input trees

Popular methods of TreeUtils

  • pruneDegreeOneNodes
  • commonLeaves
    Returns the list of leaves contained in all trees
  • deleteInnerLabels
    Clones all trees and removes all innter vertex labels from the clones. The given source trees are no
  • getChildrenMap
  • pruneInnerNode
    Deletes the specified node from the tree.The child of this node becomes child of its parent. If the
  • removeSubtreeFromTree
  • reorderingBootstrapLabelsForRooting
  • rerootToOutgroup
    Reroot tree with the new root placed at the incomming edge of the given outgroup
  • addLeafesFromChildren
  • buildFitchUnion
  • calculateTreeResolution
  • checkForChilds
  • calculateTreeResolution,
  • checkForChilds,
  • cloneAndPruneTrees,
  • connectParent,
  • containsInnerLabels,
  • deleteRootNode,
  • findAndMergeDuplicates,
  • flipLeaves,
  • getLeafesFromLabels

Popular in Java

  • Reading from database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • compareTo (BigDecimal)
  • requestLocationUpdates (LocationManager)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Top PhpStorm 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