]> git.donarmstrong.com Git - mothur.git/blobdiff - clusterdoturcommand.cpp
added set.current and get.current commands and modified existing commands to update...
[mothur.git] / clusterdoturcommand.cpp
index 21840e482d4ccadcd138f35f4ef9fda1e0f7881c..5bcfe03416f90700a02a4ff3d58ad312f788bb96 100644 (file)
@@ -25,8 +25,7 @@ vector<string> ClusterDoturCommand::getValidParameters(){
 //**********************************************************************************************************************
 ClusterDoturCommand::ClusterDoturCommand(){    
        try {
-               abort = true;
-               //initialize outputTypes
+               abort = true; calledHelp = true; 
                vector<string> tempOutNames;
                outputTypes["list"] = tempOutNames;
                outputTypes["rabund"] = tempOutNames;
@@ -65,10 +64,10 @@ vector<string> ClusterDoturCommand::getRequiredFiles(){
 ClusterDoturCommand::ClusterDoturCommand(string option)  {
        try{
                
-               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
@@ -189,7 +188,7 @@ ClusterDoturCommand::~ClusterDoturCommand(){}
 int ClusterDoturCommand::execute(){
        try {
        
-               if (abort == true) {    return 0;       }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                if(namefile != ""){     
                        nameMap = new NameAssignment(namefile);
@@ -223,11 +222,11 @@ int ClusterDoturCommand::execute(){
                oldRAbund = *rabund;
                oldList = *list;
 
-               double saveCutoff = cutoff;
+               //double saveCutoff = cutoff;
                
                int estart = time(NULL);
        
-               while ((cluster->getSmallDist() < cutoff) && (cluster->getNSeqs() > 0)){
+               while ((cluster->getSmallDist() < cutoff) && (cluster->getNSeqs() > 1)){
                        if (m->control_pressed) { delete cluster; delete list; delete rabund; sabundFile.close();rabundFile.close();listFile.close();  for (int i = 0; i < outputNames.size(); i++) {   remove(outputNames[i].c_str());         } outputTypes.clear();  return 0;  }
                
                        cluster->update(cutoff);
@@ -266,10 +265,29 @@ int ClusterDoturCommand::execute(){
                
                delete cluster; delete nameMap; delete list; delete rabund;
        
-               if (saveCutoff != cutoff) { 
-                       if (hard)       {  saveCutoff = m->ceilDist(saveCutoff, precision);     }
-                       else            {       saveCutoff = m->roundDist(saveCutoff, precision);  }
-                       m->mothurOut("changed cutoff to " + toString(cutoff)); m->mothurOutEndLine(); 
+               //if (saveCutoff != cutoff) { 
+               //      if (hard)       {  saveCutoff = m->ceilDist(saveCutoff, precision);     }
+               //      else            {       saveCutoff = m->roundDist(saveCutoff, precision);  }
+               //      m->mothurOut("changed cutoff to " + toString(cutoff)); m->mothurOutEndLine(); 
+               //}
+               
+               //set list file as new current listfile
+               string current = "";
+               itTypes = outputTypes.find("list");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
+               }
+               
+               //set rabund file as new current rabundfile
+               itTypes = outputTypes.find("rabund");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
+               }
+               
+               //set sabund file as new current sabundfile
+               itTypes = outputTypes.find("sabund");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); }
                }
                
                m->mothurOutEndLine();