+ if (abort == true) { return 0; }
+
+ string hadShared = "";
+ if ((globaldata->getFormat() != "sharedfile")) { inputFileNames.push_back(globaldata->inputFileName); }
+ else { hadShared = globaldata->getSharedFile(); inputFileNames = parseSharedFile(globaldata->getSharedFile()); globaldata->setFormat("rabund"); }
+
+ if (m->control_pressed) { if (hadShared != "") { globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile"); } return 0; }
+
+ int numLines = 0;
+ int numCols = 0;
+
+ for (int p = 0; p < inputFileNames.size(); p++) {
+
+ numLines = 0;
+ numCols = 0;
+
+ string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + "summary";
+ globaldata->inputFileName = inputFileNames[p];
+ outputNames.push_back(fileNameRoot); outputTypes["summary"].push_back(fileNameRoot);
+
+ if (inputFileNames.size() > 1) {
+ m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[p]); m->mothurOutEndLine(); m->mothurOutEndLine();
+ }
+
+ sumCalculators.clear();
+
+ validCalculator = new ValidCalculators();
+
+ for (int i=0; i<Estimators.size(); i++) {
+ if (validCalculator->isValidCalculator("summary", Estimators[i]) == true) {
+ if(Estimators[i] == "sobs"){
+ sumCalculators.push_back(new Sobs());
+ }else if(Estimators[i] == "chao"){
+ sumCalculators.push_back(new Chao1());
+ }else if(Estimators[i] == "coverage"){
+ sumCalculators.push_back(new Coverage());
+ }else if(Estimators[i] == "geometric"){
+ sumCalculators.push_back(new Geom());
+ }else if(Estimators[i] == "logseries"){
+ sumCalculators.push_back(new LogSD());
+ }else if(Estimators[i] == "qstat"){
+ sumCalculators.push_back(new QStat());
+ }else if(Estimators[i] == "bergerparker"){
+ sumCalculators.push_back(new BergerParker());
+ }else if(Estimators[i] == "bstick"){
+ sumCalculators.push_back(new BStick());
+ }else if(Estimators[i] == "ace"){
+ if(abund < 5)
+ abund = 10;
+ sumCalculators.push_back(new Ace(abund));
+ }else if(Estimators[i] == "jack"){
+ sumCalculators.push_back(new Jackknife());
+ }else if(Estimators[i] == "shannon"){
+ sumCalculators.push_back(new Shannon());
+ }else if(Estimators[i] == "shannoneven"){
+ sumCalculators.push_back(new ShannonEven());
+ }else if(Estimators[i] == "npshannon"){
+ sumCalculators.push_back(new NPShannon());
+ }else if(Estimators[i] == "heip"){
+ sumCalculators.push_back(new Heip());
+ }else if(Estimators[i] == "smithwilson"){
+ sumCalculators.push_back(new SmithWilson());
+ }else if(Estimators[i] == "simpson"){
+ sumCalculators.push_back(new Simpson());
+ }else if(Estimators[i] == "simpsoneven"){
+ sumCalculators.push_back(new SimpsonEven());
+ }else if(Estimators[i] == "invsimpson"){
+ sumCalculators.push_back(new InvSimpson());
+ }else if(Estimators[i] == "bootstrap"){
+ sumCalculators.push_back(new Bootstrap());
+ }else if (Estimators[i] == "nseqs") {
+ sumCalculators.push_back(new NSeqs());
+ }else if (Estimators[i] == "goodscoverage") {
+ sumCalculators.push_back(new GoodsCoverage());
+ }else if (Estimators[i] == "efron") {
+ sumCalculators.push_back(new Efron(size));
+ }else if (Estimators[i] == "boneh") {
+ sumCalculators.push_back(new Boneh(size));
+ }else if (Estimators[i] == "solow") {
+ sumCalculators.push_back(new Solow(size));
+ }else if (Estimators[i] == "shen") {
+ sumCalculators.push_back(new Shen(size, abund));
+ }
+ }
+ }
+
+ //if the users entered no valid calculators don't execute command
+ if (sumCalculators.size() == 0) { if (hadShared != "") { globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile"); } return 0; }
+
+ ofstream outputFileHandle;
+ m->openOutputFile(fileNameRoot, outputFileHandle);
+ outputFileHandle << "label";
+
+ read = new ReadOTUFile(globaldata->inputFileName);
+ read->read(&*globaldata);
+
+ sabund = globaldata->sabund;
+ string lastLabel = sabund->getLabel();
+ input = globaldata->ginput;
+
+ for(int i=0;i<sumCalculators.size();i++){
+ if(sumCalculators[i]->getCols() == 1){
+ outputFileHandle << '\t' << sumCalculators[i]->getName();
+ numCols++;
+ }
+ else{
+ outputFileHandle << '\t' << sumCalculators[i]->getName() << "\t" << sumCalculators[i]->getName() << "_lci\t" << sumCalculators[i]->getName() << "_hci";
+ numCols += 3;
+ }
+ }
+ outputFileHandle << endl;
+
+ //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
+ set<string> processedLabels;
+ set<string> userLabels = labels;
+
+ if (m->control_pressed) { if (hadShared != "") { globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile"); } outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } for(int i=0;i<sumCalculators.size();i++){ delete sumCalculators[i]; } delete validCalculator; delete read; delete sabund; globaldata->sabund = NULL; delete input; globaldata->ginput = NULL; return 0; }
+
+ while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
+
+ if (m->control_pressed) { if (hadShared != "") { globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile"); } outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } for(int i=0;i<sumCalculators.size();i++){ delete sumCalculators[i]; } delete validCalculator; delete read; delete sabund; globaldata->sabund = NULL; delete input; globaldata->ginput = NULL; return 0; }
+
+ if(allLines == 1 || labels.count(sabund->getLabel()) == 1){
+
+ m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
+ processedLabels.insert(sabund->getLabel());
+ userLabels.erase(sabund->getLabel());
+
+ outputFileHandle << sabund->getLabel();
+ for(int i=0;i<sumCalculators.size();i++){
+ vector<double> data = sumCalculators[i]->getValues(sabund);
+
+ if (m->control_pressed) { if (hadShared != "") { globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile"); } outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } for(int i=0;i<sumCalculators.size();i++){ delete sumCalculators[i]; } delete validCalculator; delete read; delete sabund; globaldata->sabund = NULL; delete input; globaldata->ginput = NULL; return 0; }