]> git.donarmstrong.com Git - mothur.git/blobdiff - distancecommand.cpp
working on pca
[mothur.git] / distancecommand.cpp
index a3cebe27ac3a0dec63f8b21b3d1a446864350d28..5ffe0da63cfbbafd80ab1813a66b3cdb9779725b 100644 (file)
@@ -30,8 +30,7 @@ vector<string> DistanceCommand::getValidParameters(){
 //**********************************************************************************************************************
 DistanceCommand::DistanceCommand(){    
        try {
-               abort = true;
-               //initialize outputTypes
+               abort = true; calledHelp = true; 
                vector<string> tempOutNames;
                outputTypes["phylip"] = tempOutNames;
                outputTypes["column"] = tempOutNames;
@@ -67,11 +66,11 @@ vector<string> DistanceCommand::getRequiredFiles(){
 //**********************************************************************************************************************
 DistanceCommand::DistanceCommand(string option) {
        try {
-               abort = false;
+               abort = false; calledHelp = false;   
                Estimators.clear();
                                
                //allow user to run help
-               if(option == "help") { help(); abort = true; }
+               if(option == "help") { help(); abort = true; calledHelp = true; }
                
                else {
                        //valid paramters for this command
@@ -242,7 +241,7 @@ void DistanceCommand::help(){
 int DistanceCommand::execute(){
        try {
                
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                int startTime = time(NULL);
                
@@ -502,6 +501,19 @@ int DistanceCommand::execute(){
                
                delete distCalculator;
                
+               //set phylip file as new current phylipfile
+               string current = "";
+               itTypes = outputTypes.find("phylip");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setPhylipFile(current); }
+               }
+               
+               //set column file as new current columnfile
+               itTypes = outputTypes.find("column");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setColumnFile(current); }
+               }
+               
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
                m->mothurOut(outputFile); m->mothurOutEndLine();