5 * Created by Sarah Westcott on 1/2/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "rarefactcommand.h"
14 #include "bootstrap.h"
16 #include "npshannon.h"
18 #include "jackknife.h"
20 //**********************************************************************************************************************
23 RareFactCommand::RareFactCommand(){
25 globaldata = GlobalData::getInstance();
27 fileNameRoot = getRootName(globaldata->inputFileName);
28 validCalculator = new ValidCalculators();
31 for (i=0; i<globaldata->Estimators.size(); i++) {
32 if (validCalculator->isValidCalculator("rarefaction", globaldata->Estimators[i]) == true) {
33 if (globaldata->Estimators[i] == "sobs") {
34 rDisplays.push_back(new RareDisplay(new Sobs(), new ThreeColumnFile(fileNameRoot+"rarefaction")));
35 }else if (globaldata->Estimators[i] == "chao") {
36 rDisplays.push_back(new RareDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"r_chao")));
37 }else if (globaldata->Estimators[i] == "ace") {
38 rDisplays.push_back(new RareDisplay(new Ace(), new ThreeColumnFile(fileNameRoot+"r_ace")));
39 }else if (globaldata->Estimators[i] == "jack") {
40 rDisplays.push_back(new RareDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"r_jack")));
41 }else if (globaldata->Estimators[i] == "shannon") {
42 rDisplays.push_back(new RareDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"r_shannon")));
43 }else if (globaldata->Estimators[i] == "npshannon") {
44 rDisplays.push_back(new RareDisplay(new NPShannon(), new ThreeColumnFile(fileNameRoot+"r_npshannon")));
45 }else if (globaldata->Estimators[i] == "simpson") {
46 rDisplays.push_back(new RareDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"r_simpson")));
47 }else if (globaldata->Estimators[i] == "bootstrap") {
48 rDisplays.push_back(new RareDisplay(new Bootstrap(), new ThreeColumnFile(fileNameRoot+"r_bootstrap")));
53 //reset calc for next command
54 globaldata->setCalc("");
58 cout << "Standard Error: " << e.what() << " has occurred in the RareFactCommand class Function RareFactCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
62 cout << "An unknown error has occurred in the RareFactCommand class function RareFactCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
68 //**********************************************************************************************************************
70 RareFactCommand::~RareFactCommand(){
77 //**********************************************************************************************************************
79 int RareFactCommand::execute(){
83 //if the users entered no valid calculators don't execute command
84 if (rDisplays.size() == 0) { return 0; }
86 read = new ReadPhilFile(globaldata->inputFileName);
87 read->read(&*globaldata);
89 order = globaldata->gorder;
90 input = globaldata->ginput;
94 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
96 rCurve = new Rarefact(order, rDisplays);
97 convert(globaldata->getFreq(), freq);
98 convert(globaldata->getIters(), nIters);
99 rCurve->getCurve(freq, nIters);
103 cout << order->getLabel() << '\t' << count << endl;
106 order = (input->getOrderVector());
111 for(int i=0;i<rDisplays.size();i++){ delete rDisplays[i]; }
114 catch(exception& e) {
115 cout << "Standard Error: " << e.what() << " has occurred in the RareFactCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
119 cout << "An unknown error has occurred in the RareFactCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
124 //**********************************************************************************************************************