X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=rarefactsharedcommand.cpp;h=89cf4e2732af38c6fff844490effde5f8676e76c;hb=154e089bcd37c2c2f773e53ffb88a20170b27037;hp=189be88de11e4160b4e185727e324a581063727f;hpb=fd282e6b4be2560f5b1bd154a9e8d24b798eefaf;p=mothur.git diff --git a/rarefactsharedcommand.cpp b/rarefactsharedcommand.cpp index 189be88..89cf4e2 100644 --- a/rarefactsharedcommand.cpp +++ b/rarefactsharedcommand.cpp @@ -9,28 +9,34 @@ #include "rarefactsharedcommand.h" #include "sharedsobs.h" +#include "sharednseqs.h" //********************************************************************************************************************** RareFactSharedCommand::RareFactSharedCommand(){ try { globaldata = GlobalData::getInstance(); - string fileNameRoot, groups; + string fileNameRoot; fileNameRoot = getRootName(globaldata->inputFileName); - groupmap = globaldata->gGroupmap; - - //initialize groups for label - groups = ""; - for (int i = 0; i < groupmap->namesOfGroups.size(); i++) { - groups = groups + groupmap->namesOfGroups[i]; - } - + format = globaldata->getFormat(); + validCalculator = new ValidCalculators(); + util = new SharedUtil(); + int i; - for (i=0; isharedRareEstimators.size(); i++) { - if (globaldata->sharedRareEstimators[i] == "sharedobserved") { - rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(fileNameRoot+"r_shared.observed", groups))); + for (i=0; iEstimators.size(); i++) { + if (validCalculator->isValidCalculator("sharedrarefaction", globaldata->Estimators[i]) == true) { + if (globaldata->Estimators[i] == "sharedobserved") { + rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(fileNameRoot+"shared.rarefaction", ""))); + }else if (globaldata->Estimators[i] == "sharednseqs") { + rDisplays.push_back(new RareDisplay(new SharedNSeqs(), new SharedThreeColumnFile(fileNameRoot+"shared.r_nseqs", ""))); + } + } } + + //reset calc for next command + globaldata->setCalc(""); + } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the RareFactSharedCommand class Function RareFactSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -50,6 +56,7 @@ RareFactSharedCommand::~RareFactSharedCommand(){ delete input; delete rCurve; delete read; + delete util; } //********************************************************************************************************************** @@ -57,12 +64,28 @@ RareFactSharedCommand::~RareFactSharedCommand(){ int RareFactSharedCommand::execute(){ try { int count = 1; - read = new ReadPhilFile(globaldata->inputFileName); - read->read(&*globaldata); - input = globaldata->ginput; - SharedList = globaldata->gSharedList; - order = SharedList->getSharedOrderVector(); + //if the users entered no valid calculators don't execute command + if (rDisplays.size() == 0) { return 0; } + + if (format == "sharedfile") { + read = new ReadOTUFile(globaldata->inputFileName); + read->read(&*globaldata); + + input = globaldata->ginput; + order = input->getSharedOrderVector(); + }else { + //you are using a list and a groupfile + read = new ReadOTUFile(globaldata->inputFileName); + read->read(&*globaldata); + + input = globaldata->ginput; + SharedList = globaldata->gSharedList; + order = SharedList->getSharedOrderVector(); + } + + //set users groups + util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "rarefact"); while(order != NULL){ @@ -78,17 +101,27 @@ int RareFactSharedCommand::execute(){ cout << order->getLabel() << '\t' << count << endl; } - SharedList = input->getSharedListVector(); //get new list vector to process - if (SharedList != NULL) { - order = SharedList->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++; } for(int i=0;iGroups.clear(); globaldata->setGroups(""); + return 0; } catch(exception& e) {