]> git.donarmstrong.com Git - mothur.git/blobdiff - deconvolutecommand.cpp
added load.logfile command. changed summary.single output for subsample=t.
[mothur.git] / deconvolutecommand.cpp
index 3d0c0d51acaac8844b71a3efa40c7925674ad4c5..bab5a634cd101507957dabc22e34e429c5ec5b1b 100644 (file)
@@ -45,6 +45,27 @@ string DeconvoluteCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string DeconvoluteCommand::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 == "fasta") {  outputFileName =  "unique" + m->getExtension(inputName); }
+            else if (type == "name") {  outputFileName =  "names"; }
+            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, "DeconvoluteCommand", "getOutputFileNameTag");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 DeconvoluteCommand::DeconvoluteCommand(){      
        try {
                abort = true; calledHelp = true; 
@@ -149,14 +170,14 @@ int DeconvoluteCommand::execute() {
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
 
                //prepare filenames and open files
-               string outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "names";
-               string outFastaFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "unique" + m->getExtension(inFastaName);
+               string outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + getOutputFileNameTag("name");
+               string outFastaFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + getOutputFileNameTag("fasta", inFastaName);
                
                map<string, string> nameMap;
                map<string, string>::iterator itNames;
                if (oldNameMapFName != "")  {  
             m->readNames(oldNameMapFName, nameMap); 
-            if (oldNameMapFName == outNameFile){ outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "unique.names";   }
+            if (oldNameMapFName == outNameFile){ outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "unique." + getOutputFileNameTag("name");   }
         }
                
                if (m->control_pressed) { return 0; }