]> git.donarmstrong.com Git - mothur.git/blobdiff - venncommand.cpp
pat's differences before v.1.8
[mothur.git] / venncommand.cpp
index b6a53e67eaa8947ffd6d4b48b26e11fe23d7bdc4..437f044e841783059421a121a2d89bc079207c54 100644 (file)
@@ -31,7 +31,7 @@ VennCommand::VennCommand(string option){
                
                else {
                        //valid paramters for this command
-                       string AlignArray[] =  {"groups","label","calc", "abund"};
+                       string AlignArray[] =  {"groups","label","calc", "abund","outputdir","inputdir"};
                        vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
                        
                        OptionParser parser(option);
@@ -48,6 +48,12 @@ VennCommand::VennCommand(string option){
                        if ((globaldata->getListFile() == "") && (globaldata->getSharedFile() == "")) {
                                mothurOut("You must read a list, or a list and a group, or a shared before you can use the venn command."); mothurOutEndLine(); 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  
+                       }
 
                        //check for optional parameter and set defaults
                        // ...at some point should added some additional type checking...
@@ -122,7 +128,7 @@ VennCommand::VennCommand(string option){
                                        }
                                }
                                
-                               venn = new Venn();
+                               venn = new Venn(outputDir);
                        }
                }
 
@@ -223,6 +229,8 @@ int VennCommand::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);
 
@@ -235,6 +243,9 @@ int VennCommand::execute(){
                                                for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
                                        }                               
                                        venn->getPic(lookup, vennCalculators);
+                                       
+                                       //restore real lastlabel to save below
+                                       lookup[0]->setLabel(saveLabel);
                                }
                                
                                
@@ -293,6 +304,8 @@ int VennCommand::execute(){
                                }
                                
                                if ((anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       string saveLabel = sabund->getLabel();
+                               
                                        delete sabund;
                                        sabund = input->getSAbundVector(lastLabel);
                                        
@@ -301,6 +314,9 @@ int VennCommand::execute(){
                                        
                                        processedLabels.insert(sabund->getLabel());
                                        userLabels.erase(sabund->getLabel());
+                                       
+                                       //restore real lastlabel to save below
+                                       sabund->setLabel(saveLabel);
                                }               
                                
                                lastLabel = sabund->getLabel();