String pioTreeAsText() {
    String header =
        "topology             height         union         nlin coalheights"
            + System.getProperty("line.separator");

    String s = "";
    Stack<Integer> x = new Stack<Integer>();
    return header + subtreeAsText(pionodes[rootn], s, x, 0, "");
  }
 public String toString() {
   int ngt = piosb.numberOfGeneTrees();
   String nl = System.getProperty("line.separator");
   String s = nl + pioTreeAsText() + nl;
   for (int g = 0; g < ngt; g++) {
     s += "Gene tree " + g + nl;
     s += piosb.genetreeAsText(g) + nl;
   }
   s += nl;
   return s;
 }
 private String subtreeAsText(PopsIONode node, String s, Stack<Integer> x, int depth, String b) {
   Integer[] y = x.toArray(new Integer[x.size()]);
   StringBuffer indent = new StringBuffer();
   for (int i = 0; i < depth; i++) {
     indent.append("  ");
   }
   for (int i = 0; i < y.length; i++) {
     indent.replace(2 * y[i], 2 * y[i] + 1, "|");
   }
   if (b.length() > 0) {
     indent.replace(indent.length() - b.length(), indent.length(), b);
   }
   s += indent;
   s += node.asText(indent.length());
   s += System.getProperty("line.separator");
   String subs = "";
   if (node.lft >= 0) {
     x.push(depth);
     subs += subtreeAsText(pionodes[node.lft], "", x, depth + 1, "-");
     x.pop();
     subs += subtreeAsText(pionodes[node.rgt], "", x, depth + 1, "`-");
   }
   return s + subs;
 }