diminuto_list_t * diminuto_list_cut( diminuto_list_t * firstp, diminuto_list_t * lastp ) { if (firstp->root != lastp->root) { /* Do nothing. */ } else if (firstp->prev == lastp) { /* Do nothing. */ } else if (firstp == lastp) { diminuto_list_remove(firstp); } else { diminuto_list_t * nodep = firstp->prev; do { nodep = nodep->next; if (nodep == firstp->root) { reroot(lastp->next, firstp->prev, lastp->next); break; } } while (nodep != lastp); firstp->prev->next = lastp->next; lastp->next->prev = firstp->prev; firstp->prev = lastp; lastp->next = firstp; reroot(firstp, lastp, firstp); } return firstp; }
url reroot (url u, string protocol) { if (is_concat (u)) return reroot (u[1], protocol) * u[2]; if (is_or (u)) return reroot (u[1], protocol) | reroot (u[2], protocol); if (is_root (u)) return url_root (protocol); return u; }
void process_tree(struct rooted_tree *tree, struct parameters params) { struct llist *outgroup_nodes = get_outgroup_nodes(tree, params.labels); if (! params.deroot) { /* re-root according to outgroup nodes */ enum reroot_status result = reroot(tree, outgroup_nodes, params.i_node_lbl_as_support); switch (result) { case REROOT_OK: dump_newick(tree->root); break; case LCA_IS_TREE_ROOT: if (params.try_ingroup) try_ingroup(tree, params); else { fprintf (stderr, "ERROR: Outgroup's LCA is tree's root " "- cannot reroot. Try -l.\n"); } break; case NOT_PHYLOGRAM: fprintf (stderr, "ERROR: Tree must be a phylogram, but some " "branch lengths are not defined - aborting.\n"); break; default: assert(0); } destroy_all_rnodes(NULL); destroy_tree(tree); } else { enum deroot_status result = deroot(tree); switch (result) { case DEROOT_OK: dump_newick(tree->root); break; case NOT_BIFURCATING: fprintf (stderr, "ERROR: tree is already unrooted, or root" " has only 1 child - cannot deroot.\n"); break; case BALANCED: fprintf (stderr, "ERROR: can't decide which of root's " "children is the outgroup.\n"); break; case MEM_PROB: perror(NULL); break; default: assert(0); } destroy_all_rnodes(NULL); destroy_tree(tree); } destroy_llist(outgroup_nodes); }
diminuto_list_t * diminuto_list_remove( diminuto_list_t * nodep ) { if (nodep != nodep->next) { if (nodep == nodep->root) { reroot(nodep->next, nodep->prev, nodep->next); } nodep->next->prev = nodep->prev; nodep->prev->next = nodep->next; diminuto_list_init(nodep); } return nodep; }
void buildtree() { long i, j, nextnode; node *p; changed = false; newtree = false; switch (how) { case arb: arbitree(); break; case use: /* Open in binary: ftell() is broken for UNIX line-endings under WIN32 */ openfile(&intree,INTREE,"input tree file", "rb",progname,intreename); names = (boolean *)Malloc(spp*sizeof(boolean)); firsttree = true; /**/ nodep = NULL; /**/ nextnode = 0; /**/ haslengths = 0; /**/ zeros = (long *)Malloc(chars*sizeof(long)); /**/ for (i = 0; i < chars; i++) /**/ zeros[i] = 0; /**/ treeread(intree, &root, treenode, &goteof, &firsttree, nodep, &nextnode, &haslengths, &grbg, initdolmovenode,false,nonodes); for (i = spp; i < (nonodes); i++) { p = treenode[i]; for (j = 1; j <= 3; j++) { p->stateone = (bitptr)Malloc(words*sizeof(long)); p->statezero = (bitptr)Malloc(words*sizeof(long)); p = p->next; } } /* debug: see comment at initdolmovenode() */ /*treeread(which, ch, &root, treenode, names);*/ for (i = 0; i < (spp); i++) in_tree[i] = names[i]; free(names); FClose(intree); break; case spec: yourtree(); break; } outgrno = root->next->back->index; if (in_tree[outgrno - 1]) reroot(treenode[outgrno - 1]); } /* buildtree */
tree evaluate_find_file (tree t) { int i, n=N(t); array<tree> r (n); for (i=0; i<n; i++) { r[i]= evaluate (t[i]); if (is_compound (r[i])) return evaluate_error ("bad find file"); } for (i=0; i<(n-1); i++) { url u= resolve (url (r[i]->label, r[n-1]->label)); if (!is_none (u)) { if (is_rooted (u, "default")) u= reroot (u, "file"); return as_string (u); } } url base_file_name (as_string (std_env["base-file-name"])); url u= resolve (base_file_name * url_parent () * r[n-1]->label); if (!is_none (u)) { if (is_rooted (u, "default")) u= reroot (u, "file"); return as_string (u); } return "false"; }
diminuto_list_t * diminuto_list_splice( diminuto_list_t * top, diminuto_list_t * fromp ) { if (fromp->root == top->root) { /* Do nothing. */ } else if (fromp == fromp->next) { diminuto_list_insert(top, fromp); } else { reroot(fromp, fromp->prev, top->root); fromp->prev->next = top->next; top->next->prev = fromp->prev; top->next = fromp; fromp->prev = top; } return fromp; }
void process_tree(struct rooted_tree *tree, struct parameters params) { struct llist *outgroup_nodes = get_outgroup_nodes(tree, params.labels); if (! params.deroot) { /* re-root according to outgroup nodes */ enum reroot_status result = reroot(tree, outgroup_nodes); switch (result) { case REROOT_OK: dump_newick(tree->root); break; case LCA_IS_TREE_ROOT: if (params.try_ingroup) try_ingroup(tree, params); else { fprintf (stderr, "Outgroup's LCA is tree's root " "- cannot reroot. Try -l.\n"); } break; default: assert(0); } destroy_tree_cb(tree, NULL); } else { enum deroot_status result = deroot(tree); switch (result) { case DEROOT_OK: dump_newick(tree->root); break; case NOT_BIFURCATING: fprintf (stderr, "WARNING: tree is already unrooted, or root" " has only 1 child - cannot deroot.\n"); break; case BALANCED: fprintf (stderr, "WARNING: can't decide which of root's " "children is the outgroup.\n"); break; default: assert(0); } destroy_tree_cb(tree, NULL); } destroy_llist(outgroup_nodes); }
string concretize (url u) { // This routine transforms a resolved url into a system file name. // In the case of distant files from the web, a local copy is created. if (is_rooted (u, "default") || is_rooted (u, "file") || is_rooted (u, "blank")) return as_string (reroot (u, "default")); if (is_rooted_web (u)) return concretize (get_from_web (u)); if (is_rooted_tmfs (u)) return concretize (get_from_server (u)); if (is_ramdisc (u)) return concretize (get_from_ramdisc (u)); if (is_here (u)) return as_string (url_pwd ()); if (is_parent (u)) return as_string (url_pwd () * url_parent ()); if (is_wildcard (u, 1)) return u->t[1]->label; std_warning << "Couldn't concretize " << u->t << LF; // failed_error << "u= " << u << LF; // FAILED ("url has no root"); return "xxx"; }
void try_ingroup(struct rooted_tree *tree, struct parameters params) { /* we will try to insert the root above the ingroup - for this we'll * need all leaves that are NOT in the outgroup. */ // TODO: why just leaves? struct llist *ingroup_leaves; ingroup_leaves = get_ingroup_leaves(tree, params.labels); enum reroot_status result = reroot(tree, ingroup_leaves); switch (result) { case REROOT_OK: dump_newick(tree->root); break; case LCA_IS_TREE_ROOT: fprintf (stderr, "LCA is still tree's root " "- be sure to include ALL outgroup " "leaves with -l"); break; } destroy_llist(ingroup_leaves); }
void try_ingroup(struct rooted_tree *tree, struct parameters params) { /* we will try to insert the root above the ingroup - for this we'll * need all leaves that are NOT in the outgroup. We don't need the * inner nodes, though, since tha leaves are sufficient for determining * the ingroup's LCA. This also works if some leaf labels are empty * (see test case 'nolbl_ingrp' in test_nw_reroot_args) */ struct llist *ingroup_leaves; ingroup_leaves = get_ingroup_leaves(tree, params.labels); enum reroot_status result = reroot(tree, ingroup_leaves, params.i_node_lbl_as_support); switch (result) { case REROOT_OK: dump_newick(tree->root); break; case LCA_IS_TREE_ROOT: fprintf (stderr, "LCA is still tree's root " "- be sure to include ALL outgroup " "leaves with -l"); break; } destroy_llist(ingroup_leaves); }
url operator * (url u1, url u2) { //cout << "concat " << u1->t << " * " << u2->t << "\n"; if (is_root (u2) || (is_concat (u2) && is_root (u2[1]))) { if (is_concat (u1) && is_root_web (u1[1])) { if (is_root (u2, "default") || (is_concat (u2) && is_root (u2[1], "default"))) { url v= u1[2]; while (is_concat (v)) v= v[1]; if (is_root (u2)) return u1[1] * v; return u1[1] * v * u2[2]; } if (is_root (u2, "blank") || (is_concat (u2) && is_root (u2[1], "blank"))) return reroot (u2, u1[1][1]->t->label); } return u2; } if (is_here (u1) || (u1->t == "")) return u2; if (is_here (u2)) return u1; if (is_none (u1)) return url_none (); if (is_none (u2)) return url_none (); if (u2 == url_parent ()) { if (is_root (u1)) return u1; if (is_pseudo_atomic (u1) && (!is_parent (u1))) return url_here (); if (is_semi_root (u1)) return u1; } if (is_concat (u2) && (u2[1] == url_parent ())) { if (is_root (u1)) return u1 * u2[2]; if (is_pseudo_atomic (u1) && (!is_parent (u1))) return u2[2]; if (is_semi_root (u1)) return u1 * u2[2]; } if (is_concat (u1)) return u1[1] * (u1[2] * u2); return as_url (tuple ("concat", u1->t, u2->t)); }
void tree::insert(key_t key) { if(root->size == range_max) reroot(); root->insert(key); }
sint read_tree(char *treefile, sint first_seq, sint last_seq) { char c; char name1[MAXNAMES+1], name2[MAXNAMES+1]; sint i, j, k; Boolean found; numseq = 0; nnodes = 0; ntotal = 0; rooted_tree = TRUE; #ifdef VMS if ((fd = fopen(treefile,"r","rat=cr","rfm=var")) == NULL) #else if ((fd = fopen(treefile, "r")) == NULL) #endif { error("cannot open %s", treefile); return((sint)0); } skip_space(fd); ch = (char)getc(fd); if (ch != '(') { error("Wrong format in tree file %s", treefile); return((sint)0); } rewind(fd); distance_tree = TRUE; /* Allocate memory for tree */ nptr = (treeptr *)ckalloc(3*(last_seq-first_seq+1) * sizeof(treeptr)); ptrs = (treeptr *)ckalloc(3*(last_seq-first_seq+1) * sizeof(treeptr)); lptr = (treeptr *)ckalloc((last_seq-first_seq+1) * sizeof(treeptr)); olptr = (treeptr *)ckalloc((last_seq+1) * sizeof(treeptr)); seq_tree = avail(); set_info(seq_tree, NULL, 0, "", 0.0); create_tree(seq_tree,NULL); fclose(fd); if (numseq != last_seq-first_seq) { error("tree not compatible with alignment\n(%d sequences in alignment and %d in tree", (pint)last_seq-first_seq,(pint)numseq); return((sint)0); } /* If the tree is unrooted, reroot the tree - ie. minimise the difference between the mean root->leaf distances for the left and right branches of the tree. */ if (distance_tree == FALSE) { if (rooted_tree == FALSE) { error("input tree is unrooted and has no distances.\nCannot align sequences"); return((sint)0); } } if (rooted_tree == FALSE) { root = reroot(seq_tree, last_seq-first_seq+1); } else { root = seq_tree; } /* calculate the 'order' of each node. */ order_nodes(); if (numseq >= 2) { /* If there are more than three sequences.... */ /* assign the sequence nodes (in the same order as in the alignment file) */ for (i=first_seq; i<last_seq; i++) { if (strlen(names[i+1]) > MAXNAMES) warning("name %s is too long for PHYLIP tree format (max %d chars)", names[i+1],MAXNAMES); for (k=0; k< strlen(names[i+1]) && k<MAXNAMES ; k++) { c = names[i+1][k]; if ((c>0x40) && (c<0x5b)) c=c | 0x20; if (c == ' ') c = '_'; name2[k] = c; } name2[k]='\0'; found = FALSE; for (j=0; j<numseq; j++) { for (k=0; k< strlen(lptr[j]->name) && k<MAXNAMES ; k++) { c = lptr[j]->name[k]; if ((c>0x40) && (c<0x5b)) c=c | 0x20; name1[k] = c; } name1[k]='\0'; if (strcmp(name1, name2) == 0) { olptr[i] = lptr[j]; found = TRUE; } } if (found == FALSE) { error("tree not compatible with alignment:\n%s not found", name2); return((sint)0); } } } return((sint)1); }
int main(int argc, char * * argv) { if (argc != 3) { printf("usage: ./proj4 input output\n"); return EXIT_FAILURE; } int index = 0; double x = 0, y=0; // Build binary tree stack * root = loadFile(argv[1], &index); node * head = nodeCreate(root->stackNode->width, root->stackNode->height, root->stackNode->split, root->stackNode->index-1); //= buildTree(root); root = StackPop(root); buildTree(root, head, &head, index); node * tree = NULL; tree = nodeArrange(tree, &head); // Packing clock_t timeStart = clock(); assignCutline(tree); setCoord(tree); clock_t timeEnd = clock(); double packTime = (double) (timeEnd - timeStart) / CLOCKS_PER_SEC; searchNode(tree, &x, &y, 1); //printPostorderFull(tree); //Reset output file and save output FILE * fptr = fopen(argv[2], "w"); saveTree(tree, argv[2]); // Screen dump printf("Preorder: "); printPreorder(tree); printf("\n\nInorder: "); printInorder(tree); printf("\n\nPostorder: "); printPostorder(tree); printf("\n\nWidth: %le", tree->width); printf("\nHeight: %le", tree->height); printf("\n\nX-coordinate: %le", x); printf("\nY-coordinate: %le", y); printf("\n"); // Rerooting box * minBox = malloc(sizeof(box)); minBox->width = tree->width; minBox->height = tree->height; timeStart = clock(); // ------------------------------------ to run cases without rerooting, comment out the following lines while (tree->right->split!='-') { tree = reroot(tree, minBox); decideMin(minBox, tree); //printPostorderFull(tree); } // ------------------------------------ timeEnd = clock(); double rootTime = (double) (timeEnd - timeStart) / CLOCKS_PER_SEC; printf("\nElapsed Time: %le", packTime); printf("\n\nBest width: %le", minBox->width); printf("\nBest height: %le\n", minBox->height); printf("\nElapsed Time for re-routing: %le\n", rootTime); // Free stack while(root!=NULL){ root = StackPop(root); } // Memory management free(root); free(minBox); deleteTree(head); deleteTree(tree); fclose(fptr); return EXIT_SUCCESS; }
diminuto_list_t * diminuto_list_reroot( diminuto_list_t * nodep ) { return reroot(nodep, nodep->prev, nodep); }
url complete (url base, url u, string filter, bool flag) { // cout << "complete " << base << " |||| " << u << LF; if (!is_rooted(u)) { if (is_none (base)) return base; if (is_none (u)) return u; if ((!is_root (base)) && (!is_rooted_name (base))) { failed_error << "base= " << base << LF; FAILED ("invalid base url"); } } if (is_name (u) || (is_concat (u) && is_root (u[1]) && is_name (u[2]))) { url comp= base * u; if (is_rooted (comp, "default") || is_rooted (comp, "file")) { if (is_of_type (comp, filter)) return reroot (u, "default"); return url_none (); } if (is_rooted_web (comp) || is_rooted_tmfs (comp) || is_ramdisc (comp)) { if (is_of_type (comp, filter)) return u; return url_none (); } failed_error << "base= " << base << LF; failed_error << "u= " << u << LF; ASSERT (is_rooted (comp), "unrooted url"); FAILED ("bad protocol in url"); } if (is_root (u)) { // FIXME: test filter flags here return u; } if (is_concat (u) && is_wildcard (u[1], 0) && is_wildcard (u[2], 1)) { // FIXME: ret= ret | ... is unefficient (quadratic) in main loop if (!(is_rooted (base, "default") || is_rooted (base, "file"))) { failed_error << "base= " << base << LF; FAILED ("wildcards only implemented for files"); } url ret= url_none (); bool error_flag; array<string> dir= read_directory (base, error_flag); int i, n= N(dir); for (i=0; i<n; i++) { if ((!is_none (ret)) && flag) return ret; if ((dir[i] == ".") || (dir[i] == "..")) continue; if (starts (dir[i], "http://") || starts (dir[i], "ftp://")) if (is_directory (base * dir[i])) continue; ret= ret | (dir[i] * complete (base * dir[i], u, filter, flag)); if (match_wildcard (dir[i], u[2][1]->t->label)) ret= ret | complete (base, dir[i], filter, flag); } return ret; } if (is_concat (u)) { url sub= complete (base, u[1], "", false); // "" should often be faster than the more correct "d" here return complete (base, sub, u[2], filter, flag); } if (is_or (u)) { url res1= complete (base, u[1], filter, flag); if ((!is_none (res1)) && flag) return res1; return res1 | complete (base, u[2], filter, flag); } if (is_wildcard (u)) { // FIXME: ret= ret | ... is unefficient (quadratic) in main loop if (!(is_rooted (base, "default") || is_rooted (base, "file"))) { failed_error << "base= " << base << LF; FAILED ("wildcards only implemented for files"); } url ret= url_none (); if (is_wildcard (u, 0) && is_of_type (base, filter)) ret= url_here (); bool error_flag; array<string> dir= read_directory (base, error_flag); int i, n= N(dir); for (i=0; i<n; i++) { if ((!is_none (ret)) && flag) return ret; if ((dir[i] == ".") || (dir[i] == "..")) continue; if (starts (dir[i], "http://") || starts (dir[i], "ftp://")) if (is_directory (base * dir[i])) continue; if (is_wildcard (u, 0)) ret= ret | (dir[i] * complete (base * dir[i], u, filter, flag)); else if (match_wildcard (dir[i], u[1]->t->label)) ret= ret | complete (base, dir[i], filter, flag); } return ret; } failed_error << "url= " << u << LF; FAILED ("bad url"); return u; }
void maketree() { /* tree construction recursively by branch and bound */ long i, j, k; node2 *dummy; fullset = (1L << (bits + 1)) - (1L << 1); if (progress) { printf("\nHow many\n"); printf("trees looked Approximate\n"); printf("at so far Length of How many percentage\n"); printf("(multiples shortest tree trees this long searched\n"); printf("of %4ld): found so far found so far so far\n", howoften); printf("---------- ------------ ------------ ------------\n"); #ifdef WIN32 phyFillScreenColor(); #endif } done = false; mults = 0; examined = 0; nextree = 1; root = treenode[0]; firsttime = true; for (i = 0; i < (spp); i++) added[i] = false; added[0] = true; order[0] = 1; k = 2; fracdone = 0.0; fracinc = 1.0; bestyet = -1.0; addit(k); if (done) { if (progress) { printf("Search broken off! Not guaranteed to\n"); printf(" have found the most parsimonious trees.\n"); } if (treeprint) { fprintf(outfile, "Search broken off! Not guaranteed to\n"); fprintf(outfile, " have found the most parsimonious\n"); fprintf(outfile, " trees, but here is what we found:\n"); } } if (treeprint) { fprintf(outfile, "\nrequires a total of %18.3f\n\n", bestyet); if (nextree == 2) fprintf(outfile, "One most parsimonious tree found:\n"); else fprintf(outfile, "%5ld trees in all found\n", nextree - 1); } if (nextree > maxtrees + 1) { if (treeprint) fprintf(outfile, "here are the first%4ld of them\n", (long)maxtrees); nextree = maxtrees + 1; } if (treeprint) putc('\n', outfile); for (i = 0; i < (spp); i++) added[i] = true; for (i = 0; i <= (nextree - 2); i++) { for (j = k; j <= (spp); j++) add3(treenode[bestrees[i][j - 1] - 1], treenode[bestorders[i][j - 1] - 1], treenode[spp + j - 2], &root, treenode); if (noroot) reroot(treenode[outgrno - 1]); didreroot = (outgropt && noroot); evaluate(root); printree(treeprint, noroot, didreroot, root); describe(); for (j = k - 1; j < (spp); j++) re_move3(&treenode[bestorders[i][j] - 1], &dummy, &root, treenode); } if (progress) { printf("\nOutput written to file \"%s\"\n\n", outfilename); if (trout) printf("Trees also written onto file \"%s\"\n\n", outtreename); } if (ancseq) freegarbage(&garbage); } /* maketree */
void extrait_outgroup(string inFile,string outFile,list<string> &outgroups,int nb){ int n;//the number of internal nodes int m;//the number of branches int n1,m1; counting(inFile,n,m,nb); int *P = new int[m+1];//tableau de predecesseurs double *B = new double[m+1];//branch lengths string *Support = new string[m+1]; string* Labels = new string[m+1]; FILE * tree = fopen(inFile.c_str(),"rt"); if (tree==NULL) cout<<"Can not open the tree file"<<endl; else{ FILE * w = fopen(outFile.c_str(),"wt"); bool rooted=false; for (int y=1;y<=nb;y++){ if (rooted){ n++; m++; } tree2dataS(tree,n,m,P,B,Support,Labels); int * Suc1= new int[n]; int * Suc2= new int[n]; computeSuc(P,Suc1,Suc2,m+1,n); list<int> P1; list<double> B1; list<string> Support1; list<string> Labels1; list<double> T1; int s; if (m==2*n){ rooted=true; rooted2unrooted(n,m,P,Suc1,Suc2,B,Labels); m--; n--; computeSuc(P,Suc1,Suc2,m+1,n); } s= computeSuc_unrooted(P,Suc1,Suc2,m+1,n); list<int> out; list<int> in; for (int i=n;i<=m;i++){ bool flag = true; for (list<string>::iterator iter=outgroups.begin();iter!=outgroups.end();iter++){ if (Labels[i].compare(*iter)==0){ out.push_back(i); flag=false; break; } } if (flag) in.push_back(i); } if (out.size()==0){ cout<<"Tree "<<y<<": the tree does not contain any outgroup"<<endl; exit( EXIT_SUCCESS ); } else{ int *P_new= new int[m+1]; int *Suc1_new= new int[n]; int *Suc2_new= new int[n]; double *B_new= new double[m+1]; string* Support_new = new string[m+1]; int t=out.front(); int t1=in.front(); if (out.size()==1){ reroot(n,m,t,P,s,Suc1,Suc2,B,Support,P_new,Suc1_new,Suc2_new,B_new,Support_new); subTree(n,m,P[t],P_new,Suc1_new,Suc2_new,B_new,Support_new,Labels,P1,B1,Support1,Labels1); int *Po=new int[m]; listToArray(P1,Po); double *Bo=new double[m]; listToArray(B1,Bo); string* Supporto=new string[m]; listToArray(Support1,Supporto); string* Labelso = new string[m]; listToArray(Labels1,Labelso); int *Suc1o=new int[n]; int *Suc2o=new int[n]; computeSuc(Po,Suc1o,Suc2o,m,n); newicktree(n,Po,Suc1o,Suc2o,Labelso,Bo,Supporto,w); delete[] Po; delete[] Bo; delete[] Labelso; delete[] Suc1o; delete[] Suc2o; delete[] Supporto; } else{ bool flag = false; while (!flag && P[t]!=-1){ t = P[t]; flag=true; for (list<int>::iterator ia=out.begin();ia!=out.end();ia++){ int j=*ia; if (!isAncestor(P,t,j)) { flag=false;break; } } }//t is lca of outgroups if (P[t]!=-1){//lca of outgroups is not the root reroot(n,m,t,P,s,Suc1,Suc2,B,Support,P_new,Suc1_new,Suc2_new,B_new,Support_new); subTree(n,m,P[t],P_new,Suc1_new,Suc2_new,B_new,Support_new,Labels,P1,B1,Support1,Labels1); } else{//lca of outgroups is the root bool flag = false; while (!flag && P[t1]!=-1){ t1 = P[t1]; flag=true; for (list<int>::iterator ia=in.begin();ia!=in.end();ia++){ int j=*ia; if (!isAncestor(P,t1,j)) {flag=false;break;} } } //t1 is lca of ingroups if (P[t1]==-1){//lca of ingroups is the root cout<<"Tree "<<y<<": The outgroups are not separated from the ingroups"<<endl; exit( EXIT_FAILURE ); } else{//lca of ingroups is not the root reroot(n,m,t1,P,s,Suc1,Suc2,B,Support,P_new,Suc1_new,Suc2_new,B_new,Support_new); subTree(n,m,t1,P_new,Suc1_new,Suc2_new,B_new,Support_new,Labels,P1,B1,Support1,Labels1); } } m1=(int)P1.size()-1; n1=m1/2; if ((n1+out.size())==n+1){ int *Po = new int[m1+1]; listToArray(P1,Po); double *Bo = new double[m1+1]; listToArray(B1,Bo); string* Supporto = new string[m1+1]; listToArray(Support1,Supporto); string* Labelso = new string[m1+1]; listToArray(Labels1,Labelso); int *Suc1o = new int[n1]; int *Suc2o = new int[n1]; computeSuc(Po,Suc1o,Suc2o,m1+1,n1); newicktree(n1,Po,Suc1o,Suc2o,Labelso,Bo,Supporto,w); delete[] Po; delete[] Bo; delete[] Supporto; delete[] Labelso; delete[] Suc1o; delete[] Suc2o; } else { cout<<"Tree "<<y<<": The outgroups are not separated from the ingroups"<<endl; exit( EXIT_FAILURE ); } delete[] P_new; delete[] Suc1_new; delete[] Suc2_new; delete[] B_new; delete[] Support_new; } delete[] Suc1; delete[] Suc2; } } fclose(tree); fclose(w); } delete[] P; delete[] B; delete[] Support; delete[] Labels; }
static url url_local (string name) { url u= url_get_name (name, URL_SYSTEM); return reroot (u, "file"); }