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) + "heatmap" + 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 //fills vector of sharedsabunds - lookup
49 getSharedVectors(sharedorder);
51 string filename = getRootName(globaldata->inputFileName) + "heatmap" + sharedorder->getLabel();
56 cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
60 cout << "An unknown error has occurred in the HeatMap class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
64 //**********************************************************************************************************************
65 void HeatMap::getSharedVectors(SharedOrderVector* order){
69 vector<SharedRAbundVector*> templookup;
71 //create and initialize vector of sharedvectors, one for each group
72 for (int i = 0; i < globaldata->Groups.size(); i++) {
73 SharedRAbundVector* temp = new SharedRAbundVector(order->getMaxRank());
74 temp->setLabel(order->getLabel());
75 temp->setGroup(globaldata->Groups[i]);
76 templookup.push_back(temp);
79 int numSeqs = order->size();
80 //sample all the members
81 for(int i=0;i<numSeqs;i++){
83 individual chosen = order->get(i);
86 //set info for sharedvector in chosens group
87 for (int j = 0; j < templookup.size(); j++) {
88 if (chosen.group == templookup[j]->getGroup()) {
89 abundance = templookup[j]->getAbundance(chosen.bin);
90 templookup[j]->set(chosen.bin, (abundance + 1), chosen.group);
96 //convert templookups rabunds to lookups sabunds
97 for (int j = 0; j < templookup.size(); j++) {
98 lookup.push_back(templookup[j]->getSharedSAbundVector());
104 catch(exception& e) {
105 cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
109 cout << "An unknown error has occurred in the HeatMap class function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
115 //**********************************************************************************************************************
116 void HeatMap::setGroups() {
118 //if the user has not entered specific groups to analyze then do them all
119 if (globaldata->Groups.size() != 0) {
120 if (globaldata->Groups[0] != "all") {
121 //check that groups are valid
122 for (int i = 0; i < globaldata->Groups.size(); i++) {
123 if (globaldata->gGroupmap->isValidGroup(globaldata->Groups[i]) != true) {
124 cout << globaldata->Groups[i] << " is not a valid group, and will be disregarded." << endl;
125 // erase the invalid group from globaldata->Groups
126 globaldata->Groups.erase(globaldata->Groups.begin()+i);
130 //if the user only entered invalid groups
131 if (globaldata->Groups.size() == 0) {
132 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;
133 for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
134 globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
137 }else{//user has enter "all" and wants the default groups
138 globaldata->Groups.clear();
139 for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
140 globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
142 globaldata->setGroups("");
145 for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
146 globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
151 catch(exception& e) {
152 cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
156 cout << "An unknown error has occurred in the HeatMap class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
161 /***********************************************************/