5 * Created by Sarah Westcott on 1/2/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "summarycommand.h"
14 #include "bootstrap.h"
16 #include "npshannon.h"
18 #include "jackknife.h"
20 //**********************************************************************************************************************
22 SummaryCommand::SummaryCommand(){
24 globaldata = GlobalData::getInstance();
26 for (i=0; i<globaldata->summaryEstimators.size(); i++) {
27 if(globaldata->summaryEstimators[i] == "sobs"){
28 sumCalculators.push_back(new Sobs());
29 }else if(globaldata->summaryEstimators[i] == "chao"){
30 sumCalculators.push_back(new Chao1());
31 }else if(globaldata->summaryEstimators[i] == "ace"){
32 sumCalculators.push_back(new Ace());
33 }else if(globaldata->summaryEstimators[i] == "jack"){
34 sumCalculators.push_back(new Jackknife());
35 }else if(globaldata->summaryEstimators[i] == "shannon"){
36 sumCalculators.push_back(new Shannon());
37 }else if(globaldata->summaryEstimators[i] == "npshannon"){
38 sumCalculators.push_back(new NPShannon());
39 }else if(globaldata->summaryEstimators[i] == "simpson"){
40 sumCalculators.push_back(new Simpson());
41 }else if(globaldata->summaryEstimators[i] == "bootstrap"){
42 sumCalculators.push_back(new Bootstrap());
47 cout << "Standard Error: " << e.what() << " has occurred in the SummaryCommand class Function SummaryCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
51 cout << "An unknown error has occurred in the SummaryCommand class function SummaryCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
55 //**********************************************************************************************************************
57 SummaryCommand::~SummaryCommand(){
63 //**********************************************************************************************************************
65 int SummaryCommand::execute(){
67 outputFileName = ((getRootName(globaldata->inputFileName)) + "summary");
68 openOutputFile(outputFileName, outputFileHandle);
69 outputFileHandle << "label";
71 read = new ReadPhilFile(globaldata->inputFileName);
72 read->read(&*globaldata);
74 for(int i=0;i<sumCalculators.size();i++){
75 if(sumCalculators[i]->getCols() == 1){
76 outputFileHandle << '\t' << sumCalculators[i]->getName();
79 outputFileHandle << '\t' << sumCalculators[i]->getName() << "\t" << sumCalculators[i]->getName() << "_lci\t" << sumCalculators[i]->getName() << "_hci";
82 outputFileHandle << endl;
84 sabund = globaldata->sabund;
85 input = globaldata->ginput;
87 while(sabund != NULL){
89 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(sabund->getLabel()) == 1){
91 cout << sabund->getLabel() << '\t' << count << endl;
93 outputFileHandle << sabund->getLabel();
94 for(int i=0;i<sumCalculators.size();i++){
95 vector<double> data = sumCalculators[i]->getValues(sabund);
96 outputFileHandle << '\t';
97 sumCalculators[i]->print(outputFileHandle);
99 outputFileHandle << endl;
102 sabund = input->getSAbundVector();
108 catch(exception& e) {
109 cout << "Standard Error: " << e.what() << " has occurred in the SummaryCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
113 cout << "An unknown error has occurred in the SummaryCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
118 //**********************************************************************************************************************