]> git.donarmstrong.com Git - mothur.git/blobdiff - collectsharedcommand.cpp
1.21.0
[mothur.git] / collectsharedcommand.cpp
index 0fe4d0f239fad770e83b68cee3f68eb9630aa368..3b43a40f4cd33c4f006776ba764c04fa3866d96b 100644 (file)
@@ -57,7 +57,7 @@ vector<string> CollectSharedCommand::setParameters(){
                CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
                CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
                CommandParameter pfreq("freq", "Number", "", "100", "", "", "",false,false); parameters.push_back(pfreq);
-               CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-skulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "",true,false); parameters.push_back(pcalc);
+               CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "",true,false); parameters.push_back(pcalc);
                CommandParameter pall("all", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pall);
                CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
                CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
@@ -89,7 +89,7 @@ string CollectSharedCommand::getHelpString(){
                helpString += "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";
                helpString += "If you use sharedchao and run into memory issues, set all to false. \n";
                helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed.  You must enter at least 2 valid groups.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n\n";
+               helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n";
                return helpString;
        }
        catch(exception& e) {
@@ -119,7 +119,7 @@ CollectSharedCommand::CollectSharedCommand(){
                outputTypes["sharednseqs"] = tempOutNames;
                outputTypes["ochiai"] = tempOutNames;
                outputTypes["anderberg"] = tempOutNames;
-               outputTypes["skulczynski"] = tempOutNames;
+               outputTypes["kulczynski"] = tempOutNames;
                outputTypes["kulczynskicody"] = tempOutNames;
                outputTypes["lennon"] = tempOutNames;
                outputTypes["morisitahorn"] = tempOutNames;
@@ -157,6 +157,7 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                
                //allow user to run help
                if(option == "help") { help(); abort = true; calledHelp = true; }
+               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
                
                else {
                        vector<string> myArray = setParameters();
@@ -190,7 +191,7 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                        outputTypes["sharednseqs"] = tempOutNames;
                        outputTypes["ochiai"] = tempOutNames;
                        outputTypes["anderberg"] = tempOutNames;
-                       outputTypes["skulczynski"] = tempOutNames;
+                       outputTypes["kulczynski"] = tempOutNames;
                        outputTypes["kulczynskicody"] = tempOutNames;
                        outputTypes["lennon"] = tempOutNames;
                        outputTypes["morisitahorn"] = tempOutNames;
@@ -237,7 +238,7 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                                sharedfile = m->getSharedFile(); 
                                if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
                                else {  m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
+                       }else { m->setSharedFile(sharedfile); }
                        
                        
                        //if the user changes the output directory command factory will send this info to us in the output parameter 
@@ -258,6 +259,11 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                                 if (calc == "default")  {  calc = "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan";  }
                        }
                        m->splitAtDash(calc, Estimators);
+                       if (m->inUsersGroups("citation", Estimators)) { 
+                               ValidCalculators validCalc; validCalc.printCitations(Estimators); 
+                               //remove citation from list of calcs
+                               for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") {  Estimators.erase(Estimators.begin()+i); break; } }
+                       }
                        
                        groups = validParameter.validFile(parameters, "groups", false);                 
                        if (groups == "not found") { groups = ""; }
@@ -329,7 +335,7 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                                                }else if (Estimators[i] == "anderberg") { 
                                                        cDisplays.push_back(new CollectDisplay(new Anderberg(), new SharedOneColumnFile(fileNameRoot+"anderberg")));
                                                        outputNames.push_back(fileNameRoot+"anderberg"); outputTypes["anderberg"].push_back(fileNameRoot+"anderberg");
-                                               }else if (Estimators[i] == "skulczynski") { 
+                                               }else if (Estimators[i] == "kulczynski") { 
                                                        cDisplays.push_back(new CollectDisplay(new Kulczynski(), new SharedOneColumnFile(fileNameRoot+"kulczynski")));
                                                        outputNames.push_back(fileNameRoot+"kulczynski"); outputTypes["kulczynski"].push_back(fileNameRoot+"kulczynski");
                                                }else if (Estimators[i] == "kulczynskicody") { 
@@ -439,7 +445,7 @@ int CollectSharedCommand::execute(){
 
                while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                        if (m->control_pressed) { 
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }  outputTypes.clear();
+                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        }  outputTypes.clear();
                                        for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
                                        delete order; delete input;
                                        m->Groups.clear();
@@ -487,7 +493,7 @@ int CollectSharedCommand::execute(){
                }
                
                if (m->control_pressed) { 
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }   outputTypes.clear();
+                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        }   outputTypes.clear();
                                        for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
                                        m->Groups.clear();
                                        delete input;
@@ -518,7 +524,7 @@ int CollectSharedCommand::execute(){
                        delete cCurve;
                        
                        if (m->control_pressed) { 
-                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }  outputTypes.clear();
+                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        }  outputTypes.clear();
                                for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
                                delete order; 
                                delete input;