X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=collectcommand.cpp;h=3d7f1b0fead598d628491f6214ed3701bd65edea;hb=bffbd9ad0d837bc9523d95e7b35c34cfd2631046;hp=95a79d5bc69f763688915ecb998bd47cff162f1e;hpb=ec43347d04dbb2a7d9d9ecfb5fc556e21ad8c2bc;p=mothur.git diff --git a/collectcommand.cpp b/collectcommand.cpp index 95a79d5..3d7f1b0 100644 --- a/collectcommand.cpp +++ b/collectcommand.cpp @@ -10,22 +10,33 @@ #include "collectcommand.h" #include "ace.h" #include "sobs.h" +#include "nseqs.h" #include "chao1.h" #include "bootstrap.h" #include "simpson.h" #include "npshannon.h" #include "shannon.h" #include "jackknife.h" +#include "geom.h" +#include "qstat.h" +#include "logsd.h" +#include "bergerparker.h" +#include "bstick.h" +#include "goodscoverage.h" +#include "efron.h" +#include "boneh.h" +#include "solow.h" +#include "shen.h" +#include "coverage.h" //********************************************************************************************************************** - - CollectCommand::CollectCommand(){ try { globaldata = GlobalData::getInstance(); string fileNameRoot; fileNameRoot = getRootName(globaldata->inputFileName); + convert(globaldata->getFreq(), freq); int i; validCalculator = new ValidCalculators(); @@ -35,8 +46,12 @@ CollectCommand::CollectCommand(){ cDisplays.push_back(new CollectDisplay(new Sobs(), new OneColumnFile(fileNameRoot+"sobs"))); }else if (globaldata->Estimators[i] == "chao") { cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao"))); + }else if (globaldata->Estimators[i] == "nseqs") { + cDisplays.push_back(new CollectDisplay(new NSeqs(), new OneColumnFile(fileNameRoot+"nseqs"))); + }else if (globaldata->Estimators[i] == "coverage") { + cDisplays.push_back(new CollectDisplay(new Coverage(), new OneColumnFile(fileNameRoot+"coverage"))); }else if (globaldata->Estimators[i] == "ace") { - convert(globaldata->getAbund(), abund); + convert(globaldata->getAbund(), abund); cDisplays.push_back(new CollectDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"ace"))); }else if (globaldata->Estimators[i] == "jack") { cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack"))); @@ -48,6 +63,30 @@ CollectCommand::CollectCommand(){ cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"simpson"))); }else if (globaldata->Estimators[i] == "bootstrap") { cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(fileNameRoot+"bootstrap"))); + }else if (globaldata->Estimators[i] == "geometric") { + cDisplays.push_back(new CollectDisplay(new Geom(), new OneColumnFile(fileNameRoot+"geometric"))); + }else if (globaldata->Estimators[i] == "qstat") { + cDisplays.push_back(new CollectDisplay(new QStat(), new OneColumnFile(fileNameRoot+"qstat"))); + }else if (globaldata->Estimators[i] == "logseries") { + cDisplays.push_back(new CollectDisplay(new LogSD(), new OneColumnFile(fileNameRoot+"logseries"))); + }else if (globaldata->Estimators[i] == "bergerparker") { + cDisplays.push_back(new CollectDisplay(new BergerParker(), new OneColumnFile(fileNameRoot+"bergerparker"))); + }else if (globaldata->Estimators[i] == "bstick") { + cDisplays.push_back(new CollectDisplay(new BStick(), new ThreeColumnFile(fileNameRoot+"bstick"))); + }else if (globaldata->Estimators[i] == "goodscoverage") { + cDisplays.push_back(new CollectDisplay(new GoodsCoverage(), new OneColumnFile(fileNameRoot+"goodscoverage"))); + }else if (globaldata->Estimators[i] == "efron") { + convert(globaldata->getSize(), size); + cDisplays.push_back(new CollectDisplay(new Efron(size), new OneColumnFile(fileNameRoot+"efron"))); + }else if (globaldata->Estimators[i] == "boneh") { + convert(globaldata->getSize(), size); + cDisplays.push_back(new CollectDisplay(new Boneh(size), new OneColumnFile(fileNameRoot+"boneh"))); + }else if (globaldata->Estimators[i] == "solow") { + convert(globaldata->getSize(), size); + cDisplays.push_back(new CollectDisplay(new Solow(size), new OneColumnFile(fileNameRoot+"solow"))); + }else if (globaldata->Estimators[i] == "shen") { + convert(globaldata->getSize(), size); + cDisplays.push_back(new CollectDisplay(new Shen(size), new OneColumnFile(fileNameRoot+"shen"))); } } } @@ -84,33 +123,74 @@ int CollectCommand::execute(){ //if the users entered no valid calculators don't execute command if (cDisplays.size() == 0) { return 0; } - read = new ReadPhilFile(globaldata->inputFileName); + read = new ReadOTUFile(globaldata->inputFileName); read->read(&*globaldata); order = globaldata->gorder; + lastOrder = order; input = globaldata->ginput; - set orderList; - while(order != NULL){ + //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label. + set processedLabels; + set userLabels = globaldata->labels; + set userLines = globaldata->lines; + + while((order != NULL) && ((globaldata->allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) { - orderList.insert(order->getLabel()); if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){ + cCurve = new Collect(order, cDisplays); - convert(globaldata->getFreq(), freq); cCurve->getCurve(freq); - delete cCurve; cout << order->getLabel() << '\t' << count << endl; + processedLabels.insert(order->getLabel()); + userLabels.erase(order->getLabel()); + userLines.erase(count); + + //you have a label the user want that is smaller than this line and the last line has not already been processed + } + + if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastOrder->getLabel()) != 1)) { + cCurve = new Collect(lastOrder, cDisplays); + cCurve->getCurve(freq); + delete cCurve; + + cout << lastOrder->getLabel() << '\t' << count << endl; + processedLabels.insert(lastOrder->getLabel()); + userLabels.erase(lastOrder->getLabel()); } + + if (count != 1) { delete lastOrder; } + lastOrder = order; order = (input->getOrderVector()); count++; } - set::iterator i; - for(i = globaldata->labels.begin(); i != globaldata->labels.end(); ++i) - if(orderList.count(*i) == 0) - cout << "'" << *i << "'" << " is not a valid label.\n"; - for(int i=0;i::iterator it; + bool needToRun = false; + for (it = userLabels.begin(); it != userLabels.end(); it++) { + cout << "Your file does not include the label "<< *it; + if (processedLabels.count(lastOrder->getLabel()) != 1) { + cout << ". I will use " << lastOrder->getLabel() << "." << endl; + needToRun = true; + }else { + cout << ". Please refer to " << lastOrder->getLabel() << "." << endl; + } + } + + //run last line if you need to + if (needToRun == true) { + cCurve = new Collect(lastOrder, cDisplays); + cCurve->getCurve(freq); + delete cCurve; + + cout << lastOrder->getLabel() << '\t' << count << endl; + } + + delete lastOrder; + for(int i=0;i