]> git.donarmstrong.com Git - mothur.git/blobdiff - hclustercommand.cpp
fixed bugg in shhh.seqs command
[mothur.git] / hclustercommand.cpp
index e236d86cf2934a349500bbd2aacf2737d3f351b7..94082dfc74dfe0969e769572fc6df219ecaa69d2 100644 (file)
@@ -24,7 +24,7 @@ vector<string> HClusterCommand::getValidParameters(){
 //**********************************************************************************************************************
 HClusterCommand::HClusterCommand(){    
        try {
-               //initialize outputTypes
+               abort = true; calledHelp = true; 
                vector<string> tempOutNames;
                outputTypes["list"] = tempOutNames;
                outputTypes["rabund"] = tempOutNames;
@@ -63,10 +63,10 @@ vector<string> HClusterCommand::getRequiredFiles(){
 HClusterCommand::HClusterCommand(string option)  {
        try{
                globaldata = GlobalData::getInstance();
-               abort = false;
+               abort = false; calledHelp = false;   
                
                //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
@@ -170,8 +170,8 @@ HClusterCommand::HClusterCommand(string option)  {
                        method = validParameter.validFile(parameters, "method", false);
                        if (method == "not found") { method = "furthest"; }
                        
-                       if ((method == "furthest") || (method == "nearest") || (method == "average")) { }
-                       else { m->mothurOut("Not a valid clustering method.  Valid clustering algorithms are furthest, nearest or average."); m->mothurOutEndLine(); abort = true; }
+                       if ((method == "furthest") || (method == "nearest") || (method == "average") || (method == "weighted")) { }
+                       else { m->mothurOut("Not a valid clustering method.  Valid clustering algorithms are furthest, nearest, average or weighted."); m->mothurOutEndLine(); abort = true; }
 
                        showabund = validParameter.validFile(parameters, "showabund", false);
                        if (showabund == "not found") { showabund = "T"; }
@@ -191,6 +191,7 @@ HClusterCommand::HClusterCommand(string option)  {
                                
                                if (method == "furthest")               { tag = "fn";  }
                                else if (method == "nearest")   { tag = "nn";  }
+                               else if (method == "weighted")  { tag = "wn";  }
                                else                                                    { tag = "an";  }
                        
                                m->openOutputFile(fileroot+ tag + ".sabund",    sabundFile);
@@ -218,7 +219,7 @@ void HClusterCommand::help(){
                m->mothurOut("The name parameter allows you to enter your name file and is required if your distance file is in column format. \n");
                m->mothurOut("The hcluster command should be in the following format: \n");
                m->mothurOut("hcluster(column=youDistanceFile, name=yourNameFile, method=yourMethod, cutoff=yourCutoff, precision=yourPrecision) \n");
-               m->mothurOut("The acceptable hcluster methods are furthest, nearest and average.\n\n"); 
+               m->mothurOut("The acceptable hcluster methods are furthest, nearest, weighted and average.\n\n");       
        }
        catch(exception& e) {
                m->errorOut(e, "HClusterCommand", "help");
@@ -235,7 +236,7 @@ HClusterCommand::~HClusterCommand(){}
 int HClusterCommand::execute(){
        try {
        
-               if (abort == true) {    return 0;       }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                if(namefile != ""){     
                        globaldata->nameMap = new NameAssignment(namefile);