]> git.donarmstrong.com Git - mothur.git/blobdiff - getoturepcommand.cpp
changed how we do "smart" distancing
[mothur.git] / getoturepcommand.cpp
index 8008079b3d2c84681d1e0c81cce7f617e66ee52e..1f5c02beab1630a2d5e8d39547fb967838ae0e29 100644 (file)
@@ -195,7 +195,7 @@ int GetOTURepCommand::execute(){
                
                input = globaldata->ginput;
                list = globaldata->gListVector;
-               ListVector* lastList = list;
+               string lastLabel = list->getLabel();
                
                //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
                set<string> processedLabels;
@@ -215,18 +215,22 @@ int GetOTURepCommand::execute(){
                                        userLines.erase(count);
                        }
                        
-                       if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastList->getLabel()) != 1)) {
-                                       cout << lastList->getLabel() << '\t' << count << endl;
-                                       error = process(lastList);
+                       if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       delete list;
+                                       list = input->getListVector(lastLabel);
+                                       
+                                       cout << list->getLabel() << '\t' << count << endl;
+                                       error = process(list);
                                        if (error == 1) { return 0; } //there is an error in hte input files, abort command
                                        
-                                       processedLabels.insert(lastList->getLabel());
-                                       userLabels.erase(lastList->getLabel());
+                                       processedLabels.insert(list->getLabel());
+                                       userLabels.erase(list->getLabel());
                        }
                        
-                       if (count != 1) { delete lastList; }
-                       lastList = list;                        
                        
+                       lastLabel = list->getLabel();                   
+                       
+                       delete list;
                        list = input->getListVector();
                        count++;
                }
@@ -235,25 +239,27 @@ int GetOTURepCommand::execute(){
                bool needToRun = false;
                for (set<string>::iterator it = userLabels.begin(); it != userLabels.end(); it++) {  
                        cout << "Your file does not include the label "<< *it; 
-                       if (processedLabels.count(lastList->getLabel()) != 1) {
-                               cout << ". I will use " << lastList->getLabel() << "." << endl;
+                       if (processedLabels.count(lastLabel) != 1) {
+                               cout << ". I will use " << lastLabel << "." << endl;
                                needToRun = true;
                        }else {
-                               cout << ". Please refer to " << lastList->getLabel() << "." << endl;
+                               cout << ". Please refer to " << lastLabel << "." << endl;
                        }
                }
                
                //run last line if you need to
                if (needToRun == true)  {
-                       cout << lastList->getLabel() << '\t' << count << endl;
-                       error = process(lastList);
+                       delete list;
+                       list = input->getListVector(lastLabel);
+
+                       cout << list->getLabel() << '\t' << count << endl;
+                       error = process(list);
                        if (error == 1) { return 0; } //there is an error in hte input files, abort command
+                       delete list;
                }
-               delete lastList;
                
                delete matrix;
                globaldata->gSparseMatrix = NULL;
-               delete list;
                globaldata->gListVector = NULL;
 
                return 0;