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"
22 //**********************************************************************************************************************
25 RareFactCommand::RareFactCommand(){
27 globaldata = GlobalData::getInstance();
29 fileNameRoot = getRootName(globaldata->inputFileName);
30 validCalculator = new ValidCalculators();
33 for (i=0; i<globaldata->Estimators.size(); i++) {
34 if (validCalculator->isValidCalculator("rarefaction", globaldata->Estimators[i]) == true) {
35 if (globaldata->Estimators[i] == "sobs") {
36 rDisplays.push_back(new RareDisplay(new Sobs(), new ThreeColumnFile(fileNameRoot+"rarefaction")));
37 }else if (globaldata->Estimators[i] == "chao") {
38 rDisplays.push_back(new RareDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"r_chao")));
39 }else if (globaldata->Estimators[i] == "ace") {
40 convert(globaldata->getAbund(), abund);
43 rDisplays.push_back(new RareDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"r_ace")));
44 }else if (globaldata->Estimators[i] == "jack") {
45 rDisplays.push_back(new RareDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"r_jack")));
46 }else if (globaldata->Estimators[i] == "shannon") {
47 rDisplays.push_back(new RareDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"r_shannon")));
48 }else if (globaldata->Estimators[i] == "npshannon") {
49 rDisplays.push_back(new RareDisplay(new NPShannon(), new ThreeColumnFile(fileNameRoot+"r_npshannon")));
50 }else if (globaldata->Estimators[i] == "simpson") {
51 rDisplays.push_back(new RareDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"r_simpson")));
52 }else if (globaldata->Estimators[i] == "bootstrap") {
53 rDisplays.push_back(new RareDisplay(new Bootstrap(), new ThreeColumnFile(fileNameRoot+"r_bootstrap")));
54 }else if (globaldata->Estimators[i] == "coverage") {
55 rDisplays.push_back(new RareDisplay(new Coverage(), new ThreeColumnFile(fileNameRoot+"r_coverage")));
56 }else if (globaldata->Estimators[i] == "nseqs") {
57 rDisplays.push_back(new RareDisplay(new NSeqs(), new ThreeColumnFile(fileNameRoot+"r_nseqs")));
62 //reset calc for next command
63 globaldata->setCalc("");
67 cout << "Standard Error: " << e.what() << " has occurred in the RareFactCommand class Function RareFactCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
71 cout << "An unknown error has occurred in the RareFactCommand class function RareFactCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
77 //**********************************************************************************************************************
79 RareFactCommand::~RareFactCommand(){
86 //**********************************************************************************************************************
88 int RareFactCommand::execute(){
92 //if the users entered no valid calculators don't execute command
93 if (rDisplays.size() == 0) { return 0; }
95 read = new ReadOTUFile(globaldata->inputFileName);
96 read->read(&*globaldata);
98 order = globaldata->gorder;
99 input = globaldata->ginput;
101 while(order != NULL){
103 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
105 rCurve = new Rarefact(order, rDisplays);
106 convert(globaldata->getFreq(), freq);
107 convert(globaldata->getIters(), nIters);
108 rCurve->getCurve(freq, nIters);
112 cout << order->getLabel() << '\t' << count << endl;
115 order = (input->getOrderVector());
120 for(int i=0;i<rDisplays.size();i++){ delete rDisplays[i]; }
123 catch(exception& e) {
124 cout << "Standard Error: " << e.what() << " has occurred in the RareFactCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
128 cout << "An unknown error has occurred in the RareFactCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
133 //**********************************************************************************************************************