void treeoutr(node *p, long *col, tree *curtree) { /* write out file with representation of final tree. * Rooted case. Used in kitsch and neighbor. */ long i, n, w; Phylip_Char c; double x; if (p->tip) { n = 0; for (i = 1; i <= nmlngth; i++) { if (nayme[p->index - 1][i - 1] != ' ') n = i; } for (i = 0; i < n; i++) { c = nayme[p->index - 1][i]; if (c == ' ') c = '_'; putc(c, outtree); } (*col) += n; } else { putc('(', outtree); (*col)++; treeoutr(p->next->back,col,curtree); putc(',', outtree); (*col)++; if ((*col) > 55) { putc('\n', outtree); (*col) = 0; } treeoutr(p->next->next->back,col,curtree); putc(')', outtree); (*col)++; } x = p->v; if (x > 0.0) w = (long)(0.43429448222 * log(x)); else if (x == 0.0) w = 0; else w = (long)(0.43429448222 * log(-x)) + 1; if (w < 0) w = 0; if (p == curtree->root) fprintf(outtree, ";\n"); else { // HACK: format using Qt instead of ":%*.5f" which uses system locale radix sign, which can be "," QString number = QString("%1").arg(x, (int)(w + 7), 'f', 5); fprintf(outtree, ":%s", number.toStdString().c_str()); (*col) += w + 8; } } /* treeoutr */
void treeoutr(node *p, long *col, tree *curtree) { /* write out file with representation of final tree. * Rooted case. Used in kitsch and neighbor. */ long i, n, w; Char c; double x; if (p->tip) { n = 0; for (i = 1; i <= nmlngth; i++) { if (nayme[p->index - 1][i - 1] != ' ') n = i; } for (i = 0; i < n; i++) { c = nayme[p->index - 1][i]; if (c == ' ') c = '_'; putc(c, outtree); } (*col) += n; } else { putc('(', outtree); (*col)++; treeoutr(p->next->back,col,curtree); putc(',', outtree); (*col)++; if ((*col) > 55) { putc('\n', outtree); (*col) = 0; } treeoutr(p->next->next->back,col,curtree); putc(')', outtree); (*col)++; } x = p->v; if (x > 0.0) w = (long)(0.43429448222 * log(x)); else if (x == 0.0) w = 0; else w = (long)(0.43429448222 * log(-x)) + 1; if (w < 0) w = 0; if (p == curtree->root) fprintf(outtree, ";\n"); else { fprintf(outtree, ":%*.5f", (int)(w + 7), x); (*col) += w + 8; } } /* treeoutr */
void maketree() { /* construct the tree */ long i ; inputdata(replicates, printdata, lower, upper, x, reps); /* if (njoin && (spp < 3)) { mexPrintf("\nERROR: Neighbor-Joining runs must have at least 3 species\n\n"); exxit(-1); } */ if (progress) putchar('\n'); if (ith == 1) setuptree(&curtree, nonodes2 + 1); for (i = 1; i <= spp; i++) enterorder[i - 1] = i; if (jumble) randumize(seed, enterorder); for (i = 0; i < spp; i++) cluster[i] = curtree.nodep[i]; jointree(); if (njoin) curtree.start = curtree.nodep[outgrno - 1]->back; printree(curtree.start, treeprint, njoin, (boolean)(!njoin)); if (treeprint) summarize(); if (trout) { col = 0; if (njoin) treeout(curtree.start, &col, 0.43429448222, njoin, curtree.start); else curtree.root = curtree.start, treeoutr(curtree.start,&col,&curtree); } if (progress) { mexPrintf("\nOutput written on file \"%s\"\n\n", outfilename); if (trout) mexPrintf("Tree written on file \"%s\"\n\n", outtreename); } } /* maketree */
void maketree() { /* construct the tree */ long i ; inputdata(replicates, printdata, lower, upper, x, reps); if (progress) putchar('\n'); if (ith == 1) setuptree(&curtree, nonodes2 + 1); for (i = 1; i <= spp; i++) enterorder[i - 1] = i; if (jumble) randumize(seed, enterorder); for (i = 0; i < spp; i++) cluster[i] = curtree.nodep[i]; jointree(); if (outgropt) curtree.start = curtree.nodep[outgrno - 1]->back; printree(&curtree, curtree.start->next, treeprint, njoin, !njoin); if (treeprint) summarize(); if (trout) { col = 0; if (njoin) treeout(curtree.start, &col, 0.43429448222, njoin, curtree.start); else curtree.root = curtree.start, treeoutr(curtree.start,&col,&curtree); } if (progress) { printf("\nOutput written on output file\n\n"); if (trout) printf("Tree written on tree file\n\n"); } } /* maketree */