]> git.donarmstrong.com Git - mothur.git/blob - heatmapcommand.cpp
started heatmap 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                 format = globaldata->getFormat();
19         }
20         catch(exception& e) {
21                 cout << "Standard Error: " << e.what() << " has occurred in the HeatMapCommand class Function HeatMapCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
22                 exit(1);
23         }
24         catch(...) {
25                 cout << "An unknown error has occurred in the HeatMapCommand class function HeatMapCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
26                 exit(1);
27         }       
28 }
29 //**********************************************************************************************************************
30
31 HeatMapCommand::~HeatMapCommand(){
32         delete input;
33         delete read;
34 }
35
36 //**********************************************************************************************************************
37
38 int HeatMapCommand::execute(){
39         try {
40                 int count = 1;  
41                 
42                 if (format == "sharedfile") {
43                         //you have groups
44                         read = new ReadPhilFile(globaldata->inputFileName);     
45                         read->read(&*globaldata); 
46                         
47                         input = globaldata->ginput;
48                         order = input->getSharedOrderVector();
49                 }else if (format == "shared") {
50                         //you are using a list and a groupfile
51                         read = new ReadPhilFile(globaldata->inputFileName);     
52                         read->read(&*globaldata); 
53                 
54                         input = globaldata->ginput;
55                         SharedList = globaldata->gSharedList;
56                         order = SharedList->getSharedOrderVector();
57                 }else if (format == "list") {
58                         //you are using just a list file and have only one group
59                         read = new ReadPhilFile(globaldata->inputFileName);     
60                         read->read(&*globaldata); 
61                 
62                         ordersingle = globaldata->gorder;
63                         input = globaldata->ginput;
64                 }
65                 
66                 if (format != "list") { 
67                         while(order != NULL){
68                 
69                                 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){                       
70         
71                                         cout << order->getLabel() << '\t' << count << endl;
72 //call heatmap class to make file
73                                 }
74                                                 
75                                 //get next line to process
76                                 if (format == "sharedfile") {
77                                         order = input->getSharedOrderVector();
78                                 }else {
79                                         //you are using a list and a groupfile
80                                         SharedList = input->getSharedListVector(); //get new list vector to process
81                                         if (SharedList != NULL) {
82                                                 order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
83                                         }else {
84                                                 break;
85                                         }
86                                 }
87                                 count++;
88                         }
89                         
90                         //reset groups parameter
91                         globaldata->Groups.clear();  globaldata->setGroups("");
92                         
93                 }else{
94                         while(ordersingle != NULL){
95                 
96                                 if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){                       
97         
98                                         cout << order->getLabel() << '\t' << count << endl;
99 //call heatmap class to make file
100                                 }
101                                 
102                                 ordersingle = (input->getOrderVector());
103                                 count++;
104                         }
105                 }
106                 
107                 return 0;
108         }
109         catch(exception& e) {
110                 cout << "Standard Error: " << e.what() << " has occurred in the HeatMapCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
111                 exit(1);
112         }
113         catch(...) {
114                 cout << "An unknown error has occurred in the HeatMapCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
115                 exit(1);
116         }               
117 }
118
119 //**********************************************************************************************************************
120