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"
23 #include "bergerparker.h"
27 //**********************************************************************************************************************
28 CollectCommand::CollectCommand(){
30 globaldata = GlobalData::getInstance();
32 fileNameRoot = getRootName(globaldata->inputFileName);
34 validCalculator = new ValidCalculators();
35 for (i=0; i<globaldata->Estimators.size(); i++) {
36 if (validCalculator->isValidCalculator("single", globaldata->Estimators[i]) == true) {
37 if (globaldata->Estimators[i] == "sobs") {
38 cDisplays.push_back(new CollectDisplay(new Sobs(), new OneColumnFile(fileNameRoot+"sobs")));
39 }else if (globaldata->Estimators[i] == "chao") {
40 cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao")));
41 }else if (globaldata->Estimators[i] == "nseqs") {
42 cDisplays.push_back(new CollectDisplay(new NSeqs(), new OneColumnFile(fileNameRoot+"nseqs")));
43 }else if (globaldata->Estimators[i] == "ace") {
44 convert(globaldata->getAbund(), abund);
45 cDisplays.push_back(new CollectDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"ace")));
46 }else if (globaldata->Estimators[i] == "jack") {
47 cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack")));
48 }else if (globaldata->Estimators[i] == "shannon") {
49 cDisplays.push_back(new CollectDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"shannon")));
50 }else if (globaldata->Estimators[i] == "npshannon") {
51 cDisplays.push_back(new CollectDisplay(new NPShannon(), new OneColumnFile(fileNameRoot+"np_shannon")));
52 }else if (globaldata->Estimators[i] == "simpson") {
53 cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"simpson")));
54 }else if (globaldata->Estimators[i] == "bootstrap") {
55 cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(fileNameRoot+"bootstrap")));
56 }else if (globaldata->Estimators[i] == "geom") {
57 cDisplays.push_back(new CollectDisplay(new Geom(), new OneColumnFile(fileNameRoot+"geom")));
58 }else if (globaldata->Estimators[i] == "qstat") {
59 cDisplays.push_back(new CollectDisplay(new QStat(), new OneColumnFile(fileNameRoot+"qstat")));
60 }else if (globaldata->Estimators[i] == "logsd") {
61 cDisplays.push_back(new CollectDisplay(new LogSD(), new OneColumnFile(fileNameRoot+"logsd")));
62 }else if (globaldata->Estimators[i] == "bergerparker") {
63 cDisplays.push_back(new CollectDisplay(new BergerParker(), new OneColumnFile(fileNameRoot+"bergerparker")));
64 }else if (globaldata->Estimators[i] == "bstick") {
65 cDisplays.push_back(new CollectDisplay(new BStick(), new OneColumnFile(fileNameRoot+"bstick")));
70 //reset calc for next command
71 globaldata->setCalc("");
74 cout << "Standard Error: " << e.what() << " has occurred in the CollectCommand class Function CollectCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
78 cout << "An unknown error has occurred in the CollectCommand class function CollectCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
84 //**********************************************************************************************************************
86 CollectCommand::~CollectCommand(){
93 //**********************************************************************************************************************
95 int CollectCommand::execute(){
99 //if the users entered no valid calculators don't execute command
100 if (cDisplays.size() == 0) { return 0; }
102 read = new ReadOTUFile(globaldata->inputFileName);
103 read->read(&*globaldata);
105 order = globaldata->gorder;
106 input = globaldata->ginput;
107 set<string> orderList;
109 while(order != NULL){
111 orderList.insert(order->getLabel());
112 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
113 cCurve = new Collect(order, cDisplays);
114 convert(globaldata->getFreq(), freq);
115 cCurve->getCurve(freq);
119 cout << order->getLabel() << '\t' << count << endl;
121 order = (input->getOrderVector());
124 set<string>::iterator i;
125 for(i = globaldata->labels.begin(); i != globaldata->labels.end(); ++i)
126 if(orderList.count(*i) == 0)
127 cout << "'" << *i << "'" << " is not a valid label.\n";
128 for(int i=0;i<cDisplays.size();i++){ delete cDisplays[i]; }
131 catch(exception& e) {
132 cout << "Standard Error: " << e.what() << " has occurred in the CollectCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
136 cout << "An unknown error has occurred in the CollectCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
141 //**********************************************************************************************************************