]> git.donarmstrong.com Git - mothur.git/blobdiff - pcoacommand.cpp
changes while testing
[mothur.git] / pcoacommand.cpp
index 354826f8c0b27a359b1eb1530e6a0d7a9fbaf32f..2043a128bd94bc755cb7ef10f5a8b8d9bdb5a6be 100644 (file)
 //**********************************************************************************************************************
 vector<string> PCOACommand::setParameters(){   
        try {
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip);
-               CommandParameter pmetric("metric", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pmetric);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none","pcoa-loadings",false,true,true); parameters.push_back(pphylip);
+               CommandParameter pmetric("metric", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pmetric);
+               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);          }
@@ -45,29 +45,24 @@ string PCOACommand::getHelpString(){
                exit(1);
        }
 }
-
 //**********************************************************************************************************************
-string PCOACommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string PCOACommand::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 == "pcoa") {  outputFileName =  "pcoa.axes"; }
-            else if (type == "loadings") {  outputFileName =  "pcoa.loadings"; }
-            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, "PCOACommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "pcoa") {  pattern = "[filename],pcoa.axes"; } 
+        else if (type == "loadings") {  pattern = "[filename],pcoa.loadings"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "PCOACommand", "getOutputPattern");
+        exit(1);
+    }
 }
 
+
 //**********************************************************************************************************************
 PCOACommand::PCOACommand(){    
        try {
@@ -251,7 +246,9 @@ void PCOACommand::output(string fnameRoot, vector<string> name_list, vector<vect
                }
                
                ofstream pcaData;
-        string pcoaDataFile = fnameRoot+getOutputFileNameTag("pcoa");
+        map<string, string> variables; 
+        variables["[filename]"] = fnameRoot;
+        string pcoaDataFile = getOutputFileName("pcoa",variables);
         m->openOutputFile(pcoaDataFile, pcaData);
                pcaData.setf(ios::fixed, ios::floatfield);
                pcaData.setf(ios::showpoint);   
@@ -259,7 +256,7 @@ void PCOACommand::output(string fnameRoot, vector<string> name_list, vector<vect
                outputTypes["pcoa"].push_back(pcoaDataFile);
                
                ofstream pcaLoadings;
-        string loadingsFile = fnameRoot+getOutputFileNameTag("loadings");
+        string loadingsFile = getOutputFileName("loadings",variables);
         m->openOutputFile(loadingsFile, pcaLoadings);
                pcaLoadings.setf(ios::fixed, ios::floatfield);
                pcaLoadings.setf(ios::showpoint);