]> git.donarmstrong.com Git - mothur.git/blobdiff - getlistcountcommand.cpp
true chimera testing using reference sequences
[mothur.git] / getlistcountcommand.cpp
index 43280edd76b1c924ed87572412977f682d3d7b17..1ecef653e11fe15d206b41fd958834be194455ff 100644 (file)
@@ -9,6 +9,54 @@
 
 #include "getlistcountcommand.h"
 
+//**********************************************************************************************************************
+vector<string> GetListCountCommand::getValidParameters(){      
+       try {
+               string Array[] =  {"list","label","sort","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetListCountCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+GetListCountCommand::GetListCountCommand(){    
+       try {
+               abort = true;
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["otu"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetListCountCommand", "GetListCountCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetListCountCommand::getRequiredParameters(){   
+       try {
+               string Array[] =  {"list"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetListCountCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetListCountCommand::getRequiredFiles(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetListCountCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 GetListCountCommand::GetListCountCommand(string option)  {
        try {
@@ -36,6 +84,10 @@ GetListCountCommand::GetListCountCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["otu"] = tempOutNames;
+               
                        string ranRead = globaldata->getListFile();
                        
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
@@ -46,7 +98,7 @@ GetListCountCommand::GetListCountCommand(string option)  {
                                it = parameters.find("list");
                                //user has given a template file
                                if(it != parameters.end()){ 
-                                       path = hasPath(it->second);
+                                       path = m->hasPath(it->second);
                                        //if the user has not given a path then, add inputdir. else leave path alone.
                                        if (path == "") {       parameters["list"] = inputDir + it->second;             }
                                }
@@ -70,7 +122,7 @@ GetListCountCommand::GetListCountCommand(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;  }
                        }
                        
@@ -152,7 +204,7 @@ int GetListCountCommand::execute(){
                                        delete input;
                                        delete list;
                                        globaldata->gListVector = NULL;  
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                        return 0; 
                                }
                                                        
@@ -160,7 +212,7 @@ int GetListCountCommand::execute(){
                                userLabels.erase(list->getLabel());
                        }
                        
-                       if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                       if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
                                string saveLabel = list->getLabel();
                                
                                delete list;
@@ -173,7 +225,7 @@ int GetListCountCommand::execute(){
                                        delete input;
                                        delete list;
                                        globaldata->gListVector = NULL;  
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                        return 0; 
                                }
                                                                                                        
@@ -216,7 +268,7 @@ int GetListCountCommand::execute(){
                                        delete input;
                                        delete list;
                                        globaldata->gListVector = NULL;  
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                        return 0; 
                        }
                        
@@ -245,10 +297,10 @@ int GetListCountCommand::execute(){
 void GetListCountCommand::process(ListVector* list) {
        try {
                string binnames;
-               if (outputDir == "") { outputDir += hasPath(listfile); }
-               string outputFileName = outputDir + getRootName(getSimpleName(listfile)) + list->getLabel() + ".otu";
-               openOutputFile(outputFileName, out);
-               outputNames.push_back(outputFileName);
+               if (outputDir == "") { outputDir += m->hasPath(listfile); }
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + list->getLabel() + ".otu";
+               m->openOutputFile(outputFileName, out);
+               outputNames.push_back(outputFileName); outputTypes["otu"].push_back(outputFileName);
                
                m->mothurOut(list->getLabel()); m->mothurOutEndLine();
                
@@ -262,7 +314,7 @@ void GetListCountCommand::process(ListVector* list) {
                                out << i+1 << '\t' << binnames << endl;
                        }else{ //sort = name
                                vector<string> names;
-                               splitAtComma(binnames, names);
+                               m->splitAtComma(binnames, names);
                                
                                for (int j = 0; j < names.size(); j++) {
                                        out << names[j] << '\t' << i+1 << endl;