]> git.donarmstrong.com Git - mothur.git/blobdiff - mantelcommand.cpp
fixes while testing 1.33.0
[mothur.git] / mantelcommand.cpp
index 0c0163b538a747ca5b9b4eb82ef57a06ca302b91..b9e4df93eff8b19bece4740e22c6526736b1faf2 100644 (file)
 //**********************************************************************************************************************
 vector<string> MantelCommand::setParameters(){ 
        try {
-               CommandParameter pphylip1("phylip1", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip1);
-               CommandParameter pphylip2("phylip2", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip2);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pmethod("method", "Multiple", "pearson-spearman-kendall", "pearson", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pphylip1("phylip1", "InputTypes", "", "", "none", "none", "none","mantel",false,true,true); parameters.push_back(pphylip1);
+               CommandParameter pphylip2("phylip2", "InputTypes", "", "", "none", "none", "none","mantel",false,true,true); parameters.push_back(pphylip2);
+               CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter pmethod("method", "Multiple", "pearson-spearman-kendall", "pearson", "", "", "","",false,false); parameters.push_back(pmethod);
+               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);          }
@@ -50,6 +50,21 @@ string MantelCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string MantelCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
+        
+        if (type == "mantel") {  pattern = "[filename],mantel"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "MantelCommand", "getOutputPattern");
+        exit(1);
+    }
+}
+//**********************************************************************************************************************
 MantelCommand::MantelCommand(){        
        try {
                abort = true; calledHelp = true;
@@ -69,6 +84,7 @@ MantelCommand::MantelCommand(string option)  {
                
                //allow user to run help
                if(option == "help") { help(); abort = true; calledHelp = true; }
+               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
                
                else {
                        vector<string> myArray = setParameters();
@@ -124,7 +140,7 @@ MantelCommand::MantelCommand(string option)  {
                        method = validParameter.validFile(parameters, "method", false);         if (method == "not found"){     method = "pearson";             }
                        
                        string temp = validParameter.validFile(parameters, "iters", false);                     if (temp == "not found") { temp = "1000"; }
-                       convert(temp, iters);
+                       m->mothurConvert(temp, iters);
                        
                        if ((method != "pearson") && (method != "spearman") && (method != "kendall")) { m->mothurOut(method + " is not a valid method. Valid methods are pearson, spearman, and kendall."); m->mothurOutEndLine(); abort = true; }
                }
@@ -205,7 +221,9 @@ int MantelCommand::execute(){
                
                if (m->control_pressed) { return 0; }
                
-               string outputFile = outputDir + m->getRootName(m->getSimpleName(phylipfile1)) + "mantel";
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(phylipfile1));
+               string outputFile = getOutputFileName("mantel",variables);
                outputNames.push_back(outputFile); outputTypes["mantel"].push_back(outputFile);
                ofstream out;