]> git.donarmstrong.com Git - mothur.git/blobdiff - clusterdoturcommand.cpp
added load.logfile command. changed summary.single output for subsample=t.
[mothur.git] / clusterdoturcommand.cpp
index 603bd73d680b485fb4df6ef6cf62e935af3f1ff5..9bfb52b9d92b0222af2e4b1acff37c82f968349f 100644 (file)
@@ -49,6 +49,28 @@ string ClusterDoturCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string ClusterDoturCommand::getOutputFileNameTag(string type, string inputName=""){    
+       try {
+        string outputFileName = "";
+               map<string, vector<string> >::iterator it;
+        
+        //is this a type this command creates
+        it = outputTypes.find(type);
+        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
+        else {
+            if (type == "list") {  outputFileName =  "list"; }
+            else if (type == "rabund") {  outputFileName =  "rabund"; }
+            else if (type == "sabund") {  outputFileName =  "sabund"; }
+            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
+        }
+        return outputFileName;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClusterDoturCommand", "getOutputFileNameTag");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 ClusterDoturCommand::ClusterDoturCommand(){    
        try {
                abort = true; calledHelp = true;
@@ -201,13 +223,17 @@ int ClusterDoturCommand::execute(){
                if (outputDir == "") { outputDir += m->hasPath(phylipfile); }
                fileroot = outputDir + m->getRootName(m->getSimpleName(phylipfile));
                        
-               m->openOutputFile(fileroot+ tag + ".sabund",    sabundFile);
-               m->openOutputFile(fileroot+ tag + ".rabund",    rabundFile);
-               m->openOutputFile(fileroot+ tag + ".list",              listFile);
-                               
-               outputNames.push_back(fileroot+ tag + ".sabund"); outputTypes["sabund"].push_back(fileroot+ tag + ".sabund");
-               outputNames.push_back(fileroot+ tag + ".rabund"); outputTypes["rabund"].push_back(fileroot+ tag + ".rabund");
-               outputNames.push_back(fileroot+ tag + ".list"); outputTypes["list"].push_back(fileroot+ tag + ".list");
+        string sabundFileName = fileroot+ tag + "." + getOutputFileNameTag("sabund");
+        string rabundFileName = fileroot+ tag + "." + getOutputFileNameTag("rabund");
+        string listFileName = fileroot+ tag + "." + getOutputFileNameTag("list");
+        
+               m->openOutputFile(sabundFileName,       sabundFile);
+               m->openOutputFile(rabundFileName,       rabundFile);
+               m->openOutputFile(listFileName, listFile);
+               
+               outputNames.push_back(sabundFileName); outputTypes["sabund"].push_back(sabundFileName);
+               outputNames.push_back(rabundFileName); outputTypes["rabund"].push_back(rabundFileName);
+               outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName);
                
                float previousDist = 0.00000;
                float rndPreviousDist = 0.00000;