]> git.donarmstrong.com Git - mothur.git/blobdiff - collectsharedcommand.cpp
fixed order of unifrac commands so that it matches the summary commands
[mothur.git] / collectsharedcommand.cpp
index 201709ea83ff099f9afe97b2e3af69bdb4fbe1ce..c0b8248e58981473b1f7bf70709863c36c68992b 100644 (file)
@@ -79,7 +79,7 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                        label = validParameter.validFile(parameters, "label", false);                   
                        if (label == "not found") { label = ""; }
                        else { 
-                               if(label != "all") {  splitAtDash(label, labels);  allLines = 0;  }
+                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
                                else { allLines = 1;  }
                        }
                        
@@ -94,12 +94,12 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                        else { 
                                 if (calc == "default")  {  calc = "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan";  }
                        }
-                       splitAtDash(calc, Estimators);
+                       m->splitAtDash(calc, Estimators);
                        
                        groups = validParameter.validFile(parameters, "groups", false);                 
                        if (groups == "not found") { groups = ""; }
                        else { 
-                               splitAtDash(groups, Groups);
+                               m->splitAtDash(groups, Groups);
                        }
                        globaldata->Groups = Groups;
                        
@@ -108,12 +108,12 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                        convert(temp, freq); 
                        
                        temp = validParameter.validFile(parameters, "all", false);                              if (temp == "not found") { temp = "false"; }
-                       all = isTrue(temp);
+                       all = m->isTrue(temp);
                                                
                        if (abort == false) {
                                
-                               if (outputDir == "") { outputDir += hasPath(globaldata->inputFileName); }
-                               string fileNameRoot = outputDir + getRootName(getSimpleName(globaldata->inputFileName));
+                               if (outputDir == "") { outputDir += m->hasPath(globaldata->inputFileName); }
+                               string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName));
                                format = globaldata->getFormat();
                                int i;
                                
@@ -208,6 +208,7 @@ void CollectSharedCommand::help(){
                m->mothurOut("Example collect.shared(label=unique-.01-.03, freq=10, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan).\n");
                m->mothurOut("The default values for freq is 100 and calc are sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan.\n");
                m->mothurOut("The default value for groups is all the groups in your groupfile.\n");
+               m->mothurOut("The freq parameter is used indicate when to output your data, by default it is set to 100. But you can set it to a percentage of the number of sequence. For example freq=0.10, means 10%. \n");
                validCalculator->printCalc("shared", cout);
                m->mothurOut("The label parameter is used to analyze specific labels in your input.\n");
                m->mothurOut("The all parameter is used to specify if you want the estimate of all your groups together.  This estimate can only be made for sharedsobs and sharedchao calculators. The default is false.\n");
@@ -261,55 +262,39 @@ int CollectSharedCommand::execute(){
                util->updateGroupIndex(globaldata->Groups, globaldata->gGroupmap->groupIndex);
 
                while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-
-                       if(allLines == 1 || labels.count(order->getLabel()) == 1){
-                               
-                               //create collectors curve
-                               cCurve = new Collect(order, cDisplays);
-                               int error = cCurve->getSharedCurve(freq);
-                               delete cCurve;
-                               
-                               if (error == 1) {
+                       if (m->control_pressed) { 
                                        for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }  
                                        for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
-                                       delete input;  globaldata->ginput = NULL;
-                                       delete read;
-                                       delete order; globaldata->gorder = NULL;
-                                       delete validCalculator;
+                                       delete order; 
                                        globaldata->Groups.clear();
                                        return 0;
-                               }
+                       }
+
+                       if(allLines == 1 || labels.count(order->getLabel()) == 1){
                        
                                m->mothurOut(order->getLabel()); m->mothurOutEndLine();
+                               //create collectors curve
+                               cCurve = new Collect(order, cDisplays);
+                               cCurve->getSharedCurve(freq);
+                               delete cCurve;
+                       
                                processedLabels.insert(order->getLabel());
                                userLabels.erase(order->getLabel());
                        }
                        
                        //you have a label the user want that is smaller than this label and the last label has not already been processed
-                       if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                       if ((m->anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
                                string saveLabel = order->getLabel();
                                
                                delete order;
                                order = input->getSharedOrderVector(lastLabel);
                                
+                               m->mothurOut(order->getLabel()); m->mothurOutEndLine();
                                //create collectors curve
                                cCurve = new Collect(order, cDisplays);
-                               int error = cCurve->getSharedCurve(freq);
+                               cCurve->getSharedCurve(freq);
                                delete cCurve;
                                
-                               if (error == 1) {
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }  
-                                       for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
-                                       delete input;  globaldata->ginput = NULL;
-                                       delete read;
-                                       delete order; globaldata->gorder = NULL;
-                                       delete validCalculator;
-                                       globaldata->Groups.clear();
-                                       return 0;
-                               }
-
-                       
-                               m->mothurOut(order->getLabel()); m->mothurOutEndLine();
                                processedLabels.insert(order->getLabel());
                                userLabels.erase(order->getLabel());
                                
@@ -325,6 +310,13 @@ int CollectSharedCommand::execute(){
                        order = input->getSharedOrderVector();
                }
                
+               if (m->control_pressed) { 
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }  
+                                       for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
+                                       globaldata->Groups.clear();
+                                       return 0;
+               }
+               
                //output error messages about any remaining user labels
                set<string>::iterator it;
                bool needToRun = false;
@@ -342,24 +334,20 @@ int CollectSharedCommand::execute(){
                if (needToRun == true)  {
                        if (order != NULL) {  delete order;  }
                        order = input->getSharedOrderVector(lastLabel);
-
+                       
+                       m->mothurOut(order->getLabel()); m->mothurOutEndLine();
                        cCurve = new Collect(order, cDisplays);
-                       int error = cCurve->getSharedCurve(freq);
+                       cCurve->getSharedCurve(freq);
                        delete cCurve;
                        
-                       if (error == 1) {
+                       if (m->control_pressed) { 
                                for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }  
                                for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
-                               delete input;  globaldata->ginput = NULL;
-                               delete read;
-                               delete order; globaldata->gorder = NULL;
-                               delete validCalculator;
+                               delete order; 
                                globaldata->Groups.clear();
                                return 0;
                        }
 
-                       
-                       m->mothurOut(order->getLabel()); m->mothurOutEndLine();
                        delete order;
                }