]> git.donarmstrong.com Git - mothur.git/blobdiff - rarefact.cpp
fixed bug in heatmap
[mothur.git] / rarefact.cpp
index 0be032727ab5dcb9294b670fe4dffcfa52a328cd..cb4bbbce9a4047ae08b5f37b807be3f78c255d89 100644 (file)
@@ -3,12 +3,12 @@
  *  Dotur
  *
  *  Created by Sarah Westcott on 11/18/08.
- *  Copyright 2008 __MyCompanyName__. All rights reserved.
+ *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
  *
  */
 
 #include "rarefact.h"
-#include "ordervector.hpp"
+//#include "ordervector.hpp"
 
 /***********************************************************************/
 
@@ -52,11 +52,15 @@ void Rarefact::getCurve(int increment = 1, int nIters = 1000){
                        for(int i=0;i<displays.size();i++){
                                displays[i]->reset();
                        }
+                       
+                       delete lookup;
+                       delete rank;
                }
 
                for(int i=0;i<displays.size();i++){
                        displays[i]->close();
                }
+               delete rcd;
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the Rarefact class Function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -85,10 +89,10 @@ try {
                        lookup.clear();
                
                        //create and initialize vector of sharedvectors, one for each group
-                       for (int i = 0; i < globaldata->gGroupmap->getNumGroups(); i++) { 
+                       for (int i = 0; i < globaldata->Groups.size(); i++) { 
                                SharedRAbundVector* temp = new SharedRAbundVector(sharedorder->getNumBins());
                                temp->setLabel(sharedorder->getLabel());
-                               temp->setGroup(globaldata->gGroupmap->namesOfGroups[i]);
+                               temp->setGroup(globaldata->Groups[i]);
                                lookup.push_back(temp);
                        }
                        
@@ -114,30 +118,33 @@ try {
                        
                        //randomize the groups
                        random_shuffle(lookup.begin(), lookup.end());
-               
-                       //send the first group
-                       rcd->updateSharedData(lookup[0], lookup[0], 1, numGroupComb);
+                       
+                       vector<SharedRAbundVector*> subset;
+                       //send each group one at a time
+                       for (int k = 0; k < lookup.size(); k++) { 
+                               subset.clear(); //clears out old pair of sharedrabunds
+                               //add in new pair of sharedrabunds
+                               subset.push_back(lookup[0]); subset.push_back(lookup[k]);
                                
-                       //send each additional group one at a time
-                       int n = 1;
-                       for (int k = 0; k < (lookup.size() - 1); k++) { 
-                               for (int l = n; l < lookup.size(); l++) {
-                                       rcd->updateSharedData(lookup[k], lookup[l], l+1, numGroupComb);
-                                       mergeVectors(lookup[0], lookup[l]);
-                               }
-                               n++;
+                               rcd->updateSharedData(subset, k+1, numGroupComb);
+                               mergeVectors(lookup[0], lookup[k]);
                        }
 
                        //resets output files
                        for(int i=0;i<displays.size();i++){
                                displays[i]->reset();
                        }
+                       
+                       for (int i = 0; i < lookup.size(); i++) {
+                               delete lookup[i];
+                       }
                }
                
                for(int i=0;i<displays.size();i++){
                        displays[i]->close();
                }
-
+               
+               delete rcd;
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the Rarefact class Function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";