]> git.donarmstrong.com Git - mothur.git/blobdiff - venncommand.cpp
added cluster.fragments command as well as the nseqs parameter to the venn command
[mothur.git] / venncommand.cpp
index 35c814d2625a4f236667646801e01eb1b6c056bd..5fa06aa98d0eeed0783c9d53eb5f3663e0405c14 100644 (file)
@@ -15,6 +15,7 @@
 #include "sharedsobscollectsummary.h"
 #include "sharedchao1.h"
 #include "sharedace.h"
+#include "nseqs.h"
 
 
 //**********************************************************************************************************************
@@ -31,7 +32,7 @@ VennCommand::VennCommand(string option)  {
                
                else {
                        //valid paramters for this command
-                       string AlignArray[] =  {"groups","label","calc", "abund","outputdir","inputdir"};
+                       string AlignArray[] =  {"groups","label","calc", "abund","nseqs","outputdir","inputdir"};
                        vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
                        
                        OptionParser parser(option);
@@ -52,7 +53,7 @@ VennCommand::VennCommand(string option)  {
                        //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  
+                               outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it       
                        }
 
                        //check for optional parameter and set defaults
@@ -60,7 +61,7 @@ VennCommand::VennCommand(string option)  {
                        label = validParameter.validFile(parameters, "label", false);                   
                        if (label == "not found") { label = ""; }
                        else { 
-                               if(label != "all") {  splitAtDash(label, labels);  allLines = 0;  }
+                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
                                else { allLines = 1;  }
                        }
                        
@@ -73,7 +74,7 @@ VennCommand::VennCommand(string option)  {
                        groups = validParameter.validFile(parameters, "groups", false);                 
                        if (groups == "not found") { groups = ""; }
                        else { 
-                               splitAtDash(groups, Groups);
+                               m->splitAtDash(groups, Groups);
                                globaldata->Groups = Groups;
                        }
                        
@@ -89,11 +90,15 @@ VennCommand::VennCommand(string option)  {
                                        else { calc = "sharedsobs"; }
                                }
                        }
-                       splitAtDash(calc, Estimators);
+                       m->splitAtDash(calc, Estimators);
                        
                        string temp;
                        temp = validParameter.validFile(parameters, "abund", false);            if (temp == "not found") { temp = "10"; }
                        convert(temp, abund); 
+                       
+                       temp = validParameter.validFile(parameters, "nseqs", false);                    if (temp == "not found"){       temp = "f";                             }
+                       nseqs = m->isTrue(temp); 
+
 
                        if (abort == false) {
                                validCalculator = new ValidCalculators();
@@ -128,8 +133,11 @@ VennCommand::VennCommand(string option)  {
                                        }
                                }
                                
-                               venn = new Venn(outputDir);
+                               //if the users entered no valid calculators don't execute command
+                               if (vennCalculators.size() == 0) { m->mothurOut("No valid calculators given, please correct."); m->mothurOutEndLine(); abort = true;  }
+                               else {  venn = new Venn(outputDir, nseqs);  }
                        }
+                       
                }
 
                
@@ -146,7 +154,7 @@ VennCommand::VennCommand(string option)  {
 void VennCommand::help(){
        try {
                m->mothurOut("The venn command can only be executed after a successful read.otu command.\n");
-               m->mothurOut("The venn command parameters are groups, calc, abund and label.  No parameters are required.\n");
+               m->mothurOut("The venn command parameters are groups, calc, abund, nseqs and label.  No parameters are required.\n");
                m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like included in your venn diagram, you may only use a maximum of 4 groups.\n");
                m->mothurOut("The group names are separated by dashes. The label allows you to select what distance levels you would like a venn diagram created for, and are also separated by dashes.\n");
                m->mothurOut("The venn command should be in the following format: venn(groups=yourGroups, calc=yourCalcs, label=yourLabels, abund=yourAbund).\n");
@@ -154,7 +162,8 @@ void VennCommand::help(){
                m->mothurOut("The default value for groups is all the groups in your groupfile up to 4, and all labels in your inputfile will be used.\n");
                m->mothurOut("The default value for calc is sobs if you have only read a list file or if you have selected only one group, and sharedsobs if you have multiple groups.\n");
                m->mothurOut("The default available estimators for calc are sobs, chao and ace if you have only read a list file, and sharedsobs, sharedchao and sharedace if you have read a list and group file or a shared file.\n");
-               m->mothurOut("The only estmiator available four 4 groups is sharedsobs.\n");
+               m->mothurOut("The nseqs parameter will output the number of sequences represented by the otus in the picture, default=F.\n");
+               m->mothurOut("The only estimators available four 4 groups are sharedsobs and sharedchao.\n");
                m->mothurOut("The venn command outputs a .svg file for each calculator you specify at each distance you choose.\n");
                m->mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
        }
@@ -188,9 +197,6 @@ int VennCommand::execute(){
                string lastLabel;
                vector<string> outputNames;
                
-               //if the users entered no valid calculators don't execute command
-               if (vennCalculators.size() == 0) { return 0; }
-               
                if (format == "sharedfile") {
                        //you have groups
                        read = new ReadOTUFile(globaldata->inputFileName);      
@@ -240,7 +246,7 @@ int VennCommand::execute(){
                                        for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
                                }
                                
-                               if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                               if ((m->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];  } 
@@ -342,7 +348,7 @@ int VennCommand::execute(){
                                        userLabels.erase(sabund->getLabel());
                                }
                                
-                               if ((anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                               if ((m->anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
                                        string saveLabel = sabund->getLabel();
                                
                                        delete sabund;