2 * rarefactsharedcommand.cpp
5 * Created by Sarah Westcott on 1/6/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "rarefactsharedcommand.h"
11 #include "sharedsobs.h"
13 //**********************************************************************************************************************
15 RareFactSharedCommand::RareFactSharedCommand(){
17 globaldata = GlobalData::getInstance();
19 fileNameRoot = getRootName(globaldata->inputFileName);
20 format = globaldata->getFormat();
21 validCalculator = new ValidCalculators();
24 for (i=0; i<globaldata->Estimators.size(); i++) {
25 if (validCalculator->isValidCalculator("sharedrarefaction", globaldata->Estimators[i]) == true) {
26 if (globaldata->Estimators[i] == "sharedobserved") {
27 rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(fileNameRoot+"shared.rarefaction", "")));
32 //reset calc for next command
33 globaldata->setCalc("");
37 cout << "Standard Error: " << e.what() << " has occurred in the RareFactSharedCommand class Function RareFactSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
41 cout << "An unknown error has occurred in the RareFactSharedCommand class function RareFactSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
47 //**********************************************************************************************************************
49 RareFactSharedCommand::~RareFactSharedCommand(){
56 //**********************************************************************************************************************
58 int RareFactSharedCommand::execute(){
62 //if the users entered no valid calculators don't execute command
63 if (rDisplays.size() == 0) { return 0; }
65 if (format == "sharedfile") {
66 read = new ReadPhilFile(globaldata->inputFileName);
67 read->read(&*globaldata);
69 input = globaldata->ginput;
70 order = input->getSharedOrderVector();
72 //you are using a list and a groupfile
73 read = new ReadPhilFile(globaldata->inputFileName);
74 read->read(&*globaldata);
76 input = globaldata->ginput;
77 SharedList = globaldata->gSharedList;
78 order = SharedList->getSharedOrderVector();
83 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
84 //create collectors curve
85 rCurve = new Rarefact(order, rDisplays);
86 convert(globaldata->getFreq(), freq);
87 convert(globaldata->getIters(), nIters);
88 rCurve->getSharedCurve(freq, nIters);
92 cout << order->getLabel() << '\t' << count << endl;
95 //get next line to process
96 if (format == "sharedfile") {
97 order = input->getSharedOrderVector();
99 //you are using a list and a groupfile
100 SharedList = input->getSharedListVector(); //get new list vector to process
101 if (SharedList != NULL) {
102 order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
111 for(int i=0;i<rDisplays.size();i++){ delete rDisplays[i]; }
114 catch(exception& e) {
115 cout << "Standard Error: " << e.what() << " has occurred in the RareFactSharedCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
119 cout << "An unknown error has occurred in the RareFactSharedCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
125 //**********************************************************************************************************************