5 * Created by Sarah Westcott on 1/2/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "sharedcommand.h"
12 //**********************************************************************************************************************
14 SharedCommand::SharedCommand(){
16 globaldata = GlobalData::getInstance();
18 //getting output filename
19 filename = globaldata->inputFileName;
20 filename = getRootName(filename);
21 filename = filename + "shared";
22 openOutputFile(filename, out);
25 cout << "Standard Error: " << e.what() << " has occurred in the SharedCommand class Function SharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
29 cout << "An unknown error has occurred in the SharedCommand class function SharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
34 //**********************************************************************************************************************
36 int SharedCommand::execute(){
38 globaldata = GlobalData::getInstance();
41 read = new ReadOTUFile(globaldata->inputFileName);
42 read->read(&*globaldata);
43 input = globaldata->ginput;
44 SharedList = globaldata->gSharedList;
46 shared = new Shared();
48 while(SharedList != NULL){
50 if(globaldata->allLines == 1 || globaldata->lines.count(i+1) == 1 || globaldata->labels.count(SharedList->getLabel()) == 1){
52 shared->getSharedVectors(i, SharedList); //fills sharedGroups with new info and updates sharedVector
53 printSharedData(); //prints info to the .shared file
56 SharedList = input->getSharedListVector(); //get new list vector to process
62 cout << "Standard Error: " << e.what() << " has occurred in the SharedCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
66 cout << "An unknown error has occurred in the SharedCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
71 //**********************************************************************************************************************
72 void SharedCommand::printSharedData() {
74 //prints out horizontally
75 for (it = shared->sharedGroups.begin(); it != shared->sharedGroups.end(); it++) {
76 out << it->second->getLabel() << "\t" << it->first << "\t"; //prints out label and groupname
77 it->second->print(out); // prints sharedrabundvector
81 cout << "Standard Error: " << e.what() << " has occurred in the SharedCommand class Function printSharedData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
85 cout << "An unknown error has occurred in the SharedCommand class function printSharedData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
91 //**********************************************************************************************************************
93 SharedCommand::~SharedCommand(){
98 //**********************************************************************************************************************