]> git.donarmstrong.com Git - mothur.git/blobdiff - heatmapsimcommand.cpp
added pipeline commands which involved change to command factory and command class...
[mothur.git] / heatmapsimcommand.cpp
index 61e29390c21ae0a851a3acaede4c9da681d4d7d4..1eb3ceedb228220f8e8d86231866c1606a50b196 100644 (file)
 #include "sharedmorisitahorn.h"
 #include "sharedbraycurtis.h"
 
-
+//**********************************************************************************************************************
+vector<string> HeatMapSimCommand::getValidParameters(){        
+       try {
+               string Array[] =  {"groups","label", "calc","phylip","column","name","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HeatMapSimCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+HeatMapSimCommand::HeatMapSimCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["svg"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HeatMapSimCommand", "HeatMapSimCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> HeatMapSimCommand::getRequiredParameters(){     
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HeatMapSimCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> HeatMapSimCommand::getRequiredFiles(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HeatMapSimCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 HeatMapSimCommand::HeatMapSimCommand(string option)  {
@@ -50,6 +95,10 @@ HeatMapSimCommand::HeatMapSimCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["svg"] = tempOutNames;
+                       
                        format = "";
                        //if the user changes the output directory command factory will send this info to us in the output parameter 
                        outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
@@ -240,7 +289,7 @@ int HeatMapSimCommand::execute(){
                delete heatmap;
                delete validCalculator;
                
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } return 0; }
+               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } outputTypes.clear(); return 0; }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
@@ -264,11 +313,11 @@ int HeatMapSimCommand::runCommandShared() {
                //you have groups
                read = new ReadOTUFile(globaldata->inputFileName);      
                read->read(&*globaldata); 
-                       
+                               
                input = globaldata->ginput;
                lookup = input->getSharedRAbundVectors();
                string lastLabel = lookup[0]->getLabel();
-               
+                       
                if (lookup.size() < 2) { m->mothurOut("You have not provided enough valid groups.  I cannot run the command."); m->mothurOutEndLine(); return 0;}
                                
                //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
@@ -286,7 +335,7 @@ int HeatMapSimCommand::runCommandShared() {
        
                                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                                vector<string> outfilenames = heatmap->getPic(lookup, heatCalculators);
-                               for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); }
+                               for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]); }
                                        
                                processedLabels.insert(lookup[0]->getLabel());
                                userLabels.erase(lookup[0]->getLabel());
@@ -300,7 +349,7 @@ int HeatMapSimCommand::runCommandShared() {
 
                                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                                vector<string> outfilenames = heatmap->getPic(lookup, heatCalculators);
-                               for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); }
+                               for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); outputTypes["svg"].push_back(outfilenames[i]);  }
                                        
                                processedLabels.insert(lookup[0]->getLabel());
                                userLabels.erase(lookup[0]->getLabel());
@@ -315,7 +364,8 @@ int HeatMapSimCommand::runCommandShared() {
 
                        //get next line to process
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input->getSharedRAbundVectors();                               
+                       lookup = input->getSharedRAbundVectors();
+
                }
                
                        
@@ -343,7 +393,7 @@ int HeatMapSimCommand::runCommandShared() {
 
                        m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                        vector<string> outfilenames = heatmap->getPic(lookup, heatCalculators);
-                       for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); }
+                       for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); outputTypes["svg"].push_back(outfilenames[i]);  }
                        
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                }
@@ -352,10 +402,10 @@ int HeatMapSimCommand::runCommandShared() {
                        
                //reset groups parameter
                globaldata->Groups.clear();  
-               
+                       
                delete input;  globaldata->ginput = NULL;
                delete read;
-
+       
                return 0;
        }
        catch(exception& e) {
@@ -481,8 +531,10 @@ int HeatMapSimCommand::runCommandDist() {
                        delete nameMap;
                }
                
-
-               outputNames.push_back(heatmap->getPic(matrix, names)); //vector<vector<double>>, vector<string>
+               
+               string outputFileName = heatmap->getPic(matrix, names);
+               outputNames.push_back(outputFileName); //vector<vector<double>>, vector<string>
+               outputTypes["svg"].push_back(outputFileName);
                
                return 0;
        }