From 843884c927a9f910fbc2d8e3032903c313a7e2f4 Mon Sep 17 00:00:00 2001 From: westcott Date: Thu, 20 May 2010 15:19:57 +0000 Subject: [PATCH] fixed phylip convert for cluster.split command --- clustersplitcommand.cpp | 16 +++++++++++++--- readcluster.cpp | 6 +++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/clustersplitcommand.cpp b/clustersplitcommand.cpp index a1e6db0..9545083 100644 --- a/clustersplitcommand.cpp +++ b/clustersplitcommand.cpp @@ -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 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 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"); diff --git a/readcluster.cpp b/readcluster.cpp index 0893a14..af71cbc 100644 --- a/readcluster.cpp +++ b/readcluster.cpp @@ -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;icontrol_pressed) { remove(outputFile.c_str()); } return 0; -- 2.39.2