5 * Created by Sarah Westcott on 1/2/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "rarefactcommand.h"
15 #include "bootstrap.h"
17 #include "npshannon.h"
19 #include "jackknife.h"
21 //**********************************************************************************************************************
24 RareFactCommand::RareFactCommand(){
26 globaldata = GlobalData::getInstance();
28 fileNameRoot = getRootName(globaldata->inputFileName);
29 validCalculator = new ValidCalculators();
32 for (i=0; i<globaldata->Estimators.size(); i++) {
33 if (validCalculator->isValidCalculator("rarefaction", globaldata->Estimators[i]) == true) {
34 if (globaldata->Estimators[i] == "sobs") {
35 rDisplays.push_back(new RareDisplay(new Sobs(), new ThreeColumnFile(fileNameRoot+"rarefaction")));
36 }else if (globaldata->Estimators[i] == "chao") {
37 rDisplays.push_back(new RareDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"r_chao")));
38 }else if (globaldata->Estimators[i] == "ace") {
39 convert(globaldata->getAbund(), abund);
42 rDisplays.push_back(new RareDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"r_ace")));
43 }else if (globaldata->Estimators[i] == "jack") {
44 rDisplays.push_back(new RareDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"r_jack")));
45 }else if (globaldata->Estimators[i] == "shannon") {
46 rDisplays.push_back(new RareDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"r_shannon")));
47 }else if (globaldata->Estimators[i] == "npshannon") {
48 rDisplays.push_back(new RareDisplay(new NPShannon(), new ThreeColumnFile(fileNameRoot+"r_npshannon")));
49 }else if (globaldata->Estimators[i] == "simpson") {
50 rDisplays.push_back(new RareDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"r_simpson")));
51 }else if (globaldata->Estimators[i] == "bootstrap") {
52 rDisplays.push_back(new RareDisplay(new Bootstrap(), new ThreeColumnFile(fileNameRoot+"r_bootstrap")));
53 }else if (globaldata->Estimators[i] == "nseqs") {
54 rDisplays.push_back(new RareDisplay(new NSeqs(), new ThreeColumnFile(fileNameRoot+"r_nseqs")));
59 //reset calc for next command
60 globaldata->setCalc("");
64 cout << "Standard Error: " << e.what() << " has occurred in the RareFactCommand class Function RareFactCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
68 cout << "An unknown error has occurred in the RareFactCommand class function RareFactCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
74 //**********************************************************************************************************************
76 RareFactCommand::~RareFactCommand(){
83 //**********************************************************************************************************************
85 int RareFactCommand::execute(){
89 //if the users entered no valid calculators don't execute command
90 if (rDisplays.size() == 0) { return 0; }
92 read = new ReadPhilFile(globaldata->inputFileName);
93 read->read(&*globaldata);
95 order = globaldata->gorder;
96 input = globaldata->ginput;
100 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
102 rCurve = new Rarefact(order, rDisplays);
103 convert(globaldata->getFreq(), freq);
104 convert(globaldata->getIters(), nIters);
105 rCurve->getCurve(freq, nIters);
109 cout << order->getLabel() << '\t' << count << endl;
112 order = (input->getOrderVector());
117 for(int i=0;i<rDisplays.size();i++){ delete rDisplays[i]; }
120 catch(exception& e) {
121 cout << "Standard Error: " << e.what() << " has occurred in the RareFactCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
125 cout << "An unknown error has occurred in the RareFactCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
130 //**********************************************************************************************************************