]> git.donarmstrong.com Git - mothur.git/blobdiff - clustersplitcommand.cpp
changes to chop.seqs
[mothur.git] / clustersplitcommand.cpp
index a1e6db088d0d8292034d73a9f2121654fb726918..ab8bdcfdfa6ea950745c857efe482352bbc19d4c 100644 (file)
@@ -27,7 +27,7 @@ ClusterSplitCommand::ClusterSplitCommand(string option)  {
                
                else {
                        //valid paramters for this command
-                       string Array[] =  {"phylip","column","name","cutoff","precision","method","showabund","timing","hard","processors","splitcutoff","outputdir","inputdir"};
+                       string Array[] =  {"phylip","column","name","cutoff","precision","method","showabund","timing","hard","processors","outputdir","inputdir"};
                        vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
                        
                        OptionParser parser(option);
@@ -121,11 +121,6 @@ ClusterSplitCommand::ClusterSplitCommand(string option)  {
                        convert(temp, cutoff); 
                        if (!hard) {    cutoff += (5 / (precision * 10.0));  }
                        
-                       temp = validParameter.validFile(parameters, "splitcutoff", false);
-                       if (temp == "not found") { temp = "0.10"; }
-                       convert(temp, splitcutoff); 
-                       if (!hard) {    splitcutoff += (5 / (precision * 10.0));  }
-                       
                        method = validParameter.validFile(parameters, "method", false);
                        if (method == "not found") { method = "furthest"; }
                        
@@ -177,15 +172,17 @@ int ClusterSplitCommand::execute(){
                
                //if user gave a phylip file convert to column file
                if (format == "phylip") {
+       
                        ReadCluster* convert = new ReadCluster(distfile, cutoff, outputDir, false);
                        
                        NameAssignment* nameMap = NULL;
+                       convert->setFormat("phylip");
                        convert->read(nameMap);
                        
                        if (m->control_pressed) {  delete convert;  return 0;  }
                        
-                       string distfile = convert->getOutputFile();
-                       
+                       distfile = convert->getOutputFile();
+               
                        //if no names file given with phylip file, create it
                        ListVector* listToMakeNameFile =  convert->getListVector();
                        if (namefile == "") {  //you need to make a namefile for split matrix
@@ -201,13 +198,12 @@ int ClusterSplitCommand::execute(){
                        delete listToMakeNameFile;
                        delete convert;
                }
-               
                if (m->control_pressed) { return 0; }
                
                time_t estart = time(NULL);
                
                //split matrix into non-overlapping groups
-               SplitMatrix* split = new SplitMatrix(distfile, namefile, splitcutoff);
+               SplitMatrix* split = new SplitMatrix(distfile, namefile, cutoff);
                split->split();
                
                if (m->control_pressed) { delete split; return 0; }
@@ -241,6 +237,12 @@ int ClusterSplitCommand::execute(){
                                                dividedNames[(processToAssign-1)].push_back(distName[i]);
                                        }
                                        
+                                       //not lets reverse the order of ever other process, so we balance big files running with little ones
+                                       for (int i = 0; i < processors; i++) {
+                                               int remainder = ((i+1) % processors);
+                                               if (remainder) {  reverse(dividedNames[i].begin(), dividedNames[i].end());  }
+                                       }
+                                       
                                        createProcesses(dividedNames);
                                                        
                                        if (m->control_pressed) { return 0; }
@@ -372,6 +374,13 @@ int ClusterSplitCommand::mergeLists(vector<string> listNames, string singleton,
                        //get the list info from each file
                        for (int k = 0; k < listNames.size(); k++) {
        
+                               if (m->control_pressed) {  
+                                       if (listSingle != NULL) { delete listSingle; remove(singleton.c_str());  }
+                                       for (int i = 0; i < listNames.size(); i++) {  delete inputs[i];  remove(listNames[i].c_str());  }
+                                       delete merged; merged = NULL;
+                                       return 0;
+                               }
+                               
                                ListVector* list = inputs[k]->getListVector();
                                
                                //this file has reached the end
@@ -413,6 +422,8 @@ int ClusterSplitCommand::mergeLists(vector<string> listNames, string singleton,
                if (listSingle != NULL) { delete listSingle; remove(singleton.c_str());  }
                
                for (int i = 0; i < listNames.size(); i++) {  delete inputs[i];  remove(listNames[i].c_str());  }
+               
+               return 0;
        }
        catch(exception& e) {
                m->errorOut(e, "ClusterSplitCommand", "mergeLists");