]> git.donarmstrong.com Git - mothur.git/blobdiff - normalizesharedcommand.cpp
sffinfo bug with flow grams right index when clipQualRight=0
[mothur.git] / normalizesharedcommand.cpp
index e41cfd9355ce1e08157069e59880aa32066e1505..acd8208ea7ebb20a3d3810d254d0b24f5386d4d3 100644 (file)
 //**********************************************************************************************************************
 vector<string> NormalizeSharedCommand::setParameters(){        
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);    
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prelabund);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pmethod("method", "Multiple", "totalgroup-zscore", "totalgroup", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter pnorm("norm", "Number", "", "0", "", "", "",false,false); parameters.push_back(pnorm);
-               CommandParameter pmakerelabund("makerelabund", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pmakerelabund);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none","shared",false,false,true); parameters.push_back(pshared);      
+               CommandParameter prelabund("relabund", "InputTypes", "", "", "LRSS", "LRSS", "none","shared",false,false,true); parameters.push_back(prelabund);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pmethod("method", "Multiple", "totalgroup-zscore", "totalgroup", "", "", "","",false,false,true); parameters.push_back(pmethod);
+               CommandParameter pnorm("norm", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pnorm);
+               CommandParameter pmakerelabund("makerelabund", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pmakerelabund);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -53,26 +53,20 @@ string NormalizeSharedCommand::getHelpString(){
                exit(1);
        }
 }
-
 //**********************************************************************************************************************
-string NormalizeSharedCommand::getOutputFileNameTag(string type, string inputName=""){ 
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string NormalizeSharedCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //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 == "shared") {  outputFileName =  "norm.shared"; }
-            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, "NormalizeSharedCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "shared") {  pattern = "[filename],[distance],norm.shared"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "NormalizeSharedCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 NormalizeSharedCommand::NormalizeSharedCommand(){      
@@ -468,7 +462,11 @@ int NormalizeSharedCommand::normalize(vector<SharedRAbundVector*>& thisLookUp){
                
                if (pickedGroups) { eliminateZeroOTUS(thisLookUp); }
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputfile)) + thisLookUp[0]->getLabel() + "." + getOutputFileNameTag("shared");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputfile));
+        variables["[distance]"] = thisLookUp[0]->getLabel();
+               string outputFileName = getOutputFileName("shared",variables);
+        
                ofstream out;
                m->openOutputFile(outputFileName, out);
                outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);
@@ -559,7 +557,10 @@ int NormalizeSharedCommand::normalize(vector<SharedRAbundFloatVector*>& thisLook
                //save mothurOut's binLabels to restore for next label
                vector<string> saveBinLabels = m->currentBinLabels;
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputfile)) + thisLookUp[0]->getLabel() + "." + getOutputFileNameTag("shared");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputfile));
+        variables["[distance]"] = thisLookUp[0]->getLabel();
+               string outputFileName = getOutputFileName("shared",variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);