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 convert(globaldata->getAbund(), abund);
41 rDisplays.push_back(new RareDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"r_ace")));
42 }else if (globaldata->Estimators[i] == "jack") {
43 rDisplays.push_back(new RareDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"r_jack")));
44 }else if (globaldata->Estimators[i] == "shannon") {
45 rDisplays.push_back(new RareDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"r_shannon")));
46 }else if (globaldata->Estimators[i] == "npshannon") {
47 rDisplays.push_back(new RareDisplay(new NPShannon(), new ThreeColumnFile(fileNameRoot+"r_npshannon")));
48 }else if (globaldata->Estimators[i] == "simpson") {
49 rDisplays.push_back(new RareDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"r_simpson")));
50 }else if (globaldata->Estimators[i] == "bootstrap") {
51 rDisplays.push_back(new RareDisplay(new Bootstrap(), new ThreeColumnFile(fileNameRoot+"r_bootstrap")));
56 //reset calc for next command
57 globaldata->setCalc("");
61 cout << "Standard Error: " << e.what() << " has occurred in the RareFactCommand class Function RareFactCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
65 cout << "An unknown error has occurred in the RareFactCommand class function RareFactCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
71 //**********************************************************************************************************************
73 RareFactCommand::~RareFactCommand(){
80 //**********************************************************************************************************************
82 int RareFactCommand::execute(){
86 //if the users entered no valid calculators don't execute command
87 if (rDisplays.size() == 0) { return 0; }
89 read = new ReadPhilFile(globaldata->inputFileName);
90 read->read(&*globaldata);
92 order = globaldata->gorder;
93 input = globaldata->ginput;
97 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
99 rCurve = new Rarefact(order, rDisplays);
100 convert(globaldata->getFreq(), freq);
101 convert(globaldata->getIters(), nIters);
102 rCurve->getCurve(freq, nIters);
106 cout << order->getLabel() << '\t' << count << endl;
109 order = (input->getOrderVector());
114 for(int i=0;i<rDisplays.size();i++){ delete rDisplays[i]; }
117 catch(exception& e) {
118 cout << "Standard Error: " << e.what() << " has occurred in the RareFactCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
122 cout << "An unknown error has occurred in the RareFactCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
127 //**********************************************************************************************************************