]> git.donarmstrong.com Git - mothur.git/blobdiff - heatmapsimcommand.cpp
changed how we do "smart" distancing
[mothur.git] / heatmapsimcommand.cpp
index f3329945e0fa3fb6b24c77960717ff51e7cb0de0..331ff7963460ef9d952a71382615bdf54e195677 100644 (file)
@@ -197,7 +197,7 @@ int HeatMapSimCommand::execute(){
                        
                input = globaldata->ginput;
                lookup = input->getSharedRAbundVectors();
-               vector<SharedRAbundVector*> lastLookup = lookup;
+               string lastLabel = lookup[0]->getLabel();
                
                if (lookup.size() < 2) { cout << "You have not provided enough valid groups.  I cannot run the command." << endl; return 0;}
                                
@@ -220,19 +220,24 @@ int HeatMapSimCommand::execute(){
                                userLines.erase(count);
                        }
                                
-                       if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLookup[0]->getLabel()) != 1)) {
-                               cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                               heatmap->getPic(lastLookup, heatCalculators);
+                       if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                       
+                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
+                               lookup = input->getSharedRAbundVectors(lastLabel);                              
+
+                               cout << lookup[0]->getLabel() << '\t' << count << endl;
+                               heatmap->getPic(lookup, heatCalculators);
                                        
-                               processedLabels.insert(lastLookup[0]->getLabel());
-                               userLabels.erase(lastLookup[0]->getLabel());
+                               processedLabels.insert(lookup[0]->getLabel());
+                               userLabels.erase(lookup[0]->getLabel());
                        }
                                
                        //prevent memory leak
-                       if (count != 1) { for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  } }
-                       lastLookup = lookup;                    
+                        
+                       lastLabel = lookup[0]->getLabel();                      
 
                        //get next line to process
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                        lookup = input->getSharedRAbundVectors();                               
                        count++;
                }
@@ -242,21 +247,24 @@ int HeatMapSimCommand::execute(){
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastLookup[0]->getLabel()) != 1) {
-                               cout << ". I will use " << lastLookup[0]->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel<< "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastLookup[0]->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       cout << lastLookup[0]->getLabel() << '\t' << count << endl;
-                       heatmap->getPic(lastLookup, heatCalculators);
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
+                       lookup = input->getSharedRAbundVectors(lastLabel);                              
+
+                       cout << lookup[0]->getLabel() << '\t' << count << endl;
+                       heatmap->getPic(lookup, heatCalculators);
+                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                }
                
-               for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  }
                        
                //reset groups parameter
                globaldata->Groups.clear();