]> git.donarmstrong.com Git - mothur.git/blobdiff - collectsharedcommand.cpp
added sequence name to error string in fastq.info. Changed np_shannon to npshannon.
[mothur.git] / collectsharedcommand.cpp
index 0fe4d0f239fad770e83b68cee3f68eb9630aa368..f3a320b89e0695483a5124b6336d68cf89179293 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,17 +259,22 @@ 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 = ""; }
                        else { 
                                m->splitAtDash(groups, Groups);
                        }
-                       m->Groups = Groups;
+                       m->setGroups(Groups);
                        
                        string temp;
                        temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "100"; }
-                       convert(temp, freq); 
+                       m->mothurConvert(temp, freq); 
                        
                        temp = validParameter.validFile(parameters, "all", false);                              if (temp == "not found") { temp = "false"; }
                        all = m->isTrue(temp);
@@ -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") { 
@@ -434,15 +440,19 @@ int CollectSharedCommand::execute(){
                        
                //set users groups
                SharedUtil* util = new SharedUtil();
-               util->setGroups(m->Groups, m->namesOfGroups, "collect");
+               Groups = m->getGroups();
+               vector<string> allGroups = m->getAllGroups();
+               util->setGroups(Groups, allGroups, "collect");
+               m->setGroups(Groups);
+               m->setAllGroups(allGroups);
                delete util;
 
                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();
+                                       m->clearGroups();
                                        return 0;
                        }
 
@@ -487,9 +497,9 @@ 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();
+                                       m->clearGroups();
                                        delete input;
                                        return 0;
                }
@@ -518,11 +528,11 @@ 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;
-                               m->Groups.clear();
+                               m->clearGroups();
                                return 0;
                        }
 
@@ -532,7 +542,7 @@ int CollectSharedCommand::execute(){
                for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }       
                
                //reset groups parameter
-               m->Groups.clear(); 
+               m->clearGroups(); 
                delete input;
                
                m->mothurOutEndLine();