]> git.donarmstrong.com Git - mothur.git/blobdiff - collect.cpp
changing command name classify.shared to classifyrf.shared
[mothur.git] / collect.cpp
index 79e997de38bc8938bbcdb72d7134a566a7b9a2bb..9a89020efe91f8bdd2733a3de553611e86ee6da3 100644 (file)
@@ -70,19 +70,18 @@ int Collect::getCurve(float percentFreq = 0.01){
 /***********************************************************************/
 int Collect::getSharedCurve(float percentFreq = 0.01){
 try {
-                               globaldata = GlobalData::getInstance();
                 vector<SharedRAbundVector*> lookup; 
                                vector<SharedRAbundVector*> subset;
 
                 //create and initialize vector of sharedvectors, one for each group
-                for (int i = 0; i < globaldata->Groups.size(); i++) { 
+                               vector<string> mGroups = m->getGroups();
+                for (int i = 0; i < mGroups.size(); i++) { 
                         SharedRAbundVector* temp = new SharedRAbundVector(sharedorder->getNumBins());
                         temp->setLabel(sharedorder->getLabel());
-                        temp->setGroup(globaldata->Groups[i]);
-                        temp->setGroupIndex(globaldata->gGroupmap->groupIndex[globaldata->Groups[i]]);
-                        lookup.push_back(temp);
+                        temp->setGroup(mGroups[i]);
+                                               lookup.push_back(temp);
                 }
-
+       
                 SharedCollectorsCurveData* ccd = new SharedCollectorsCurveData();
         
                 //initialize labels for output
@@ -116,7 +115,7 @@ try {
                         //get first sample
                         individual chosen = sharedorder->get(i);
                         int abundance; 
-                                        
+                                                    
                         //set info for sharedvector in chosens group
                         for (int j = 0; j < lookup.size(); j++) { 
                                                        if (chosen.group == lookup[j]->getGroup()) {
@@ -132,17 +131,27 @@ try {
                                                                //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
 
                                 int n = 1;
+                                                               bool pair = true;
                                 for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
                                         for (int l = n; l < lookup.size(); l++) {
                                                                                                subset.clear(); //clear out old pair of sharedrabunds
                                                                                                //add new pair of sharedrabund vectors
                                                                                                subset.push_back(lookup[k]); subset.push_back(lookup[l]);
-                                                ccd->updateSharedData(subset, i+1, globaldata->Groups.size());
+                                                                                       
+                                                                                               //load subset with rest of lookup for those calcs that need everyone to calc for a pair
+                                                                                               for (int w = 0; w < lookup.size(); w++) {
+                                                                                                       if ((w != k) && (w != l)) { subset.push_back(lookup[w]); }
+                                                                                               }
+                                               
+                                                ccd->updateSharedData(subset, i+1, m->getNumGroups(), pair);
                                         }
                                         n++;
                                 }
+                                                       
                                                                //if this is a calculator that can do multiples then do them
-                                                               ccd->updateSharedData(lookup, i+1, globaldata->Groups.size()); 
+                                                               pair = false;
+                                                               ccd->updateSharedData(lookup, i+1, m->getNumGroups(), pair); 
+                                                       
                         }
                         totalNumSeq = i+1;
                 }
@@ -151,19 +160,27 @@ try {
                 if(numSeqs % increment != 0){
                         //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
                         int n = 1;
+                                               bool pair = true;
                         for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
                                 for (int l = n; l < lookup.size(); l++) {
                                                                                subset.clear(); //clear out old pair of sharedrabunds
                                                                                //add new pair of sharedrabund vectors
                                                                                subset.push_back(lookup[k]); subset.push_back(lookup[l]);
-                                                                               ccd->updateSharedData(subset, totalNumSeq, globaldata->Groups.size());
+                                                                       
+                                                                               //load subset with rest of lookup for those calcs that need everyone to calc for a pair
+                                                                               for (int w = 0; w < lookup.size(); w++) {
+                                                                                       if ((w != k) && (w != l)) { subset.push_back(lookup[w]); }
+                                                                               }
+                                                                       
+                                                                               ccd->updateSharedData(subset, totalNumSeq, m->getNumGroups(), pair);
                                 }
                                 n++;
                         }
                                                //if this is a calculator that can do multiples then do them
-                                               ccd->updateSharedData(lookup, totalNumSeq, globaldata->Groups.size()); 
+                                               pair = false;
+                                               ccd->updateSharedData(lookup, totalNumSeq, m->getNumGroups(), pair); 
                 }
-                
+        
                 //resets output files
                 for(int i=0;i<displays.size();i++){
                         displays[i]->reset();
@@ -192,9 +209,10 @@ void Collect::getGroupComb() {
        numGroupComb = 0;
                 
        int n = 1;
-       for (int i = 0; i < (globaldata->Groups.size() - 1); i++) {
-               for (int l = n; l < globaldata->Groups.size(); l++) {
-                       group = globaldata->Groups[i] + globaldata->Groups[l];
+       vector<string> mGroups = m->getGroups();
+       for (int i = 0; i < (m->getNumGroups() - 1); i++) {
+               for (int l = n; l < m->getNumGroups(); l++) {
+                       group = mGroups[i] + mGroups[l];
                        groupComb.push_back(group);        
                        numGroupComb++;
                }