]> git.donarmstrong.com Git - mothur.git/blobdiff - rarefactcommand.cpp
changed how we do "smart" distancing
[mothur.git] / rarefactcommand.cpp
index 8820328461fcc2b403bbb9f01b8e44776d0a5750..9bb3daa7462368c4fbf9f889847cc4ae1e44c399 100644 (file)
@@ -195,7 +195,7 @@ int RareFactCommand::execute(){
                read->read(&*globaldata); 
 
                order = globaldata->gorder;
-               OrderVector* lastOrder = order;
+               string lastLabel = order->getLabel();
                input = globaldata->ginput;
                
                //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
@@ -218,19 +218,22 @@ int RareFactCommand::execute(){
                                userLines.erase(count);
                        }
                        
-                       if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastOrder->getLabel()) != 1)) {
-                               rCurve = new Rarefact(lastOrder, rDisplays);
+                       if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                               delete order;
+                               order = (input->getOrderVector(lastLabel));
+                               
+                               rCurve = new Rarefact(order, rDisplays);
                                rCurve->getCurve(freq, nIters);
                                delete rCurve;
                        
-                               cout << lastOrder->getLabel() << '\t' << count << endl;
-                               processedLabels.insert(lastOrder->getLabel());
-                               userLabels.erase(lastOrder->getLabel());
+                               cout << order->getLabel() << '\t' << count << endl;
+                               processedLabels.insert(order->getLabel());
+                               userLabels.erase(order->getLabel());
                        }
                        
-                       if (count != 1) { delete lastOrder; }
-                       lastOrder = order;                      
-
+                       lastLabel = order->getLabel();          
+                       
+                       delete order;
                        order = (input->getOrderVector());
                        count++;
                }
@@ -240,24 +243,27 @@ int RareFactCommand::execute(){
                bool needToRun = false;
                for (it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastOrder->getLabel()) != 1) {
-                               cout << ". I will use " << lastOrder->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel << "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastOrder->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       rCurve = new Rarefact(lastOrder, rDisplays);
+                       delete order;
+                       order = (input->getOrderVector(lastLabel));
+                               
+                       rCurve = new Rarefact(order, rDisplays);
                        rCurve->getCurve(freq, nIters);
                        delete rCurve;
                        
-                       cout << lastOrder->getLabel() << '\t' << count << endl;
+                       cout << order->getLabel() << '\t' << count << endl;
+                       delete order;
                }
                
-               delete lastOrder;
 
                for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    }       
                return 0;