]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed phylip convert for cluster.split command
authorwestcott <westcott>
Thu, 20 May 2010 15:19:57 +0000 (15:19 +0000)
committerwestcott <westcott>
Thu, 20 May 2010 15:19:57 +0000 (15:19 +0000)
clustersplitcommand.cpp
readcluster.cpp

index a1e6db088d0d8292034d73a9f2121654fb726918..9545083f555383d5b48fa4f8e167a93ccd242558 100644 (file)
@@ -177,15 +177,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,7 +203,6 @@ int ClusterSplitCommand::execute(){
                        delete listToMakeNameFile;
                        delete convert;
                }
-               
                if (m->control_pressed) { return 0; }
                
                time_t estart = time(NULL);
@@ -372,6 +373,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 +421,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");
index 0893a146a84c9e71eb95475eabe66c2b80314c93..af71cbc96f1cca200bb8e5f66258703917f6ac53 100644 (file)
@@ -54,7 +54,7 @@ int ReadCluster::convertPhylip2Column(NameAssignment* nameMap){
                ofstream out;
                string tempFile = distFile + ".column.temp";
                
-               openInputFile(distFile, in);
+               openInputFile(distFile, in);  gobble(in);
                openOutputFile(tempFile, out);
                
                float distance;
@@ -177,7 +177,7 @@ int ReadCluster::convertPhylip2Column(NameAssignment* nameMap){
                list->setLabel("0");
                in.close();
                out.close();
-               
+       
                if(nameMap == NULL){
                        nameMap = new NameAssignment();
                        for(int i=0;i<matrixNames.size();i++){
@@ -209,7 +209,7 @@ int ReadCluster::convertPhylip2Column(NameAssignment* nameMap){
                
                remove(tempFile.c_str());
                distFile = outputFile;
-               
+       
                if (m->control_pressed) {  remove(outputFile.c_str());  }
 
                return 0;