5 * Created by Sarah Westcott on 1/2/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "collectcommand.h"
14 #include "bootstrap.h"
16 #include "npshannon.h"
18 #include "jackknife.h"
21 //**********************************************************************************************************************
24 CollectCommand::CollectCommand(){
26 globaldata = GlobalData::getInstance();
28 fileNameRoot = getRootName(globaldata->inputFileName);
30 validCalculator = new ValidCalculators();
32 for (i=0; i<globaldata->Estimators.size(); i++) {
33 if (validCalculator->isValidCalculator("single", globaldata->Estimators[i]) == true) {
34 if (globaldata->Estimators[i] == "sobs") {
35 cDisplays.push_back(new CollectDisplay(new Sobs(), new OneColumnFile(fileNameRoot+"sobs")));
36 }else if (globaldata->Estimators[i] == "chao") {
37 cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao")));
38 }else if (globaldata->Estimators[i] == "ace") {
39 cDisplays.push_back(new CollectDisplay(new Ace(), new ThreeColumnFile(fileNameRoot+"ace")));
40 }else if (globaldata->Estimators[i] == "jack") {
41 cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack")));
42 }else if (globaldata->Estimators[i] == "shannon") {
43 cDisplays.push_back(new CollectDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"shannon")));
44 }else if (globaldata->Estimators[i] == "npshannon") {
45 cDisplays.push_back(new CollectDisplay(new NPShannon(), new OneColumnFile(fileNameRoot+"np_shannon")));
46 }else if (globaldata->Estimators[i] == "simpson") {
47 cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"simpson")));
48 }else if (globaldata->Estimators[i] == "bootstrap") {
49 cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(fileNameRoot+"bootstrap")));
54 //reset calc for next command
55 globaldata->setCalc("");
58 cout << "Standard Error: " << e.what() << " has occurred in the CollectCommand class Function CollectCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
62 cout << "An unknown error has occurred in the CollectCommand class function CollectCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
68 //**********************************************************************************************************************
70 CollectCommand::~CollectCommand(){
77 //**********************************************************************************************************************
79 int CollectCommand::execute(){
83 //if the users entered no valid calculators don't execute command
84 if (cDisplays.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 cCurve = new Collect(order, cDisplays);
97 convert(globaldata->getFreq(), freq);
98 cCurve->getCurve(freq);
102 cout << order->getLabel() << '\t' << count << endl;
105 order = (input->getOrderVector());
110 for(int i=0;i<cDisplays.size();i++){ delete cDisplays[i]; }
113 catch(exception& e) {
114 cout << "Standard Error: " << e.what() << " has occurred in the CollectCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
118 cout << "An unknown error has occurred in the CollectCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
123 //**********************************************************************************************************************