]> git.donarmstrong.com Git - mothur.git/blobdiff - unweighted.cpp
1.19.0
[mothur.git] / unweighted.cpp
index 08e83ec5ba4ccbbbefe36163c25d1075fb05a883..90b6476543d67ee92d7c59624e2af8da2a7b2345 100644 (file)
 
 EstOutput Unweighted::getValues(Tree* t, int p, string o) {
        try {
-               globaldata = GlobalData::getInstance();
                processors = p;
                outputDir = o;
                        
                //if the users enters no groups then give them the score of all groups
-               int numGroups = globaldata->Groups.size();
+               int numGroups = m->Groups.size();
                
                //calculate number of comparsions
                int numComp = 0;
@@ -26,7 +25,7 @@ EstOutput Unweighted::getValues(Tree* t, int p, string o) {
                for (int r=0; r<numGroups; r++) { 
                        for (int l = 0; l < r; l++) {
                                numComp++;
-                               vector<string> groups; groups.push_back(globaldata->Groups[r]); groups.push_back(globaldata->Groups[l]);
+                               vector<string> groups; groups.push_back(m->Groups[r]); groups.push_back(m->Groups[l]);
                                namesOfGroupCombos.push_back(groups);
                        }
                }
@@ -42,8 +41,8 @@ EstOutput Unweighted::getValues(Tree* t, int p, string o) {
                                }
                                namesOfGroupCombos.push_back(groups);
                        }else {
-                               for (int i = 0; i < globaldata->Groups.size(); i++) {
-                                       groups.push_back(globaldata->Groups[i]);
+                               for (int i = 0; i < m->Groups.size(); i++) {
+                                       groups.push_back(m->Groups[i]);
                                }
                                namesOfGroupCombos.push_back(groups);
                        }
@@ -199,14 +198,14 @@ EstOutput Unweighted::driver(Tree* t, vector< vector<string> > namesOfGroupCombo
                                m->mothurOut(namesOfGroupCombos[h][namesOfGroupCombos[h].size()-1]);
                                m->mothurOut(", skipping."); m->mothurOutEndLine(); results[count] = UW;
                        }else{
-                               
+                               //cout << "trying to get root" << endl; 
                                //if including the root this clears rootForGrouping[namesOfGroupCombos[h]]
                                getRoot(t, nodeBelonging, namesOfGroupCombos[h]);
-                               
+                               //cout << "here" << endl;       
                                for(int i=0;i<t->getNumNodes();i++){
                                        
                                        if (m->control_pressed) {  return data; }
-                                       
+                                       //cout << i << endl;    
                                        //pcountSize = 0, they are from a branch that is entirely from a group the user doesn't want
                                        //pcountSize = 2, not unique to one group
                                        //pcountSize = 1, unique to one group
@@ -257,12 +256,11 @@ EstOutput Unweighted::driver(Tree* t, vector< vector<string> > namesOfGroupCombo
 
 EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB, int p, string o) { 
  try {
-               globaldata = GlobalData::getInstance();
                processors = p;
                outputDir = o;
                
                //if the users enters no groups then give them the score of all groups
-               int numGroups = globaldata->Groups.size();
+               int numGroups = m->Groups.size();
                
                //calculate number of comparsions
                int numComp = 0;
@@ -270,7 +268,7 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB, int p, st
                for (int r=0; r<numGroups; r++) { 
                        for (int l = 0; l < r; l++) {
                                numComp++;
-                               vector<string> groups; groups.push_back(globaldata->Groups[r]); groups.push_back(globaldata->Groups[l]);
+                               vector<string> groups; groups.push_back(m->Groups[r]); groups.push_back(m->Groups[l]);
                                namesOfGroupCombos.push_back(groups);
                        }
                }
@@ -286,8 +284,8 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB, int p, st
                                }
                                namesOfGroupCombos.push_back(groups);
                        }else {
-                               for (int i = 0; i < globaldata->Groups.size(); i++) {
-                                       groups.push_back(globaldata->Groups[i]);
+                               for (int i = 0; i < m->Groups.size(); i++) {
+                                       groups.push_back(m->Groups[i]);
                                }
                                namesOfGroupCombos.push_back(groups);
                        }
@@ -414,7 +412,7 @@ EstOutput Unweighted::driver(Tree* t, vector< vector<string> > namesOfGroupCombo
                
                int count = 0;
                
-               Tree* copyTree = new Tree;
+               Tree* copyTree = new Tree(tmap);
                
                for (int h = start; h < (start+num); h++) {
                
@@ -497,17 +495,18 @@ EstOutput Unweighted::driver(Tree* t, vector< vector<string> > namesOfGroupCombo
 int Unweighted::getRoot(Tree* t, int v, vector<string> grouping) { 
        try {
                //you are a leaf so get your parent
-               int index = t->tree[index].getParent();
+               int index = t->tree[v].getParent();
                
                if (includeRoot) { 
                        rootForGrouping[grouping].clear();
                }else {
+                       
                        //my parent is a potential root
                        rootForGrouping[grouping].insert(index);
                        
                        //while you aren't at root
                        while(t->tree[index].getParent() != -1){
-                               
+                               //cout << index << endl;        
                                if (m->control_pressed) {  return 0; }
                                
                                //am I the root for this grouping? if so I want to stop "early"