]> git.donarmstrong.com Git - mothur.git/blob - heatmapcommand.cpp
started shared utilities, updates to venn and heatmap added tree.groups command
[mothur.git] / heatmapcommand.cpp
1 /*
2  *  heatmapcommand.cpp
3  *  Mothur
4  *
5  *  Created by Sarah Westcott on 3/25/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "heatmapcommand.h"
11
12
13 //**********************************************************************************************************************
14
15 HeatMapCommand::HeatMapCommand(){
16         try {
17                 globaldata = GlobalData::getInstance();
18                 heatmap = new HeatMap();
19                 format = globaldata->getFormat();
20                 util = new SharedUtil();
21                 
22         }
23         catch(exception& e) {
24                 cout << "Standard Error: " << e.what() << " has occurred in the HeatMapCommand class Function HeatMapCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
25                 exit(1);
26         }
27         catch(...) {
28                 cout << "An unknown error has occurred in the HeatMapCommand class function HeatMapCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
29                 exit(1);
30         }       
31 }
32 //**********************************************************************************************************************
33
34 HeatMapCommand::~HeatMapCommand(){
35         delete input;
36         delete read;
37         delete heatmap;
38         delete util;
39 }
40
41 //**********************************************************************************************************************
42
43 int HeatMapCommand::execute(){
44         try {
45                 int count = 1;  
46                 
47                 if (format == "sharedfile") {
48                         //you have groups
49                         read = new ReadPhilFile(globaldata->inputFileName);     
50                         read->read(&*globaldata); 
51                         
52                         input = globaldata->ginput;
53                         order = input->getSharedOrderVector();
54                 }else if (format == "shared") {
55                         //you are using a list and a groupfile
56                         read = new ReadPhilFile(globaldata->inputFileName);     
57                         read->read(&*globaldata); 
58                 
59                         input = globaldata->ginput;
60                         SharedList = globaldata->gSharedList;
61                         order = SharedList->getSharedOrderVector();
62                 }else if (format == "list") {
63                         //you are using just a list file and have only one group
64                         read = new ReadPhilFile(globaldata->inputFileName);     
65                         read->read(&*globaldata); 
66                 
67                         ordersingle = globaldata->gorder;
68                         input = globaldata->ginput;
69                 }
70                 
71                                 
72                 if (format != "list") { 
73                 
74                         util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "heat");
75                         globaldata->setGroups("");
76
77
78                         while(order != NULL){
79                 
80                                 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){                       
81         
82                                         cout << order->getLabel() << '\t' << count << endl;
83                                         heatmap->getPic(order);
84
85                                 }
86                                                 
87                                 //get next line to process
88                                 if (format == "sharedfile") {
89                                         order = input->getSharedOrderVector();
90                                 }else {
91                                         //you are using a list and a groupfile
92                                         SharedList = input->getSharedListVector(); //get new list vector to process
93                                         if (SharedList != NULL) {
94                                                 order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
95                                         }else {
96                                                 break;
97                                         }
98                                 }
99                                 count++;
100                         }
101                         
102                         //reset groups parameter
103                         globaldata->Groups.clear();  
104                         
105                 }else{
106                         while(ordersingle != NULL){
107                 
108                                 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(ordersingle->getLabel()) == 1){                 
109         
110                                         cout << ordersingle->getLabel() << '\t' << count << endl;
111                                         heatmap->getPic(ordersingle);
112                                         
113                                 }
114                                 
115                                 ordersingle = (input->getOrderVector());
116                                 count++;
117                         }
118                 }
119                 
120                 return 0;
121         }
122         catch(exception& e) {
123                 cout << "Standard Error: " << e.what() << " has occurred in the HeatMapCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
124                 exit(1);
125         }
126         catch(...) {
127                 cout << "An unknown error has occurred in the HeatMapCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
128                 exit(1);
129         }               
130 }
131
132 //**********************************************************************************************************************
133
134