Esempio n. 1
0
void Tree::getCopy(Tree* copy, bool subsample) {
	try {
        
		//for each node in the tree copy its info
		for (int i = 0; i < numNodes; i++) {
			//copy branch length
			tree[i].setBranchLength(copy->tree[i].getBranchLength());
            
			//copy parent
			tree[i].setParent(copy->tree[i].getParent());
            
			//copy children
			tree[i].setChildren(copy->tree[i].getLChild(), copy->tree[i].getRChild());
        }
        
        //build the pGroups in non leaf nodes to be used in the parsimony calcs.
		for (int i = numLeaves; i < numNodes; i++) {
			if (m->control_pressed) { break; }
            
			tree[i].pGroups = (mergeGroups(i));
			tree[i].pcount = (mergeGcounts(i));
		}
	}
	catch(exception& e) {
		m->errorOut(e, "Tree", "getCopy");
		exit(1);
	}
}
Esempio n. 2
0
int Tree::assembleTree() {
	try {		
		//build the pGroups in non leaf nodes to be used in the parsimony calcs.
		for (int i = numLeaves; i < numNodes; i++) {
			if (m->control_pressed) { return 1; }

			tree[i].pGroups = (mergeGroups(i));
			tree[i].pcount = (mergeGcounts(i));
		}
		
		return 0;
	}
	catch(exception& e) {
		m->errorOut(e, "Tree", "assembleTree");
		exit(1);
	}
}
Esempio n. 3
0
void unarySortAdd(vec<Formula>& Xs,vec<Formula>& Ys,vec<Formula>& out_sorter,bool useShortCuts){
 	vec<Formula> propgationShortCuts;
	int XsLen = Xs.size();
    int YsLen = Ys.size();
    if (YsLen==0) {
    	if (XsLen>0) {
    		add(Xs,out_sorter);
    		safeSortNetwork(out_sorter,propgationShortCuts);
    		if (useShortCuts) overwrite(out_sorter,propgationShortCuts);
    	}
    }
    else if (XsLen==0) add(Ys,out_sorter);
    else if (XsLen==1 & YsLen==1) {
    	add(Xs,out_sorter);
    	add(Ys,out_sorter);
    	cmp2(out_sorter, 0);
    }
    else {
    	int Ysize; for (Ysize = 2; Ysize < YsLen; Ysize *= 2);
    	Ys.growTo(Ysize,_0_);
    	propgationShortCuts.growTo(Ysize*2,_0_);
    	addShortCuts(Ys,propgationShortCuts);
    	if (XsLen <= YsLen) {
		    Xs.growTo(Ysize,_0_);
		    sortNetwork(Xs,propgationShortCuts);
		    mergeNetwork(Xs,Ys,out_sorter,propgationShortCuts);
		}
		else {
		    vec<vec<Formula> > SubXs;
		    SubXs.push();
		    add(Ys,SubXs.last());
		    splitToGroups(Xs, Ysize, SubXs);
		    sortGroups(SubXs,propgationShortCuts); 
		    mergeGroups(SubXs, Ysize, out_sorter,propgationShortCuts);
		}
		out_sorter.shrink(out_sorter.size() - XsLen-YsLen);
		if(useShortCuts) overwrite(out_sorter,propgationShortCuts);
    }
}