]> git.donarmstrong.com Git - mothur.git/blobdiff - venncommand.cpp
changes for 1.16.0
[mothur.git] / venncommand.cpp
index 852ee8c7ccb79f2a6422448b4d46f3dd752d6c94..7601ed8e667b10e2b2cd6eaf48c8f5ce365cc6f0 100644 (file)
 #include "nseqs.h"
 
 
+//**********************************************************************************************************************
+vector<string> VennCommand::getValidParameters(){      
+       try {
+               string Array[] =  {"groups","label","calc","permute", "abund","nseqs","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "VennCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+VennCommand::VennCommand(){    
+       try {
+               abort = true;
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["svg"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "VennCommand", "VennCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> VennCommand::getRequiredParameters(){   
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "VennCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> VennCommand::getRequiredFiles(){        
+       try {
+               string Array[] =  {"list","shared","or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "VennCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 VennCommand::VennCommand(string option)  {
@@ -198,7 +246,6 @@ int VennCommand::execute(){
                if (abort == true) { return 0; }
                
                string lastLabel;
-               vector<string> outputNames;
                
                if (format == "sharedfile") {
                        //you have groups
@@ -247,7 +294,7 @@ int VennCommand::execute(){
                                                for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
                                        
                                                vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  }
+                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  } }
 
                                        }else if ((lookup.size() > 4) && (perm)) {
                                                set< set<int> >::iterator it3;
@@ -259,11 +306,11 @@ int VennCommand::execute(){
                                                        for (it2 = poss.begin(); it2 != poss.end(); it2++) {   subset.push_back(lookup[*it2]);   }
                                                        
                                                        vector<string> outfilenames = venn->getPic(subset, vennCalculators);
-                                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]); }  }
                                                }               
                                        }else {
                                                vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
                                        }                                       
                                }
                                
@@ -282,7 +329,7 @@ int VennCommand::execute(){
                                                for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
                                        
                                                vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
 
                                        }else if ((lookup.size() > 4) && (perm)) {
                                                set< set<int> >::iterator it3;
@@ -294,11 +341,11 @@ int VennCommand::execute(){
                                                        for (it2 = poss.begin(); it2 != poss.end(); it2++) {   subset.push_back(lookup[*it2]);   }
                                                        
                                                        vector<string> outfilenames = venn->getPic(subset, vennCalculators);
-                                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
                                                }               
                                        }else {
                                                vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
                                        }
                                                                                
                                        //restore real lastlabel to save below
@@ -348,7 +395,7 @@ int VennCommand::execute(){
                                                for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
                                        
                                                vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]); }  }
 
                                        }else if ((lookup.size() > 4) && (perm)) {
                                                set< set<int> >::iterator it3;
@@ -360,11 +407,11 @@ int VennCommand::execute(){
                                                        for (it2 = poss.begin(); it2 != poss.end(); it2++) {   subset.push_back(lookup[*it2]);   }
                                                        
                                                        vector<string> outfilenames = venn->getPic(subset, vennCalculators);
-                                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]); }  }
                                                }               
                                        }else {
                                                vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
                                        }
                                        
                                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
@@ -396,7 +443,7 @@ int VennCommand::execute(){
        
                                        m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
                                        vector<string> outfilenames = venn->getPic(sabund, vennCalculators);
-                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
 
                                        
                                        processedLabels.insert(sabund->getLabel());
@@ -411,7 +458,7 @@ int VennCommand::execute(){
                                        
                                        m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
                                        vector<string> outfilenames = venn->getPic(sabund, vennCalculators);
-                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
 
                                        
                                        processedLabels.insert(sabund->getLabel());
@@ -453,7 +500,7 @@ int VennCommand::execute(){
                                        
                                m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
                                vector<string> outfilenames = venn->getPic(sabund, vennCalculators);
-                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
 
                                delete sabund;