X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=inline;f=summarysharedcommand.cpp;h=f31f7e10e1f19e47781d2d47dd9db09ebafa05cf;hb=dbc9352256135d7b3e2b17dddc5c506770e2df92;hp=b9fd08debd294870af590f5be48fdc4a7c7ba890;hpb=20a2d0350a737a434c89f303662d64a8eeea7b05;p=mothur.git diff --git a/summarysharedcommand.cpp b/summarysharedcommand.cpp index b9fd08d..f31f7e1 100644 --- a/summarysharedcommand.cpp +++ b/summarysharedcommand.cpp @@ -8,6 +8,7 @@ */ #include "summarysharedcommand.h" +#include "sharedsobscollectsummary.h" #include "sharedchao1.h" #include "sharedace.h" #include "sharedjabund.h" @@ -24,31 +25,43 @@ SummarySharedCommand::SummarySharedCommand(){ try { globaldata = GlobalData::getInstance(); + outputFileName = ((getRootName(globaldata->inputFileName)) + "shared.summary"); + openOutputFile(outputFileName, outputFileHandle); + format = globaldata->getFormat(); + validCalculator = new ValidCalculators(); int i; - for (i=0; isharedSummaryEstimators.size(); i++) { - if (globaldata->sharedSummaryEstimators[i] == "sharedChao") { - sumCalculators.push_back(new SharedChao1()); - }else if (globaldata->sharedSummaryEstimators[i] == "sharedAce") { - sumCalculators.push_back(new SharedAce()); - }else if (globaldata->sharedSummaryEstimators[i] == "sharedJabund") { - sumCalculators.push_back(new SharedJAbund()); - }else if (globaldata->sharedSummaryEstimators[i] == "sharedSorensonAbund") { - sumCalculators.push_back(new SharedSorAbund()); - }else if (globaldata->sharedSummaryEstimators[i] == "sharedJclass") { - sumCalculators.push_back(new SharedJclass()); - }else if (globaldata->sharedSummaryEstimators[i] == "sharedSorClass") { - sumCalculators.push_back(new SharedSorClass()); - }else if (globaldata->sharedSummaryEstimators[i] == "sharedJest") { - sumCalculators.push_back(new SharedJest()); - }else if (globaldata->sharedSummaryEstimators[i] == "sharedSorEst") { - sumCalculators.push_back(new SharedSorEst()); - }else if (globaldata->sharedSummaryEstimators[i] == "SharedThetaYC") { - sumCalculators.push_back(new SharedThetaYC()); - }else if (globaldata->sharedSummaryEstimators[i] == "SharedThetaN") { - sumCalculators.push_back(new SharedThetaN()); + for (i=0; iEstimators.size(); i++) { + if (validCalculator->isValidCalculator("sharedsummary", globaldata->Estimators[i]) == true) { + if (globaldata->Estimators[i] == "sharedsobs") { + sumCalculators.push_back(new SharedSobsCS()); + }else if (globaldata->Estimators[i] == "sharedchao") { + sumCalculators.push_back(new SharedChao1()); + }else if (globaldata->Estimators[i] == "sharedace") { + sumCalculators.push_back(new SharedAce()); + }else if (globaldata->Estimators[i] == "sharedjabund") { + sumCalculators.push_back(new SharedJAbund()); + }else if (globaldata->Estimators[i] == "sharedsorensonabund") { + sumCalculators.push_back(new SharedSorAbund()); + }else if (globaldata->Estimators[i] == "sharedjclass") { + sumCalculators.push_back(new SharedJclass()); + }else if (globaldata->Estimators[i] == "sharedsorclass") { + sumCalculators.push_back(new SharedSorClass()); + }else if (globaldata->Estimators[i] == "sharedjest") { + sumCalculators.push_back(new SharedJest()); + }else if (globaldata->Estimators[i] == "sharedsorest") { + sumCalculators.push_back(new SharedSorEst()); + }else if (globaldata->Estimators[i] == "sharedthetayc") { + sumCalculators.push_back(new SharedThetaYC()); + }else if (globaldata->Estimators[i] == "sharedthetan") { + sumCalculators.push_back(new SharedThetaN()); + } } } + + //reset calc for next command + globaldata->setCalc(""); + } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the SummarySharedCommand class Function SummarySharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -70,24 +83,34 @@ SummarySharedCommand::~SummarySharedCommand(){ int SummarySharedCommand::execute(){ try { - outputFileName = ((getRootName(globaldata->inputFileName)) + "sharedSummary"); - openOutputFile(outputFileName, outputFileHandle); - - read = new ReadPhilFile(globaldata->inputFileName); - read->read(&*globaldata); + int count = 1; - outputFileHandle << '\t' << '\t' << '\t' << '\t'; //pads file for labels and groupnames + //if the users entered no valid calculators don't execute command + if (sumCalculators.size() == 0) { return 0; } + + if (format == "sharedfile") { + read = new ReadPhilFile(globaldata->inputFileName); + read->read(&*globaldata); + + input = globaldata->ginput; + order = input->getSharedOrderVector(); + }else { + //you are using a list and a groupfile + read = new ReadPhilFile(globaldata->inputFileName); + read->read(&*globaldata); + + input = globaldata->ginput; + SharedList = globaldata->gSharedList; + order = SharedList->getSharedOrderVector(); + } + + //output estimator names as column headers + outputFileHandle << "label" <<'\t' << "comparison" << '\t'; for(int i=0;igetName(); } outputFileHandle << endl; - - list = globaldata->glist; - input = globaldata->ginput; - order = list->getSharedOrderVector(); - getGroupComb(); - - int count = 1; + while(order != NULL){ if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){ @@ -101,7 +124,7 @@ int SummarySharedCommand::execute(){ int n = 1; for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare for (int l = n; l < lookup.size(); l++) { - outputFileHandle << order->getLabel() << '\t' << groupComb[n-1] << '\t'; //print out label and group + outputFileHandle << order->getLabel() << '\t' << (lookup[k]->getGroup() + lookup[l]->getGroup()) << '\t' << '\t'; //print out label and group for(int i=0;igetValues(lookup[k], lookup[l]); //saves the calculator outputs outputFileHandle << '\t'; @@ -113,13 +136,19 @@ int SummarySharedCommand::execute(){ } } - list = input->getListVector(); //get new list vector to process - if (list != NULL) { - order = list->getSharedOrderVector(); //gets new order vector with group info. - count++; + //get next line to process + if (format == "sharedfile") { + order = input->getSharedOrderVector(); }else { - break; + //you are using a list and a groupfile + SharedList = input->getSharedListVector(); //get new list vector to process + if (SharedList != NULL) { + order = SharedList->getSharedOrderVector(); //gets new order vector with group info. + }else { + break; + } } + count++; } return 0; @@ -176,28 +205,4 @@ try { } -/**************************************************************************************/ -void SummarySharedCommand::getGroupComb() { - try { - string group; - - int n = 1; - for (int i = 0; i < (globaldata->gGroupmap->getNumGroups() - 1); i++) { - for (int l = n; l < globaldata->gGroupmap->getNumGroups(); l++) { - group = globaldata->gGroupmap->namesOfGroups[i] + globaldata->gGroupmap->namesOfGroups[l]; - groupComb.push_back(group); - } - n++; - } - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SummarySharedCommand class Function getGroupComb. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the SummarySharedCommand class function getGroupComb. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - -} - +//**********************************************************************************************************************