5 * Created by Sarah Westcott on 1/2/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "collectcommand.h"
15 #include "bootstrap.h"
17 #include "npshannon.h"
19 #include "jackknife.h"
22 //**********************************************************************************************************************
25 CollectCommand::CollectCommand(){
27 globaldata = GlobalData::getInstance();
29 fileNameRoot = getRootName(globaldata->inputFileName);
31 validCalculator = new ValidCalculators();
33 for (i=0; i<globaldata->Estimators.size(); i++) {
34 if (validCalculator->isValidCalculator("single", globaldata->Estimators[i]) == true) {
35 if (globaldata->Estimators[i] == "sobs") {
36 cDisplays.push_back(new CollectDisplay(new Sobs(), new OneColumnFile(fileNameRoot+"sobs")));
37 }else if (globaldata->Estimators[i] == "chao") {
38 cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao")));
39 }else if (globaldata->Estimators[i] == "nseqs") {
40 cDisplays.push_back(new CollectDisplay(new NSeqs(), new OneColumnFile(fileNameRoot+"nseqs")));
41 }else if (globaldata->Estimators[i] == "ace") {
42 convert(globaldata->getAbund(), abund);
43 cDisplays.push_back(new CollectDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"ace")));
44 }else if (globaldata->Estimators[i] == "jack") {
45 cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack")));
46 }else if (globaldata->Estimators[i] == "shannon") {
47 cDisplays.push_back(new CollectDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"shannon")));
48 }else if (globaldata->Estimators[i] == "npshannon") {
49 cDisplays.push_back(new CollectDisplay(new NPShannon(), new OneColumnFile(fileNameRoot+"np_shannon")));
50 }else if (globaldata->Estimators[i] == "simpson") {
51 cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"simpson")));
52 }else if (globaldata->Estimators[i] == "bootstrap") {
53 cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(fileNameRoot+"bootstrap")));
58 //reset calc for next command
59 globaldata->setCalc("");
62 cout << "Standard Error: " << e.what() << " has occurred in the CollectCommand class Function CollectCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
66 cout << "An unknown error has occurred in the CollectCommand class function CollectCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
72 //**********************************************************************************************************************
74 CollectCommand::~CollectCommand(){
81 //**********************************************************************************************************************
83 int CollectCommand::execute(){
87 //if the users entered no valid calculators don't execute command
88 if (cDisplays.size() == 0) { return 0; }
90 read = new ReadPhilFile(globaldata->inputFileName);
91 read->read(&*globaldata);
93 order = globaldata->gorder;
94 input = globaldata->ginput;
95 set<string> orderList;
99 orderList.insert(order->getLabel());
100 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
101 cCurve = new Collect(order, cDisplays);
102 convert(globaldata->getFreq(), freq);
103 cCurve->getCurve(freq);
107 cout << order->getLabel() << '\t' << count << endl;
109 order = (input->getOrderVector());
112 set<string>::iterator i;
113 for(i = globaldata->labels.begin(); i != globaldata->labels.end(); ++i)
114 if(orderList.count(*i) == 0)
115 cout << "'" << *i << "'" << " is not a valid label.\n";
116 for(int i=0;i<cDisplays.size();i++){ delete cDisplays[i]; }
119 catch(exception& e) {
120 cout << "Standard Error: " << e.what() << " has occurred in the CollectCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
124 cout << "An unknown error has occurred in the CollectCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
129 //**********************************************************************************************************************