5 * Created by Sarah Westcott on 3/30/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "venncommand.h"
14 //#include "jackknife.h"
15 #include "sharedsobscollectsummary.h"
16 #include "sharedchao1.h"
17 #include "sharedace.h"
20 //**********************************************************************************************************************
22 VennCommand::VennCommand(){
24 globaldata = GlobalData::getInstance();
25 format = globaldata->getFormat();
26 validCalculator = new ValidCalculators();
27 util = new SharedUtil();
31 if (format == "list") {
32 for (i=0; i<globaldata->Estimators.size(); i++) {
33 if (validCalculator->isValidCalculator("vennsingle", globaldata->Estimators[i]) == true) {
34 if (globaldata->Estimators[i] == "sobs") {
35 vennCalculators.push_back(new Sobs());
36 }else if (globaldata->Estimators[i] == "chao") {
37 vennCalculators.push_back(new Chao1());
38 }else if (globaldata->Estimators[i] == "ace") {
39 convert(globaldata->getAbund(), abund);
42 vennCalculators.push_back(new Ace(abund));
43 //}else if (globaldata->Estimators[i] == "jack") {
44 //vennCalculators.push_back(new Jackknife());
49 for (i=0; i<globaldata->Estimators.size(); i++) {
50 if (validCalculator->isValidCalculator("vennshared", globaldata->Estimators[i]) == true) {
51 if (globaldata->Estimators[i] == "sharedsobs") {
52 vennCalculators.push_back(new SharedSobsCS());
53 }else if (globaldata->Estimators[i] == "sharedchao") {
54 vennCalculators.push_back(new SharedChao1());
55 }else if (globaldata->Estimators[i] == "sharedace") {
56 vennCalculators.push_back(new SharedAce());
64 //reset calc for next command
65 globaldata->setCalc("");
70 cout << "Standard Error: " << e.what() << " has occurred in the VennCommand class Function VennCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
74 cout << "An unknown error has occurred in the VennCommand class function VennCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
78 //**********************************************************************************************************************
80 VennCommand::~VennCommand(){
87 //**********************************************************************************************************************
89 int VennCommand::execute(){
93 //if the users entered no valid calculators don't execute command
94 if (vennCalculators.size() == 0) { return 0; }
96 if (format == "sharedfile") {
98 read = new ReadOTUFile(globaldata->inputFileName);
99 read->read(&*globaldata);
101 input = globaldata->ginput;
102 order = input->getSharedOrderVector();
103 }else if (format == "shared") {
104 //you are using a list and a groupfile
105 read = new ReadOTUFile(globaldata->inputFileName);
106 read->read(&*globaldata);
108 input = globaldata->ginput;
109 SharedList = globaldata->gSharedList;
110 order = SharedList->getSharedOrderVector();
111 }else if (format == "list") {
112 //you are using just a list file and have only one group
113 read = new ReadOTUFile(globaldata->inputFileName);
114 read->read(&*globaldata);
116 ordersingle = globaldata->gorder;
117 input = globaldata->ginput;
121 if (format != "list") {
123 util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "venn");
124 globaldata->setGroups("");
126 while(order != NULL){
128 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
130 cout << order->getLabel() << '\t' << count << endl;
131 venn->getPic(order, vennCalculators);
135 //get next line to process
136 if (format == "sharedfile") {
137 order = input->getSharedOrderVector();
139 //you are using a list and a groupfile
140 SharedList = input->getSharedListVector(); //get new list vector to process
141 if (SharedList != NULL) {
142 order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
150 //reset groups parameter
151 globaldata->Groups.clear();
154 while(ordersingle != NULL){
156 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(ordersingle->getLabel()) == 1){
158 cout << ordersingle->getLabel() << '\t' << count << endl;
159 venn->getPic(ordersingle, vennCalculators);
163 ordersingle = (input->getOrderVector());
170 catch(exception& e) {
171 cout << "Standard Error: " << e.what() << " has occurred in the VennCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
175 cout << "An unknown error has occurred in the VennCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
180 //**********************************************************************************************************************