X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=tree.cpp;h=3b3b6840a6fd1a427258e7b84d0afe3bf181bd7e;hb=b2c44d69197045c26c1f4e62d248ab882c79a393;hp=2689b037f6a494474ce1e008ba5efb1d250f0791;hpb=5a3592c6478d5d786ec20e4bee71854ad92fdb8c;p=mothur.git diff --git a/tree.cpp b/tree.cpp index 2689b03..3b3b684 100644 --- a/tree.cpp +++ b/tree.cpp @@ -354,33 +354,27 @@ void Tree::randomLabels() { void Tree::randomLabels(string groupA, string groupB) { try { - for(int i = 0; i < numLeaves; i++) { - int z; - //get random index to switch with - z = int((float)(i+1) * (float)(rand()) / ((float)RAND_MAX+1.0)); - - //you only want to randomize the nodes that are from a group the user wants analyzed, so - //if either of the leaf nodes you are about to switch are not in the users groups then you don't want to switch them. - if (((tree[z].getGroup() == groupA) || (tree[z].getGroup() == groupB)) && ((tree[i].getGroup() == groupA) || (tree[i].getGroup() == groupB))) { - //switches node i and node z's info. - map lib_hold = tree[z].pGroups; - tree[z].pGroups = (tree[i].pGroups); - tree[i].pGroups = (lib_hold); - - string zgroup = tree[z].getGroup(); - tree[z].setGroup(tree[i].getGroup()); - tree[i].setGroup(zgroup); - - string zname = tree[z].getName(); - tree[z].setName(tree[i].getName()); - tree[i].setName(zname); + int numSeqsA = globaldata->gTreemap->seqsPerGroup[groupA]; + int numSeqsB = globaldata->gTreemap->seqsPerGroup[groupB]; + + vector randomGroups(numSeqsA+numSeqsB, groupA); + for(int i=numSeqsA;i gcount_hold = tree[z].pcount; - tree[z].pcount = (tree[i].pcount); - tree[i].pcount = (gcount_hold); + int randomCounter = 0; + for(int i=0;i