From 71b2121662daae3f9044252887d1c16eeddd85bb Mon Sep 17 00:00:00 2001 From: westcott Date: Wed, 5 Aug 2009 18:32:19 +0000 Subject: [PATCH] bugs fixes while testing for 1.5 release --- binsequencecommand.cpp | 10 +++++----- binsequencecommand.h | 2 +- bootstrapsharedcommand.cpp | 6 +++--- chao1.cpp | 16 +++++++++++++--- collectcommand.cpp | 6 +++--- collectdisplay.h | 3 +++ collectorscurvedata.h | 1 + display.h | 3 ++- fileoutput.cpp | 34 ++++++++++++++++++++++------------ getoturepcommand.cpp | 6 +++--- getrabundcommand.cpp | 6 +++--- getsabundcommand.cpp | 6 +++--- heatmapcommand.cpp | 12 ++++++------ heatmapsimcommand.cpp | 6 +++--- matrixoutputcommand.cpp | 6 +++--- mothur.h | 3 ++- rarefactcommand.cpp | 6 +++--- rarefactsharedcommand.cpp | 6 +++--- sharedchao1.cpp | 2 +- sharedcommand.cpp | 6 +++--- summarycommand.cpp | 6 +++--- summarysharedcommand.cpp | 6 +++--- tree.cpp | 28 ++++++++++++++++------------ treegroupscommand.cpp | 6 +++--- venncommand.cpp | 12 ++++++------ 25 files changed, 117 insertions(+), 87 deletions(-) diff --git a/binsequencecommand.cpp b/binsequencecommand.cpp index 8805737..e1f98eb 100644 --- a/binsequencecommand.cpp +++ b/binsequencecommand.cpp @@ -170,7 +170,7 @@ int BinSeqCommand::execute(){ if(allLines == 1 || lines.count(count) == 1 || labels.count(list->getLabel()) == 1){ - error = process(list, count); + error = process(list); if (error == 1) { return 0; } processedLabels.insert(list->getLabel()); @@ -182,7 +182,7 @@ int BinSeqCommand::execute(){ delete list; list = input->getListVector(lastLabel); - error = process(list, count); + error = process(list); if (error == 1) { return 0; } processedLabels.insert(list->getLabel()); @@ -216,7 +216,7 @@ int BinSeqCommand::execute(){ delete list; list = input->getListVector(lastLabel); - error = process(list, count); + error = process(list); if (error == 1) { return 0; } delete list; @@ -265,13 +265,13 @@ void BinSeqCommand::readNamesFile() { } //********************************************************************************************************************** //return 1 if error, 0 otherwise -int BinSeqCommand::process(ListVector* list, int count) { +int BinSeqCommand::process(ListVector* list) { try { string binnames, name, sequence; string outputFileName = getRootName(globaldata->getListFile()) + list->getLabel() + ".fasta"; openOutputFile(outputFileName, out); - mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(list->getLabel()); mothurOutEndLine(); //for each bin in the list vector for (int i = 0; i < list->size(); i++) { diff --git a/binsequencecommand.h b/binsequencecommand.h index 6f9f69d..8ea88cb 100644 --- a/binsequencecommand.h +++ b/binsequencecommand.h @@ -44,7 +44,7 @@ private: ifstream in, inNames; void readNamesFile(); - int process(ListVector*, int); + int process(ListVector*); }; #endif diff --git a/bootstrapsharedcommand.cpp b/bootstrapsharedcommand.cpp index a3717fe..12c0b5e 100644 --- a/bootstrapsharedcommand.cpp +++ b/bootstrapsharedcommand.cpp @@ -228,7 +228,7 @@ int BootSharedCommand::execute(){ if(allLines == 1 || lines.count(count) == 1 || labels.count(order->getLabel()) == 1){ - mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(order->getLabel()); mothurOutEndLine(); process(order); processedLabels.insert(order->getLabel()); @@ -241,7 +241,7 @@ int BootSharedCommand::execute(){ delete order; order = input->getSharedOrderVector(lastLabel); - mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(order->getLabel()); mothurOutEndLine(); process(order); processedLabels.insert(order->getLabel()); @@ -274,7 +274,7 @@ int BootSharedCommand::execute(){ if (needToRun == true) { delete order; order = input->getSharedOrderVector(lastLabel); - mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(order->getLabel()); mothurOutEndLine(); process(order); delete order; diff --git a/chao1.cpp b/chao1.cpp index 24521f5..590c20e 100644 --- a/chao1.cpp +++ b/chao1.cpp @@ -15,9 +15,19 @@ EstOutput Chao1::getValues(SAbundVector* rank){ data.resize(3,0); double sobs = (double)rank->getNumBins(); - - double singles = (double)rank->get(1); - double doubles = (double)rank->get(2); + + //this is a modification do to a vector fill error that occurs when an empty sharedRabund creates a sabund + //in that case there is no 1 0r 2. + double singles; + if (rank->size() > 1) { + singles = (double)rank->get(1); + }else{ singles = 0.0; } + + double doubles; + if (rank->size() > 2) { + doubles = (double)rank->get(2); + }else{ doubles = 0.0; } + double chaovar = 0.0000; //cout << "singles = " << singles << " doubles = " << doubles << " sobs = " << sobs << endl; double chao = sobs + singles*(singles-1)/(2*(doubles+1)); diff --git a/collectcommand.cpp b/collectcommand.cpp index c3a58d6..fac13ec 100644 --- a/collectcommand.cpp +++ b/collectcommand.cpp @@ -227,7 +227,7 @@ int CollectCommand::execute(){ cCurve->getCurve(freq); delete cCurve; - mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(order->getLabel()); mothurOutEndLine(); processedLabels.insert(order->getLabel()); userLabels.erase(order->getLabel()); userLines.erase(count); @@ -244,7 +244,7 @@ int CollectCommand::execute(){ cCurve->getCurve(freq); delete cCurve; - mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(order->getLabel()); mothurOutEndLine(); processedLabels.insert(order->getLabel()); userLabels.erase(order->getLabel()); } @@ -274,7 +274,7 @@ int CollectCommand::execute(){ delete order; order = (input->getOrderVector(lastLabel)); - mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(order->getLabel()); mothurOutEndLine(); cCurve = new Collect(order, cDisplays); cCurve->getCurve(freq); diff --git a/collectdisplay.h b/collectdisplay.h index 4fe3588..0f18da6 100644 --- a/collectdisplay.h +++ b/collectdisplay.h @@ -76,7 +76,10 @@ public: void close() { output->resetFile(); }; bool isCalcMultiple() { return estimate->getMultiple(); } + string getName() { return estimate->getName(); } + private: + Calculator* estimate; FileOutput* output; int nSeqs, timesCalled, numGroupComb; diff --git a/collectorscurvedata.h b/collectorscurvedata.h index 5cbe2be..d90e84a 100644 --- a/collectorscurvedata.h +++ b/collectorscurvedata.h @@ -47,6 +47,7 @@ public: void notifyDisplays(){ for(set::iterator pos=displays.begin();pos!=displays.end();pos++){ +//cout << (*pos)->getName() << endl; if ( ((*pos)->isCalcMultiple() == true) || ( ((*pos)->isCalcMultiple() == false) && (shared.size() == 2) ) ) { (*pos)->update(shared, NumSeqs, NumGroupComb); } diff --git a/display.h b/display.h index ee827e5..398d684 100644 --- a/display.h +++ b/display.h @@ -18,10 +18,11 @@ public: virtual void reset() = 0; virtual void close() = 0; virtual bool isCalcMultiple() = 0; + virtual string getName() { return ""; }; virtual ~Display() {} private: - + }; /***********************************************************************/ diff --git a/fileoutput.cpp b/fileoutput.cpp index 597a05a..004ed83 100644 --- a/fileoutput.cpp +++ b/fileoutput.cpp @@ -82,8 +82,10 @@ void ThreeColumnFile::resetFile(){ renameOk = rename(outName.c_str(), inName.c_str()); //checks to make sure user was able to rename and remove successfully - if ((renameOk != 0)) { mothurOut("Unable to rename necessary files."); mothurOutEndLine(); } - + if ((renameOk != 0)) { + mothurOut("Unable to rename " + outName); mothurOutEndLine(); + perror(" : "); + } } catch(exception& e) { errorOut(e, "ThreeColumnFile", "resetFile"); @@ -182,8 +184,10 @@ void ColumnFile::resetFile(){ renameOk = rename(outName.c_str(), inName.c_str()); //checks to make sure user was able to rename and remove successfully - if ((renameOk != 0)) { mothurOut("Unable to rename necessary files."); mothurOutEndLine(); } - + if ((renameOk != 0)) { + mothurOut("Unable to rename " + outName); mothurOutEndLine(); + perror(" : "); + } } catch(exception& e) { errorOut(e, "ColumnFile", "resetFile"); @@ -265,8 +269,10 @@ void SharedThreeColumnFile::resetFile(){ renameOk = rename(outName.c_str(), inName.c_str()); //checks to make sure user was able to rename and remove successfully - if ((renameOk != 0)) { mothurOut("Unable to rename necessary files."); mothurOutEndLine(); } - + if ((renameOk != 0)) { + mothurOut("Unable to rename " + outName); mothurOutEndLine(); + perror(" : "); + } } catch(exception& e) { errorOut(e, "SharedThreeColumnFile", "resetFile"); @@ -348,8 +354,10 @@ void OneColumnFile::resetFile(){ renameOk = rename(outName.c_str(), inName.c_str()); //checks to make sure user was able to rename and remove successfully - if ((renameOk != 0)) { mothurOut("Unable to rename necessary files."); mothurOutEndLine(); } - + if ((renameOk != 0)) { + mothurOut("Unable to rename " + outName); mothurOutEndLine(); + perror(" : "); + } } catch(exception& e) { errorOut(e, "OneColumnFile", "resetFile"); @@ -435,14 +443,16 @@ void SharedOneColumnFile::resetFile(){ outFile.close(); } counter = 1; - + remove(inName.c_str()); + renameOk = rename(outName.c_str(), inName.c_str()); //checks to make sure user was able to rename and remove successfully - if ((renameOk != 0)) { mothurOut("Unable to rename necessary files."); mothurOutEndLine(); } - - + if ((renameOk != 0)) { + mothurOut("Unable to rename " + outName); mothurOutEndLine(); + perror(" : "); + } } catch(exception& e) { errorOut(e, "SharedOneColumnFile", "resetFile"); diff --git a/getoturepcommand.cpp b/getoturepcommand.cpp index 92ba3ad..4aab740 100644 --- a/getoturepcommand.cpp +++ b/getoturepcommand.cpp @@ -204,7 +204,7 @@ int GetOTURepCommand::execute(){ while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) { if (allLines == 1 || lines.count(count) == 1 || labels.count(list->getLabel()) == 1){ - mothurOut(list->getLabel() + "\t" + toString(list->size()) + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(list->getLabel() + "\t" + toString(list->size())); mothurOutEndLine(); error = process(list); if (error == 1) { return 0; } //there is an error in hte input files, abort command @@ -216,7 +216,7 @@ int GetOTURepCommand::execute(){ if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) { delete list; list = input->getListVector(lastLabel); - mothurOut(list->getLabel() + "\t" + toString(list->size()) + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(list->getLabel() + "\t" + toString(list->size())); mothurOutEndLine(); error = process(list); if (error == 1) { return 0; } //there is an error in hte input files, abort command @@ -247,7 +247,7 @@ int GetOTURepCommand::execute(){ if (needToRun == true) { delete list; list = input->getListVector(lastLabel); - mothurOut(list->getLabel() + "\t" + toString(list->size()) + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(list->getLabel() + "\t" + toString(list->size())); mothurOutEndLine(); error = process(list); delete list; if (error == 1) { return 0; } //there is an error in hte input files, abort command diff --git a/getrabundcommand.cpp b/getrabundcommand.cpp index b0bf819..8718e16 100644 --- a/getrabundcommand.cpp +++ b/getrabundcommand.cpp @@ -134,7 +134,7 @@ int GetRAbundCommand::execute(){ while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) { if(allLines == 1 || lines.count(count) == 1 || labels.count(list->getLabel()) == 1){ - mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(list->getLabel()); mothurOutEndLine(); rabund = new RAbundVector(); *rabund = (list->getRAbundVector()); @@ -152,7 +152,7 @@ int GetRAbundCommand::execute(){ delete list; list = input->getListVector(lastLabel); - mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(list->getLabel()); mothurOutEndLine(); rabund = new RAbundVector(); *rabund = (list->getRAbundVector()); @@ -190,7 +190,7 @@ int GetRAbundCommand::execute(){ delete list; list = input->getListVector(lastLabel); - mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(list->getLabel()); mothurOutEndLine(); rabund = new RAbundVector(); *rabund = (list->getRAbundVector()); diff --git a/getsabundcommand.cpp b/getsabundcommand.cpp index 0be26ce..5d99b69 100644 --- a/getsabundcommand.cpp +++ b/getsabundcommand.cpp @@ -127,7 +127,7 @@ int GetSAbundCommand::execute(){ while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) { if(allLines == 1 || lines.count(count) == 1 || labels.count(order->getLabel()) == 1){ - mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(order->getLabel()); mothurOutEndLine(); sabund = new SAbundVector(); *sabund = (order->getSAbundVector()); sabund->print(out); @@ -142,7 +142,7 @@ int GetSAbundCommand::execute(){ delete order; order = (input->getOrderVector(lastLabel)); - mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(order->getLabel()); mothurOutEndLine(); sabund = new SAbundVector(); *sabund = (order->getSAbundVector()); sabund->print(out); @@ -178,7 +178,7 @@ int GetSAbundCommand::execute(){ delete order; order = (input->getOrderVector(lastLabel)); - mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(order->getLabel()); mothurOutEndLine(); sabund = new SAbundVector(); *sabund = (order->getSAbundVector()); sabund->print(out); diff --git a/heatmapcommand.cpp b/heatmapcommand.cpp index e21b14d..271a379 100644 --- a/heatmapcommand.cpp +++ b/heatmapcommand.cpp @@ -168,7 +168,7 @@ int HeatMapCommand::execute(){ if(allLines == 1 || lines.count(count) == 1 || labels.count(lookup[0]->getLabel()) == 1){ - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); heatmap->getPic(lookup); processedLabels.insert(lookup[0]->getLabel()); @@ -179,7 +179,7 @@ int HeatMapCommand::execute(){ if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) { for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(lastLabel); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); heatmap->getPic(lookup); @@ -214,7 +214,7 @@ int HeatMapCommand::execute(){ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(lastLabel); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); heatmap->getPic(lookup); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } } @@ -230,7 +230,7 @@ int HeatMapCommand::execute(){ if(allLines == 1 || lines.count(count) == 1 || labels.count(rabund->getLabel()) == 1){ - mothurOut(rabund->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(rabund->getLabel()); mothurOutEndLine(); heatmap->getPic(rabund); processedLabels.insert(rabund->getLabel()); @@ -242,7 +242,7 @@ int HeatMapCommand::execute(){ delete rabund; rabund = input->getRAbundVector(lastLabel); - mothurOut(rabund->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(rabund->getLabel()); mothurOutEndLine(); heatmap->getPic(rabund); @@ -276,7 +276,7 @@ int HeatMapCommand::execute(){ delete rabund; rabund = input->getRAbundVector(lastLabel); - mothurOut(rabund->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(rabund->getLabel()); mothurOutEndLine(); heatmap->getPic(rabund); delete rabund; globaldata->rabund = NULL; diff --git a/heatmapsimcommand.cpp b/heatmapsimcommand.cpp index b9216e4..1b00298 100644 --- a/heatmapsimcommand.cpp +++ b/heatmapsimcommand.cpp @@ -204,7 +204,7 @@ int HeatMapSimCommand::execute(){ if(allLines == 1 || lines.count(count) == 1 || labels.count(lookup[0]->getLabel()) == 1){ - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); heatmap->getPic(lookup, heatCalculators); processedLabels.insert(lookup[0]->getLabel()); @@ -217,7 +217,7 @@ int HeatMapSimCommand::execute(){ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(lastLabel); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); heatmap->getPic(lookup, heatCalculators); processedLabels.insert(lookup[0]->getLabel()); @@ -252,7 +252,7 @@ int HeatMapSimCommand::execute(){ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(lastLabel); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); heatmap->getPic(lookup, heatCalculators); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } } diff --git a/matrixoutputcommand.cpp b/matrixoutputcommand.cpp index 64ec2a5..00dff4b 100644 --- a/matrixoutputcommand.cpp +++ b/matrixoutputcommand.cpp @@ -202,7 +202,7 @@ int MatrixOutputCommand::execute(){ while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) { if(allLines == 1 || lines.count(count) == 1 || labels.count(lookup[0]->getLabel()) == 1){ - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); process(lookup); processedLabels.insert(lookup[0]->getLabel()); @@ -215,7 +215,7 @@ int MatrixOutputCommand::execute(){ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(lastLabel); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); process(lookup); processedLabels.insert(lookup[0]->getLabel()); @@ -249,7 +249,7 @@ int MatrixOutputCommand::execute(){ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(lastLabel); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); process(lookup); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } } diff --git a/mothur.h b/mothur.h index 5b519bb..ed206af 100644 --- a/mothur.h +++ b/mothur.h @@ -44,10 +44,11 @@ #include #include #include -#include + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) #include + #include #endif using namespace std; diff --git a/rarefactcommand.cpp b/rarefactcommand.cpp index ee0c38f..41c38e8 100644 --- a/rarefactcommand.cpp +++ b/rarefactcommand.cpp @@ -203,7 +203,7 @@ int RareFactCommand::execute(){ rCurve->getCurve(freq, nIters); delete rCurve; - mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(order->getLabel()); mothurOutEndLine(); processedLabels.insert(order->getLabel()); userLabels.erase(order->getLabel()); userLines.erase(count); @@ -217,7 +217,7 @@ int RareFactCommand::execute(){ rCurve->getCurve(freq, nIters); delete rCurve; - mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(order->getLabel()); mothurOutEndLine(); processedLabels.insert(order->getLabel()); userLabels.erase(order->getLabel()); } @@ -251,7 +251,7 @@ int RareFactCommand::execute(){ rCurve->getCurve(freq, nIters); delete rCurve; - mothurOut(order->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(order->getLabel()); mothurOutEndLine(); delete order; } diff --git a/rarefactsharedcommand.cpp b/rarefactsharedcommand.cpp index 5914f15..79bf7bb 100644 --- a/rarefactsharedcommand.cpp +++ b/rarefactsharedcommand.cpp @@ -196,7 +196,7 @@ int RareFactSharedCommand::execute(){ rCurve->getSharedCurve(freq, nIters); delete rCurve; - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); processedLabels.insert(lookup[0]->getLabel()); userLabels.erase(lookup[0]->getLabel()); userLines.erase(count); @@ -206,7 +206,7 @@ int RareFactSharedCommand::execute(){ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(lastLabel); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); rCurve = new Rarefact(lookup, rDisplays); rCurve->getSharedCurve(freq, nIters); delete rCurve; @@ -242,7 +242,7 @@ int RareFactSharedCommand::execute(){ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(lastLabel); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); rCurve = new Rarefact(lookup, rDisplays); rCurve->getSharedCurve(freq, nIters); delete rCurve; diff --git a/sharedchao1.cpp b/sharedchao1.cpp index cbb5192..a28f609 100644 --- a/sharedchao1.cpp +++ b/sharedchao1.cpp @@ -48,7 +48,7 @@ EstOutput SharedChao1::getValues(vector shared){ //calculate chao1, (numleaves-1) because numleaves contains the ++ values. - bool bias; + bool bias = false; for(int i=0;ilvalue == 0 || f2leaves[i]->rvalue == 0) { bias = true;}// break;} } diff --git a/sharedcommand.cpp b/sharedcommand.cpp index 9afb401..c49e56a 100644 --- a/sharedcommand.cpp +++ b/sharedcommand.cpp @@ -75,7 +75,7 @@ int SharedCommand::execute(){ if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(SharedList->getLabel()) == 1){ lookup = SharedList->getSharedRAbundVector(); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); printSharedData(lookup); //prints info to the .shared file for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } @@ -90,7 +90,7 @@ int SharedCommand::execute(){ SharedList = input->getSharedListVector(lastLabel); //get new list vector to process lookup = SharedList->getSharedRAbundVector(); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); printSharedData(lookup); //prints info to the .shared file for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } @@ -123,7 +123,7 @@ int SharedCommand::execute(){ SharedList = input->getSharedListVector(lastLabel); //get new list vector to process lookup = SharedList->getSharedRAbundVector(); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); printSharedData(lookup); //prints info to the .shared file for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } diff --git a/summarycommand.cpp b/summarycommand.cpp index 228b933..6ef1fae 100644 --- a/summarycommand.cpp +++ b/summarycommand.cpp @@ -236,7 +236,7 @@ int SummaryCommand::execute(){ if(allLines == 1 || lines.count(count) == 1 || labels.count(sabund->getLabel()) == 1){ - mothurOut(sabund->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(sabund->getLabel()); mothurOutEndLine(); processedLabels.insert(sabund->getLabel()); userLabels.erase(sabund->getLabel()); userLines.erase(count); @@ -255,7 +255,7 @@ int SummaryCommand::execute(){ delete sabund; sabund = input->getSAbundVector(lastLabel); - mothurOut(sabund->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(sabund->getLabel()); mothurOutEndLine(); processedLabels.insert(sabund->getLabel()); userLabels.erase(sabund->getLabel()); @@ -293,7 +293,7 @@ int SummaryCommand::execute(){ delete sabund; sabund = input->getSAbundVector(lastLabel); - mothurOut(sabund->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(sabund->getLabel()); mothurOutEndLine(); outputFileHandle << sabund->getLabel(); for(int i=0;i data = sumCalculators[i]->getValues(sabund); diff --git a/summarysharedcommand.cpp b/summarysharedcommand.cpp index 253c338..74327ba 100644 --- a/summarysharedcommand.cpp +++ b/summarysharedcommand.cpp @@ -273,7 +273,7 @@ int SummarySharedCommand::execute(){ while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) { if(allLines == 1 || lines.count(count) == 1 || labels.count(lookup[0]->getLabel()) == 1){ - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); process(lookup); processedLabels.insert(lookup[0]->getLabel()); @@ -285,7 +285,7 @@ int SummarySharedCommand::execute(){ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(lastLabel); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); process(lookup); processedLabels.insert(lookup[0]->getLabel()); @@ -321,7 +321,7 @@ int SummarySharedCommand::execute(){ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(lastLabel); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); process(lookup); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } } diff --git a/tree.cpp b/tree.cpp index 487db5c..5331dba 100644 --- a/tree.cpp +++ b/tree.cpp @@ -159,11 +159,10 @@ map Tree::mergeGroups(int i) { // this is true if right child had a greater parsimony for a certain group if(maxPars > 1){ //erase all the groups that are only 1 because you found something with 2. - for(it=parsimony.begin();it!=parsimony.end();it++){ + for(it=parsimony.begin();it!=parsimony.end();){ if(it->second == 1){ - parsimony.erase(it->first); -// it--; - } + parsimony.erase(it++); + }else { it++; } } //set one remaining groups to 1 //so with our above example p[white] = 2 would be left and it would become p[white] = 1 @@ -193,13 +192,17 @@ map Tree::mergeUserGroups(int i, vector g) { int rc = tree[i].getRChild(); //loop through nodes groups removing the ones the user doesn't want - for (it = tree[lc].pGroups.begin(); it != tree[lc].pGroups.end(); it++) { - if (inUsersGroups(it->first, g) != true) { tree[lc].pGroups.erase(it->first); } + for(it=tree[lc].pGroups.begin();it!=tree[lc].pGroups.end();){ + if (inUsersGroups(it->first, g) != true) { + tree[lc].pGroups.erase(it++); + }else { it++; } } - + //loop through nodes groups removing the ones the user doesn't want - for (it = tree[rc].pGroups.begin(); it != tree[rc].pGroups.end(); it++) { - if (inUsersGroups(it->first, g) != true) { tree[rc].pGroups.erase(it->first); } + for(it=tree[rc].pGroups.begin();it!=tree[rc].pGroups.end();){ + if (inUsersGroups(it->first, g) != true) { + tree[rc].pGroups.erase(it++); + }else { it++; } } //set parsimony groups to left child @@ -224,11 +227,12 @@ map Tree::mergeUserGroups(int i, vector g) { // this is true if right child had a greater parsimony for a certain group if(maxPars > 1){ //erase all the groups that are only 1 because you found something with 2. - for(it=parsimony.begin();it!=parsimony.end();it++){ + for(it=parsimony.begin();it!=parsimony.end();){ if(it->second == 1){ - parsimony.erase(it->first); - } + parsimony.erase(it++); + }else { it++; } } + for(it=parsimony.begin();it!=parsimony.end();it++){ parsimony[it->first] = 1; } diff --git a/treegroupscommand.cpp b/treegroupscommand.cpp index dae04f5..ab81f42 100644 --- a/treegroupscommand.cpp +++ b/treegroupscommand.cpp @@ -448,7 +448,7 @@ void TreeGroupCommand::makeSimsShared() { while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) { if(allLines == 1 || lines.count(count) == 1 || labels.count(lookup[0]->getLabel()) == 1){ - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); process(lookup); processedLabels.insert(lookup[0]->getLabel()); @@ -460,7 +460,7 @@ void TreeGroupCommand::makeSimsShared() { for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(lastLabel); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); process(lookup); processedLabels.insert(lookup[0]->getLabel()); @@ -493,7 +493,7 @@ void TreeGroupCommand::makeSimsShared() { for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(lastLabel); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); process(lookup); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } } diff --git a/venncommand.cpp b/venncommand.cpp index 38cf8cb..84d33f2 100644 --- a/venncommand.cpp +++ b/venncommand.cpp @@ -224,7 +224,7 @@ int VennCommand::execute(){ while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) { if(allLines == 1 || lines.count(count) == 1 || labels.count(lookup[0]->getLabel()) == 1){ - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); processedLabels.insert(lookup[0]->getLabel()); userLabels.erase(lookup[0]->getLabel()); userLines.erase(count); @@ -240,7 +240,7 @@ int VennCommand::execute(){ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(lastLabel); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); processedLabels.insert(lookup[0]->getLabel()); userLabels.erase(lookup[0]->getLabel()); @@ -278,7 +278,7 @@ int VennCommand::execute(){ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(lastLabel); - mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); processedLabels.insert(lookup[0]->getLabel()); userLabels.erase(lookup[0]->getLabel()); @@ -300,7 +300,7 @@ int VennCommand::execute(){ if(allLines == 1 || lines.count(count) == 1 || labels.count(sabund->getLabel()) == 1){ - mothurOut(sabund->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(sabund->getLabel()); mothurOutEndLine(); venn->getPic(sabund, vennCalculators); processedLabels.insert(sabund->getLabel()); @@ -312,7 +312,7 @@ int VennCommand::execute(){ delete sabund; sabund = input->getSAbundVector(lastLabel); - mothurOut(sabund->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(sabund->getLabel()); mothurOutEndLine(); venn->getPic(sabund, vennCalculators); processedLabels.insert(sabund->getLabel()); @@ -344,7 +344,7 @@ int VennCommand::execute(){ delete sabund; sabund = input->getSAbundVector(lastLabel); - mothurOut(sabund->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(sabund->getLabel()); mothurOutEndLine(); venn->getPic(sabund, vennCalculators); delete sabund; -- 2.39.2