5 * Created by Sarah Westcott on 3/25/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "heatmapcommand.h"
13 //**********************************************************************************************************************
15 HeatMapCommand::HeatMapCommand(){
17 globaldata = GlobalData::getInstance();
18 heatmap = new HeatMap();
19 format = globaldata->getFormat();
23 cout << "Standard Error: " << e.what() << " has occurred in the HeatMapCommand class Function HeatMapCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
27 cout << "An unknown error has occurred in the HeatMapCommand class function HeatMapCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
31 //**********************************************************************************************************************
33 HeatMapCommand::~HeatMapCommand(){
39 //**********************************************************************************************************************
41 int HeatMapCommand::execute(){
45 if (format == "sharedfile") {
47 read = new ReadPhilFile(globaldata->inputFileName);
48 read->read(&*globaldata);
50 input = globaldata->ginput;
51 order = input->getSharedOrderVector();
52 }else if (format == "shared") {
53 //you are using a list and a groupfile
54 read = new ReadPhilFile(globaldata->inputFileName);
55 read->read(&*globaldata);
57 input = globaldata->ginput;
58 SharedList = globaldata->gSharedList;
59 order = SharedList->getSharedOrderVector();
60 }else if (format == "list") {
61 //you are using just a list file and have only one group
62 read = new ReadPhilFile(globaldata->inputFileName);
63 read->read(&*globaldata);
65 ordersingle = globaldata->gorder;
66 input = globaldata->ginput;
70 if (format != "list") {
76 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
78 cout << order->getLabel() << '\t' << count << endl;
79 heatmap->getPic(order);
83 //get next line to process
84 if (format == "sharedfile") {
85 order = input->getSharedOrderVector();
87 //you are using a list and a groupfile
88 SharedList = input->getSharedListVector(); //get new list vector to process
89 if (SharedList != NULL) {
90 order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
98 //reset groups parameter
99 globaldata->Groups.clear(); globaldata->setGroups("");
102 while(ordersingle != NULL){
104 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(ordersingle->getLabel()) == 1){
106 cout << ordersingle->getLabel() << '\t' << count << endl;
107 heatmap->getPic(ordersingle);
111 ordersingle = (input->getOrderVector());
118 catch(exception& e) {
119 cout << "Standard Error: " << e.what() << " has occurred in the HeatMapCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
123 cout << "An unknown error has occurred in the HeatMapCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
128 //**********************************************************************************************************************
129 void HeatMapCommand::setGroups() {
131 //if the user has not entered specific groups to analyze then do them all
132 if (globaldata->Groups.size() != 0) {
133 if (globaldata->Groups[0] != "all") {
134 //check that groups are valid
135 for (int i = 0; i < globaldata->Groups.size(); i++) {
136 if (globaldata->gGroupmap->isValidGroup(globaldata->Groups[i]) != true) {
137 cout << globaldata->Groups[i] << " is not a valid group, and will be disregarded." << endl;
138 // erase the invalid group from globaldata->Groups
139 globaldata->Groups.erase(globaldata->Groups.begin()+i);
143 //if the user only entered invalid groups
144 if (globaldata->Groups.size() == 0) {
145 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;
146 for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
147 globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
150 }else{//user has enter "all" and wants the default groups
151 globaldata->Groups.clear();
152 for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
153 globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
155 globaldata->setGroups("");
158 for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
159 globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
164 catch(exception& e) {
165 cout << "Standard Error: " << e.what() << " has occurred in the HeatMapCommand class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
169 cout << "An unknown error has occurred in the HeatMapCommand class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
174 /***********************************************************/