5 * Created by Sarah Westcott on 3/25/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
12 //**********************************************************************************************************************
15 globaldata = GlobalData::getInstance();
16 format = globaldata->getFormat();
18 if (format != "list") { setGroups(); }
22 cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function HeatMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
26 cout << "An unknown error has occurred in the HeatMap class function HeatMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
30 //**********************************************************************************************************************
31 void HeatMap::getPic(OrderVector* order) {
33 sabund = order->getSAbundVector();
34 string filename = getRootName(globaldata->inputFileName) + order->getLabel();
37 cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
41 cout << "An unknown error has occurred in the HeatMap class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
45 //**********************************************************************************************************************
46 void HeatMap::getPic(SharedOrderVector* sharedorder) {
48 getSharedVectors(sharedorder);
53 cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
57 cout << "An unknown error has occurred in the HeatMap class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
61 //**********************************************************************************************************************
62 void HeatMap::getSharedVectors(SharedOrderVector* order){
66 vector<SharedRAbundVector*> templookup;
68 //create and initialize vector of sharedvectors, one for each group
69 for (int i = 0; i < globaldata->Groups.size(); i++) {
70 SharedRAbundVector* temp = new SharedRAbundVector(order->getNumBins());
71 temp->setLabel(order->getLabel());
72 temp->setGroup(globaldata->Groups[i]);
73 templookup.push_back(temp);
76 int numSeqs = order->size();
77 //sample all the members
78 for(int i=0;i<numSeqs;i++){
80 individual chosen = order->get(i);
83 //set info for sharedvector in chosens group
84 for (int j = 0; j < templookup.size(); j++) {
85 if (chosen.group == templookup[j]->getGroup()) {
86 abundance = templookup[j]->getAbundance(chosen.bin);
87 templookup[j]->set(chosen.bin, (abundance + 1), chosen.group);
93 //convert templookups rabunds to lookups sabunds
94 for (int j = 0; j < templookup.size(); j++) {
95 lookup.push_back(templookup[j]->getSharedSAbundVector());
101 catch(exception& e) {
102 cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
106 cout << "An unknown error has occurred in the HeatMap class function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
112 //**********************************************************************************************************************
113 void HeatMap::setGroups() {
115 //if the user has not entered specific groups to analyze then do them all
116 if (globaldata->Groups.size() != 0) {
117 if (globaldata->Groups[0] != "all") {
118 //check that groups are valid
119 for (int i = 0; i < globaldata->Groups.size(); i++) {
120 if (globaldata->gGroupmap->isValidGroup(globaldata->Groups[i]) != true) {
121 cout << globaldata->Groups[i] << " is not a valid group, and will be disregarded." << endl;
122 // erase the invalid group from globaldata->Groups
123 globaldata->Groups.erase(globaldata->Groups.begin()+i);
127 //if the user only entered invalid groups
128 if (globaldata->Groups.size() == 0) {
129 cout << "When using the groups parameter you must have at least 1 valid groups. I will run the command using all the groups in your groupfile." << endl;
130 for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
131 globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
134 }else{//user has enter "all" and wants the default groups
135 globaldata->Groups.clear();
136 for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
137 globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
139 globaldata->setGroups("");
142 for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
143 globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
148 catch(exception& e) {
149 cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
153 cout << "An unknown error has occurred in the HeatMap class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
158 /***********************************************************/