]> git.donarmstrong.com Git - mothur.git/blobdiff - heatmapcommand.cpp
added set.dir command and modified commands to redirect input and output, removed...
[mothur.git] / heatmapcommand.cpp
index 52395bb2a2613f24846e031f530519afbd2ed39c..04f12456a49b623a82bf3e009929d7a31870da35 100644 (file)
@@ -24,7 +24,7 @@ HeatMapCommand::HeatMapCommand(string option){
                
                else {
                        //valid paramters for this command
-                       string AlignArray[] =  {"groups","label","sorted","scale"};
+                       string AlignArray[] =  {"groups","label","sorted","scale","outputdir","inputdir"};
                        vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
                        
                        OptionParser parser(option);
@@ -37,6 +37,12 @@ HeatMapCommand::HeatMapCommand(string option){
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //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 = ""; 
+                               outputDir += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it  
+                       }
+                       
                        //make sure the user has already run the read.otu command
                        if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "") && (globaldata->getSharedFile() == "")) {
                                 mothurOut("You must read a list, rabund, sabund, or a list and a group, or a shared before you can use the heatmap.bin command."); mothurOutEndLine(); abort = true; 
@@ -69,7 +75,7 @@ HeatMapCommand::HeatMapCommand(string option){
                        scale = validParameter.validFile(parameters, "scale", false);                           if (scale == "not found") { scale = "log10"; }
                        
                        if (abort == false) {
-                               heatmap = new HeatMap(sorted, scale);
+                               heatmap = new HeatMap(sorted, scale, outputDir);
                                format = globaldata->getFormat();
                        }
                }
@@ -163,6 +169,8 @@ int HeatMapCommand::execute(){
                                }
                                
                                if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       string saveLabel = lookup[0]->getLabel();
+                               
                                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
                                        lookup = input->getSharedRAbundVectors(lastLabel);
                                        mothurOut(lookup[0]->getLabel()); mothurOutEndLine();
@@ -171,6 +179,9 @@ int HeatMapCommand::execute(){
                                        
                                        processedLabels.insert(lookup[0]->getLabel());
                                        userLabels.erase(lookup[0]->getLabel());
+                                       
+                                       //restore real lastlabel to save below
+                                       lookup[0]->setLabel(saveLabel);
                                }
                                
                                lastLabel = lookup[0]->getLabel();
@@ -223,7 +234,8 @@ int HeatMapCommand::execute(){
                                }
                                
                                if ((anyLabelsToProcess(rabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-
+                                       string saveLabel = rabund->getLabel();
+                                       
                                        delete rabund;
                                        rabund = input->getRAbundVector(lastLabel);
                                        mothurOut(rabund->getLabel()); mothurOutEndLine();
@@ -232,6 +244,9 @@ int HeatMapCommand::execute(){
                                        
                                        processedLabels.insert(rabund->getLabel());
                                        userLabels.erase(rabund->getLabel());
+                                       
+                                       //restore real lastlabel to save below
+                                       rabund->setLabel(saveLabel);
                                }