]> git.donarmstrong.com Git - mothur.git/blobdiff - collectcommand.cpp
changed file divide for trim.seqs
[mothur.git] / collectcommand.cpp
index 1e2bf2fcd42e771e2b84e7f2d3f93abd2171a15a..8c1565b901d5b885ad86b91d31cb7cc041138535 100644 (file)
@@ -86,7 +86,7 @@ CollectCommand::CollectCommand(string option)  {
                        splitAtDash(calc, Estimators);
 
                        string temp;
-                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "0.10"; }
+                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "100"; }
                        convert(temp, freq); 
                        
                        temp = validParameter.validFile(parameters, "abund", false);            if (temp == "not found") { temp = "10"; }
@@ -110,7 +110,7 @@ void CollectCommand::help(){
                m->mothurOut("The collect.single command can be executed after a successful cluster command.  It will use the .list file from the output of the cluster.\n");
                m->mothurOut("The collect.single command parameters are label, freq, calc and abund.  No parameters are required. \n");
                m->mothurOut("The collect.single command should be in the following format: \n");
-               m->mothurOut("The freq parameter is used indicate when to output your data.  It is a percentage of the number of sequences.  By default it is set to 0.10, meaning 10%. \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");
                m->mothurOut("collect.single(label=yourLabel, iters=yourIters, freq=yourFreq, calc=yourEstimators).\n");
                m->mothurOut("Example collect(label=unique-.01-.03, iters=10000, freq=10, calc=sobs-chao-ace-jack).\n");
                m->mothurOut("The default values for freq is 100, and calc are sobs-chao-ace-jack-shannon-npshannon-simpson.\n");
@@ -137,12 +137,13 @@ int CollectCommand::execute(){
                
                vector<string> outputNames;
                
+               string hadShared = "";
                if ((globaldata->getFormat() != "sharedfile")) { inputFileNames.push_back(globaldata->inputFileName);  }
-               else {  inputFileNames = parseSharedFile(globaldata->getSharedFile());  globaldata->setFormat("rabund");  }
+               else { hadShared = globaldata->getSharedFile(); inputFileNames = parseSharedFile(globaldata->getSharedFile());  globaldata->setFormat("rabund");  }
        
                for (int p = 0; p < inputFileNames.size(); p++) {
                        
-                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());         }  globaldata->Groups.clear(); return 0; }
+                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());         }  globaldata->Groups.clear(); if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } return 0; }
                        
                        if (outputDir == "") { outputDir += hasPath(inputFileNames[p]); }
                        string fileNameRoot = outputDir + getRootName(getSimpleName(inputFileNames[p]));
@@ -221,7 +222,7 @@ int CollectCommand::execute(){
                        }
                
                        //if the users entered no valid calculators don't execute command
-                       if (cDisplays.size() == 0) { return 0; }
+                       if (cDisplays.size() == 0) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } return 0; }
                        
                        read = new ReadOTUFile(inputFileNames[p]);      
                        read->read(&*globaldata); 
@@ -242,6 +243,7 @@ int CollectCommand::execute(){
                                delete order; globaldata->gorder = NULL;
                                delete validCalculator;
                                globaldata->Groups.clear();
+                               if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  }
                                return 0;
                        }
 
@@ -256,6 +258,7 @@ int CollectCommand::execute(){
                                        delete order; globaldata->gorder = NULL;
                                        delete validCalculator;
                                        globaldata->Groups.clear();
+                                       if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  }
                                        return 0;
                                }
 
@@ -306,6 +309,7 @@ int CollectCommand::execute(){
                                        delete read;
                                        delete validCalculator;
                                        globaldata->Groups.clear();
+                                       if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  }
                                        return 0;
                        }
                                
@@ -341,6 +345,7 @@ int CollectCommand::execute(){
                                        delete order; globaldata->gorder = NULL;
                                        delete validCalculator;
                                        globaldata->Groups.clear();
+                                       if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  }
                                        return 0;
                                }
                                delete order;
@@ -354,8 +359,11 @@ int CollectCommand::execute(){
                        delete validCalculator;
                }
                
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());         } return 0; }
+               //return to shared mode if you changed above
+               if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  }
 
+               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());         } return 0; }
+                               
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
                for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }