Example #1
0
string write_with_bootstrap_fraction(const vector<string>& names, const_branchview b, 
				     const vector<double>& bf, bool print_lengths)
{
  string output;

  // If this is a leaf node, then print the name
  if (b.target().is_leaf_node())
    output += names[b.target()];
  // If this is an internal node, then print the subtrees
  else {
    vector<const_branchview> branches = sorted_branches_after(b);
    output = "(";
    for(int i=0;i<branches.size();i++) {
      output += write_with_bootstrap_fraction(names,branches[i],bf,print_lengths);

      if (i+1<branches.size())
	output += ",";
    }
    output += ")";
  }

  // print the branch length if requested
  double bfb = bf[b.undirected_name()];
  if (bfb >= 0)
    output += " " + convertToString<double>(bf[b.undirected_name()]);

  if (print_lengths)
    output += ":" + convertToString(b.length());
  else if (bfb >= 0)
    output += ":1.0";

  return output;
}
Example #2
0
string write_no_names(const_branchview b, bool print_lengths)
{
  string output;

  // If this is a leaf node, then print the name
  if (b.target().is_leaf_node())
    output += convertToString(b.target().name()+1);
  // If this is an internal node, then print the subtrees
  else {
    vector<const_branchview> branches = sorted_branches_after(b);
    output = "(";
    for(int i=0;i<branches.size();i++) {
      output += write_no_names(branches[i],print_lengths);

      if (i+1<branches.size())
	output += ",";
    }
    output += ")";
  }

  // print the branch length if requested
  if (print_lengths)
    output += ":" + convertToString(b.length());

  return output;
}
Example #3
0
vector<const_branchview> randomized_branches_after(const const_branchview& b)
{
  vector<const_branchview> branches;
  append(b.branches_after(), branches);
  sort(branches.begin(), branches.end());
  return randomize(branches);
}
Example #4
0
vector<const_branchview> sorted_branches_after(const_branchview b) {
  vector<const_branchview> branches;
  append(b.branches_after(),branches);

  std::sort(branches.begin(),branches.end(),branch_order);

  return branches;
}
Example #5
0
bool branch_order(const const_branchview& b1,const const_branchview& b2) {
    return b1.target().name() < b2.target().name();
}