]> git.donarmstrong.com Git - mothur.git/blobdiff - unweighted.cpp
worked on unifrac.unweighted()
[mothur.git] / unweighted.cpp
index 1ceca424016ab5436078f7f9ce5cdce48d57a68e..16a2203274f325ffc8d8b5febfea903597340093 100644 (file)
@@ -77,7 +77,7 @@ EstOutput Unweighted::getValues(Tree* t) {
                                        //if i's chidren are leaves
                                        if (t->tree[rc].getRChild() == -1) {
                                                //if rc is a valid group and rc has a BL
-                                               if ((inUsersGroups(t->tree[rc].getGroup(), globaldata->Groups) == true) && (t->tree[rc].getBranchLength() != -1)) {
+                                               if ((inUsersGroups(t->tree[rc].getGroup(), groups) == true) && (t->tree[rc].getBranchLength() != -1)) {
                                                        UniqueBL += t->tree[rc].getBranchLength();
                                                        totalBL += t->tree[rc].getBranchLength(); 
                                                }
@@ -85,7 +85,7 @@ EstOutput Unweighted::getValues(Tree* t) {
                        
                                        if (t->tree[lc].getLChild() == -1) {
                                                //if lc is a valid group and lc has a BL
-                                               if ((inUsersGroups(t->tree[lc].getGroup(), globaldata->Groups) == true) && (t->tree[lc].getBranchLength() != -1)) {
+                                               if ((inUsersGroups(t->tree[lc].getGroup(), groups) == true) && (t->tree[lc].getBranchLength() != -1)) {
                                                        UniqueBL += t->tree[lc].getBranchLength();
                                                        totalBL += t->tree[lc].getBranchLength(); 
                                                }
@@ -151,7 +151,7 @@ EstOutput Unweighted::getValues(Tree* t) {
                                //if i's chidren are leaves
                                if (t->tree[rc].getRChild() == -1) {
                                        //if rc is a valid group and rc has a BL
-                                       if ((inUsersGroups(t->tree[rc].getGroup(), globaldata->Groups) == true) && (t->tree[rc].getBranchLength() != -1)) {
+                                       if ((inUsersGroups(t->tree[rc].getGroup(), groups) == true) && (t->tree[rc].getBranchLength() != -1)) {
                                                UniqueBL += t->tree[rc].getBranchLength();
                                                totalBL += t->tree[rc].getBranchLength(); 
                                        }
@@ -159,7 +159,7 @@ EstOutput Unweighted::getValues(Tree* t) {
                        
                                if (t->tree[lc].getLChild() == -1) {
                                        //if lc is a valid group and lc has a BL
-                                       if ((inUsersGroups(t->tree[lc].getGroup(), globaldata->Groups) == true) && (t->tree[lc].getBranchLength() != -1)) {
+                                       if ((inUsersGroups(t->tree[lc].getGroup(), groups) == true) && (t->tree[lc].getBranchLength() != -1)) {
                                                UniqueBL += t->tree[lc].getBranchLength();
                                                totalBL += t->tree[lc].getBranchLength(); 
                                        }
@@ -205,7 +205,7 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB) {
 
                //if the users enters no groups then give them the score of all groups
                int numGroups = globaldata->Groups.size();
-               
+cout << "NumGroups = " << numGroups << endl;
                //calculate number of comparsions
                int numComp = 0;
                for (int r=0; r<numGroups; r++) { 
@@ -227,12 +227,13 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB) {
                                
                                //copy random tree passed in
                                copyTree->getCopy(t);
-                               
-                               //swap labels in the groups you want to compare
-                               copyTree->assembleRandomUnifracTree(globaldata->Groups[a], globaldata->Groups[l]);
-                               
+                                                               
                                //groups in this combo
                                groups.push_back(globaldata->Groups[a]); groups.push_back(globaldata->Groups[l]);
+                               
+                               //swap labels in the groups you want to compare
+                               copyTree->assembleRandomUnifracTree(groups[0], groups[1]);
+
                
                                for(int i=t->getNumLeaves();i<t->getNumNodes();i++){
                
@@ -263,7 +264,7 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB) {
                                        //if i's chidren are leaves
                                        if (t->tree[rc].getRChild() == -1) {
                                                //if rc is a valid group and rc has a BL
-                                               if ((inUsersGroups(t->tree[rc].getGroup(), globaldata->Groups) == true) && (t->tree[rc].getBranchLength() != -1)) {
+                                               if ((inUsersGroups(t->tree[rc].getGroup(), groups) == true) && (t->tree[rc].getBranchLength() != -1)) {
                                                        UniqueBL += t->tree[rc].getBranchLength();
                                                        totalBL += t->tree[rc].getBranchLength(); 
                                                }
@@ -271,7 +272,7 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB) {
                        
                                        if (t->tree[lc].getLChild() == -1) {
                                                //if lc is a valid group and lc has a BL
-                                               if ((inUsersGroups(t->tree[lc].getGroup(), globaldata->Groups) == true) && (t->tree[lc].getBranchLength() != -1)) {
+                                               if ((inUsersGroups(t->tree[lc].getGroup(), groups) == true) && (t->tree[lc].getBranchLength() != -1)) {
                                                        UniqueBL += t->tree[lc].getBranchLength();
                                                        totalBL += t->tree[lc].getBranchLength(); 
                                                }
@@ -312,7 +313,7 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB) {
                        copyTree->getCopy(t);
                                
                        //swap labels in all the groups you want to compare
-                       copyTree->assembleRandomUnifracTree();
+                       copyTree->assembleRandomUnifracTree(groups);
 
                        for(int i=t->getNumLeaves();i<t->getNumNodes();i++){
                
@@ -343,7 +344,7 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB) {
                                //if i's chidren are leaves
                                if (t->tree[rc].getRChild() == -1) {
                                        //if rc is a valid group and rc has a BL
-                                       if ((inUsersGroups(t->tree[rc].getGroup(), globaldata->Groups) == true) && (t->tree[rc].getBranchLength() != -1)) {
+                                       if ((inUsersGroups(t->tree[rc].getGroup(), groups) == true) && (t->tree[rc].getBranchLength() != -1)) {
                                                UniqueBL += t->tree[rc].getBranchLength();
                                                totalBL += t->tree[rc].getBranchLength(); 
                                        }
@@ -351,7 +352,7 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB) {
                        
                                if (t->tree[lc].getLChild() == -1) {
                                        //if lc is a valid group and lc has a BL
-                                       if ((inUsersGroups(t->tree[lc].getGroup(), globaldata->Groups) == true) && (t->tree[lc].getBranchLength() != -1)) {
+                                       if ((inUsersGroups(t->tree[lc].getGroup(), groups) == true) && (t->tree[lc].getBranchLength() != -1)) {
                                                UniqueBL += t->tree[lc].getBranchLength();
                                                totalBL += t->tree[lc].getBranchLength(); 
                                        }