06d7be056190c14b85e71bc12523f18ea6815b5e markd Mon Dec 7 00:50:29 2020 -0800 BLAT mmap index support merge with master diff --git src/lib/phyloTree.c src/lib/phyloTree.c index cf25448..ea3c5ad 100644 --- src/lib/phyloTree.c +++ src/lib/phyloTree.c @@ -179,31 +179,31 @@ do { struct phyloTree *child = parseSubTree(&ptr); if (!child) errAbort("missing child/subTree at (%s)",ptr-1); edge = newEdge(node,child); edge->parent = node; } while (*ptr++ == ','); --ptr; if (*ptr++ != ')') errAbort("unbalanced parenthesis at (%s)",ptr-1); node->ident = parseIdent(&ptr); } else - if ((*ptr == ':') || (isalpha(*ptr))|| (isdigit(*ptr)) + if ((*ptr == ':') || (isalpha(*ptr))|| (isdigit(*ptr)) || (*ptr == '_') || (*ptr == '\'') || (*ptr == '.')) node->ident = parseIdent(&ptr); else errAbort("illegal char '%c' in phyloString",*ptr); if (*ptr == '[') { if (startsWith("[&&NHX:D=Y]",ptr)) node->isDup = TRUE; while(*ptr != ']') ptr++; ptr++; @@ -484,15 +484,29 @@ errAbort("tried to delete non-existant edge"); } int phyloCountLeaves(struct phyloTree *tree) { int ii, count = 0; if (tree->numEdges == 0) return 1; for (ii=0; ii < tree->numEdges; ii++) count += phyloCountLeaves(tree->edges[ii]); return count; } + +int phyloCountInternalNodes(struct phyloTree *node) +/* Return the number of internal nodes (not leaf nodes) in tree. */ +{ +int count = 0; +if (node->numEdges > 0) + { + count = 1; + int ii; + for (ii = 0; ii < node->numEdges; ii++) + count += phyloCountInternalNodes(node->edges[ii]); + } +return count; +}