]> git.donarmstrong.com Git - mothur.git/commitdiff
modified freq parameter be a percentage of numSeqs, added catchall command - not...
authorwestcott <westcott>
Wed, 12 May 2010 12:15:09 +0000 (12:15 +0000)
committerwestcott <westcott>
Wed, 12 May 2010 12:15:09 +0000 (12:15 +0000)
20 files changed:
Mothur.xcodeproj/project.pbxproj
catchallcommand.cpp [new file with mode: 0644]
catchallcommand.h [new file with mode: 0644]
clearcutcommand.cpp
collect.cpp
collect.h
collectcommand.cpp
collectcommand.h
collectsharedcommand.cpp
collectsharedcommand.h
commandfactory.cpp
makefile
phylodiversitycommand.cpp
phylodiversitycommand.h
rarefact.cpp
rarefact.h
rarefactcommand.cpp
rarefactcommand.h
rarefactsharedcommand.cpp
rarefactsharedcommand.h

index 259ef9c4f47269d52fcf86d15458e04a248c621f..5b5981b1608c62ffbc486921d3c1f3e5cdc8dcb8 100644 (file)
@@ -32,6 +32,8 @@
                A78434891162224F00100BE0 /* chimeraccodecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimeraccodecommand.cpp; sourceTree = "<group>"; };
                A7D215C811996C6E00F13F13 /* clearcutcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clearcutcommand.h; sourceTree = "<group>"; };
                A7D215C911996C6E00F13F13 /* clearcutcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clearcutcommand.cpp; sourceTree = "<group>"; };
+               A7D216061199C47F00F13F13 /* catchallcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catchallcommand.h; sourceTree = "<group>"; };
+               A7D216071199C47F00F13F13 /* catchallcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = catchallcommand.cpp; sourceTree = "<group>"; };
                A7DA1FEC113FECD400BF472F /* ace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ace.cpp; sourceTree = "<group>"; };
                A7DA1FED113FECD400BF472F /* ace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ace.h; sourceTree = "<group>"; };
                A7DA1FEE113FECD400BF472F /* aligncommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = aligncommand.cpp; sourceTree = "<group>"; };
                                A7DA1FFE113FECD400BF472F /* binsequencecommand.h */,
                                A7DA2007113FECD400BF472F /* bootstrapsharedcommand.cpp */,
                                A7DA2008113FECD400BF472F /* bootstrapsharedcommand.h */,
+                               A7D216061199C47F00F13F13 /* catchallcommand.h */,
+                               A7D216071199C47F00F13F13 /* catchallcommand.cpp */,
                                A7DA2017113FECD400BF472F /* chimeraseqscommand.cpp */,
                                A78434881162224F00100BE0 /* chimeraccodecommand.h */,
                                A7DA2018113FECD400BF472F /* chimeraseqscommand.h */,
diff --git a/catchallcommand.cpp b/catchallcommand.cpp
new file mode 100644 (file)
index 0000000..434c273
--- /dev/null
@@ -0,0 +1,293 @@
+/*
+ *  catchallcommand.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 5/11/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "catchallcommand.h"
+#include "globaldata.hpp"
+
+/**************************************************************************************/
+CatchAllCommand::CatchAllCommand(string option)  {     
+       try {
+               globaldata = GlobalData::getInstance();
+               abort = false;
+               allLines = 0;
+               
+               //allow user to run help
+               if(option == "help") { help(); abort = true; }
+               
+               else {
+                       //valid paramters for this command
+                       string Array[] =  {"sabund","label","inputdir","outputdir"};
+                       vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+                       
+                       OptionParser parser(option);
+                       map<string,string> parameters = parser.getParameters();
+                       
+                       ValidParameters validParameter;
+                       map<string, string>::iterator it;
+               
+                       //check to make sure all parameters are valid for command
+                       for (it = parameters.begin(); it != parameters.end(); it++) { 
+                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
+                       }
+                       
+                       //if the user changes the input directory command factory will send this info to us in the output parameter 
+                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
+                       if (inputDir == "not found"){   inputDir = "";          }
+                       else {
+                               string path;
+                               it = parameters.find("sabund");
+                               //user has given a template file
+                               if(it != parameters.end()){ 
+                                       path = hasPath(it->second);
+                                       //if the user has not given a path then, add inputdir. else leave path alone.
+                                       if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
+                               }
+                       }
+
+                       //check for required parameters
+                       sabundfile = validParameter.validFile(parameters, "sabund", true);
+                       if (sabundfile == "not open") { sabundfile = ""; abort = true; }
+                       else if (sabundfile == "not found") { sabundfile = "";  m->mothurOut("You must provide either a sabund file for the catchall command."); m->mothurOutEndLine(); abort=true; }
+                       else { globaldata->setSabundFile(sabundfile); globaldata->setFormat("sabund"); }
+                       
+                       string label = validParameter.validFile(parameters, "label", false);                    
+                       if (label == "not found") { label = ""; }
+                       else { 
+                               if(label != "all") {  splitAtDash(label, labels);  allLines = 0;  }
+                               else { allLines = 1;  }
+                       }
+               
+
+                       //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 = "./";       }
+               }
+
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CatchAllCommand", "CatchAllCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+void CatchAllCommand::help(){
+       try {
+               m->mothurOut("The catchall command interfaces mothur with the catchall program written by ...citation goes here...\n");
+               m->mothurOut("For more information about clearcut refer to http://catchall.cac.cornell.edu/ \n");
+               m->mothurOut("The catchall executable must be in a folder called catchall in the same folder as your mothur executable, similar to mothur's requirements for using blast. \n");
+               m->mothurOut("The catchall command parameters are sabund and label, sabund is required. \n");
+               m->mothurOut("The label parameter is used to analyze specific labels in your input.\n");
+               m->mothurOut("The catchall command should be in the following format: \n");
+               m->mothurOut("catchall(sabund=yourSabundFile) \n");
+               m->mothurOut("Example: catchall(sabund=abrecovery.fn.sabund) \n");      
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CatchAllCommand", "help");
+               exit(1);
+       }
+}
+
+/**************************************************************************************/
+int CatchAllCommand::execute() {       
+       try {
+               
+               if (abort == true) { return 0; }
+               
+               vector<string> outputNames;
+               
+               //prepare full output directory
+               outputDir = getFullPathName(outputDir);
+               
+               //get location of catchall
+               GlobalData* globaldata = GlobalData::getInstance();
+               string path = globaldata->argv;
+               path = path.substr(0, (path.find_last_of('m')));
+               path = getFullPathName(path);
+
+               string catchAllCommandExe = ""; 
+               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                       catchAllCommandExe += "mono " + path + "catchall/CatchAllcmdL.exe ";
+               #else
+                       catchAllCommandExe += path + "catchall/CatchAllcmdW.exe ";
+               #endif
+               
+               read = new ReadOTUFile(sabundfile);     
+               read->read(&*globaldata); 
+               
+               SAbundVector* sabund = globaldata->sabund;
+               string lastLabel = sabund->getLabel();
+               input = globaldata->ginput;
+                                               
+               set<string> processedLabels;
+               set<string> userLabels = labels;
+               
+               //for each label the user selected
+               while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
+
+                                       
+                       if(allLines == 1 || labels.count(sabund->getLabel()) == 1){
+                                       m->mothurOut(sabund->getLabel());  m->mothurOutEndLine();
+                                       
+                                       //create list of output files catchall will make
+                                       //datasetname_Analysis.csv 
+                                       //datasetname_BestModelsAnalysis.csv
+                                       //datasetname_BestModelsFits.csv 
+                                       //datasetname_BubblePlot.csv 
+                                       //datasetname_Poisson_fits.csv 
+                                       //datasetname_SingleExp_fits.csv
+                                       //datasetname_ThreeMixedExp_fits.csv
+                                       //datasetname_TwoMixedExp_fits.csv
+
+                                       //create catchall input file from mothur's inputfile
+                                       string filename = process(sabund);
+       sabund->print(cout);                                                    
+                                       //create system command
+                                       string catchAllCommand = catchAllCommandExe + filename + " " + path;
+cout << catchAllCommand << endl;
+                                       //run catchall
+                                       system(catchAllCommand.c_str());
+                                                                               
+                                       if (m->control_pressed) { delete read;  delete input; globaldata->ginput = NULL; delete sabund;  return 0; }
+
+                                       processedLabels.insert(sabund->getLabel());
+                                       userLabels.erase(sabund->getLabel());
+                       }
+                       
+                       if ((anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       string saveLabel = sabund->getLabel();
+                                       
+                                       delete sabund;          
+                                       sabund = (input->getSAbundVector(lastLabel));
+                                       
+                                       m->mothurOut(sabund->getLabel());  m->mothurOutEndLine();
+                                       
+                                       //create list of output files catchall will make
+                                       //datasetname_Analysis.csv 
+                                       //datasetname_BestModelsAnalysis.csv
+                                       //datasetname_BestModelsFits.csv 
+                                       //datasetname_BubblePlot.csv 
+                                       //datasetname_Poisson_fits.csv 
+                                       //datasetname_SingleExp_fits.csv
+                                       //datasetname_ThreeMixedExp_fits.csv
+                                       //datasetname_TwoMixedExp_fits.csv
+
+                                       
+                                       //create catchall input file from mothur's inputfile
+                                       string filename = process(sabund);
+                       
+                                       //create system command
+                                       string catchAllCommand = catchAllCommandExe + filename + " " + path;
+cout << catchAllCommand << endl;
+                                       //run catchall
+                                       system(catchAllCommand.c_str());
+
+                                       if (m->control_pressed) { delete read;  delete input; globaldata->ginput = NULL; delete sabund;  return 0; }
+
+                                       processedLabels.insert(sabund->getLabel());
+                                       userLabels.erase(sabund->getLabel());
+                                       
+                                       //restore real lastlabel to save below
+                                       sabund->setLabel(saveLabel);
+                       }
+                       
+                       
+                       lastLabel = sabund->getLabel(); 
+                       
+                       delete sabund;          
+                       sabund = (input->getSAbundVector());
+               }
+               
+               //output error messages about any remaining user labels
+               set<string>::iterator it;
+               bool needToRun = false;
+               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
+                       m->mothurOut("Your file does not include the label " + *it); 
+                       if (processedLabels.count(lastLabel) != 1) {
+                               m->mothurOut(". I will use " + lastLabel + ".");  m->mothurOutEndLine();
+                               needToRun = true;
+                       }else {
+                               m->mothurOut(". Please refer to " + lastLabel + ".");  m->mothurOutEndLine();
+                       }
+               }
+               
+               //run last label if you need to
+               if (needToRun == true)  {
+                       if (sabund != NULL) {   delete sabund;  }
+                       sabund = (input->getSAbundVector(lastLabel));
+                       
+                       m->mothurOut(sabund->getLabel());  m->mothurOutEndLine();
+                       //create list of output files catchall will make
+                       //datasetname_Analysis.csv 
+                       //datasetname_BestModelsAnalysis.csv
+                       //datasetname_BestModelsFits.csv 
+                       //datasetname_BubblePlot.csv 
+                       //datasetname_Poisson_fits.csv 
+                       //datasetname_SingleExp_fits.csv
+                       //datasetname_ThreeMixedExp_fits.csv
+                       //datasetname_TwoMixedExp_fits.csv
+
+                       //create catchall input file from mothur's inputfile
+                       string filename = process(sabund);
+
+                       //create system command
+                       string catchAllCommand = catchAllCommandExe + filename + " " + path;
+cout << catchAllCommand << endl;
+                       //run catchall
+                       system(catchAllCommand.c_str());
+       
+                       
+                       delete sabund;
+               }
+
+               delete read;
+               delete input; globaldata->ginput = NULL;
+               
+               m->mothurOutEndLine();
+               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }       
+               m->mothurOutEndLine();
+               
+
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CatchAllCommand", "execute");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+string CatchAllCommand::process(SAbundVector* sabund) {
+       try {
+               string filename = outputDir + getRootName(getSimpleName(sabundfile)) + sabund->getLabel() + ".catchall";
+               filename = getFullPathName(filename);
+       
+               ofstream out;
+               openOutputFile(filename, out);
+               
+               for (int i = 1; i <= sabund->getMaxRank(); i++) {
+                       int temp = sabund->get(i);
+                       
+                       if (temp != 0) {
+                               out << i << "," << temp << endl;
+                       }
+               }
+               out.close();
+               
+               return filename;
+       
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CatchAllCommand", "process");
+               exit(1);
+       }
+}
+/**************************************************************************************/
+
+
+
diff --git a/catchallcommand.h b/catchallcommand.h
new file mode 100644 (file)
index 0000000..ac9f115
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef CATCHALLCOMMAND_H
+#define CATCHALLCOMMAND_H
+
+/*
+ *  catchallcommand.h
+ *  Mothur
+ *
+ *  Created by westcott on 5/11/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "command.hpp"
+#include "inputdata.h"
+#include "readotu.h"
+#include "sabundvector.hpp"
+
+/* 
+ citation goes here
+ */ 
+
+/****************************************************************************/
+
+class CatchAllCommand : public Command {
+
+public:
+
+       CatchAllCommand(string);
+       ~CatchAllCommand() {};
+       int execute();
+       void help();    
+       
+private:
+
+       GlobalData* globaldata;
+       ReadOTUFile* read;
+       InputData* input;
+       
+       string outputDir, sabundfile, rabundfile, listfile, format;
+       bool abort, allLines;
+       set<string> labels;
+       
+       string process(SAbundVector*);
+};
+
+/****************************************************************************/
+
+#endif
+
+
index fc028a2f91fae5f2c50e3ba33fef889806f46a6c..f8d389c60d81654f944e6b892ef7ad19a6d91859 100644 (file)
@@ -139,6 +139,7 @@ void ClearcutCommand::help(){
        try {
                m->mothurOut("The clearcut command interfaces mothur with the clearcut program written by Initiative for Bioinformatics and Evolutionary Studies (IBEST) at the University of Idaho.\n");
                m->mothurOut("For more information about clearcut refer to http://bioinformatics.hungry.com/clearcut/ \n");
+               m->mothurOut("The clearcut executable must be in a folder called clearcut in the same folder as your mothur executable, similar to mothur's requirements for using blast. \n");
                m->mothurOut("The clearcut command parameters are phylip, fasta, version, verbose, quiet, seed, norandom, shuffle, neighbor, expblen, expdist, ntrees, matrixout, stdout, kimura, jukes, protein, DNA, stdin. \n");
                m->mothurOut("The phylip parameter allows you to enter your phylip formatted distance matrix. \n");
                m->mothurOut("The fasta parameter allows you to enter your aligned fasta file, if you enter a fastafile you specify if the sequences are DNA or protein using the DNA or protein parameters. \n");
@@ -233,3 +234,7 @@ int ClearcutCommand::execute() {
        }
 }
 /**************************************************************************************/
+
+
+
+
index 62ed9f24a929bab17a0733c98b5771105a395c3f..379424c9155d7dcee7e0535644652ef852f19481 100644 (file)
@@ -11,7 +11,7 @@
 
 /***********************************************************************/
 
-int Collect::getCurve(int increment = 1){
+int Collect::getCurve(float percentFreq = 0.01){
         try {
                 RAbundVector* lookup = new RAbundVector(order->getNumBins());
                 SAbundVector* rank        = new SAbundVector(order->getMaxRank()+1);
@@ -21,7 +21,11 @@ int Collect::getCurve(int increment = 1){
                 for(int i=0;i<displays.size();i++){
                         ccd->registerDisplay(displays[i]); //adds a display[i] to cdd
                         displays[i]->init(label);                   //sets displays label
-                }                                                                           
+                }   
+                               
+                               //convert freq percentage to number
+                               int increment = numSeqs * percentFreq;
+                                                                                                                                                                                                                                                       
                 for(int i=0;i<numSeqs;i++){
                                                
                                                if (m->control_pressed) { delete lookup; delete rank; delete ccd;  return 1;  }
@@ -62,9 +66,9 @@ int Collect::getCurve(int increment = 1){
 }
 
 /***********************************************************************/
-int Collect::getSharedCurve(int increment = 1){
+int Collect::getSharedCurve(float percentFreq = 0.01){
 try {
-                globaldata = GlobalData::getInstance();
+                               globaldata = GlobalData::getInstance();
                 vector<SharedRAbundVector*> lookup; 
                                vector<SharedRAbundVector*> subset;
 
@@ -96,6 +100,9 @@ try {
                                                else {  displays[i]->init(groupLabel);  }           
                 }
                 
+                               //convert freq percentage to number
+                               int increment = numSeqs * percentFreq;
+                               
                 //sample all the members
                 for(int i=0;i<numSeqs;i++){
                                
index 879755f5744e456e37aefb5f302ec9483a9393e9..79f88fb6dc4ea12a886107743fe7fd8a65a539d5 100644 (file)
--- a/collect.h
+++ b/collect.h
@@ -22,8 +22,8 @@ public:
                                        numSeqs(sharedorder->getNumSeqs()), sharedorder(sharedorder), displays(disp), label(sharedorder->getLabel())  { m = MothurOut::getInstance(); }
 
        ~Collect(){             };
-       int getCurve(int);
-       int getSharedCurve(int);
+       int getCurve(float);
+       int getSharedCurve(float);
        
 private:
        SharedOrderVector* sharedorder;
index cf8ba10e8e43054304c42892cbfb9c2014a8da1f..1e2bf2fcd42e771e2b84e7f2d3f93abd2171a15a 100644 (file)
@@ -86,7 +86,7 @@ CollectCommand::CollectCommand(string option)  {
                        splitAtDash(calc, Estimators);
 
                        string temp;
-                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "100"; }
+                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "0.10"; }
                        convert(temp, freq); 
                        
                        temp = validParameter.validFile(parameters, "abund", false);            if (temp == "not found") { temp = "10"; }
@@ -110,6 +110,7 @@ void CollectCommand::help(){
                m->mothurOut("The collect.single command can be executed after a successful cluster command.  It will use the .list file from the output of the cluster.\n");
                m->mothurOut("The collect.single command parameters are label, freq, calc and abund.  No parameters are required. \n");
                m->mothurOut("The collect.single command should be in the following format: \n");
+               m->mothurOut("The freq parameter is used indicate when to output your data.  It is a percentage of the number of sequences.  By default it is set to 0.10, meaning 10%. \n");
                m->mothurOut("collect.single(label=yourLabel, iters=yourIters, freq=yourFreq, calc=yourEstimators).\n");
                m->mothurOut("Example collect(label=unique-.01-.03, iters=10000, freq=10, calc=sobs-chao-ace-jack).\n");
                m->mothurOut("The default values for freq is 100, and calc are sobs-chao-ace-jack-shannon-npshannon-simpson.\n");
index 0df1bab2315c256d07c98fe38124a213cda88d7e..773bdae5c1d0b71bdad01e4403d3af3702274e70 100644 (file)
@@ -50,7 +50,8 @@ private:
        Collect* cCurve;
        ValidCalculators* validCalculator;
        vector<Display*> cDisplays;
-       int freq, abund, size;
+       int abund, size;
+       float freq;
 
        bool abort, allLines;
        set<string> labels; //holds labels to be used
index 28e58b19f1cf61d83383f3e28905bf3846a2d3ba..78ce5c400221d5620fd85447627dcb7a3b658994 100644 (file)
@@ -104,7 +104,7 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                        globaldata->Groups = Groups;
                        
                        string temp;
-                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "100"; }
+                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "0.10"; }
                        convert(temp, freq); 
                        
                        temp = validParameter.validFile(parameters, "all", false);                              if (temp == "not found") { temp = "false"; }
@@ -208,6 +208,7 @@ void CollectSharedCommand::help(){
                m->mothurOut("Example collect.shared(label=unique-.01-.03, freq=10, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan).\n");
                m->mothurOut("The default values for freq is 100 and calc are sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan.\n");
                m->mothurOut("The default value for groups is all the groups in your groupfile.\n");
+               m->mothurOut("The freq parameter is used indicate when to output your data.  It is a percentage of the number of sequences.  By default it is set to 0.10, meaning 10%. \n");
                validCalculator->printCalc("shared", cout);
                m->mothurOut("The label parameter is used to analyze specific labels in your input.\n");
                m->mothurOut("The all parameter is used to specify if you want the estimate of all your groups together.  This estimate can only be made for sharedsobs and sharedchao calculators. The default is false.\n");
index da43adc791ec9809d6ffe1031a9d65e6d77d8db6..b7a494149249af486c2a8cb812b00316a42b241f 100644 (file)
@@ -42,7 +42,7 @@ private:
        ValidCalculators* validCalculator;
        Collect* cCurve;
        vector<Display*> cDisplays;
-       int freq;
+       float freq;
        string format;
 
        bool abort, allLines, all;
index 9917b3cce2c2b4a48ac89ae4ab8a387921d1d74e..be85727f3cf5e9492041054e1f3296aad9aee660 100644 (file)
@@ -76,6 +76,7 @@
 #include "makegroupcommand.h"
 #include "chopseqscommand.h"
 #include "clearcutcommand.h"
+#include "catchallcommand.h"
 
 /*******************************************************/
 
@@ -159,6 +160,7 @@ CommandFactory::CommandFactory(){
        commands["make.group"]                  = "make.group";
        commands["chop.seqs"]                   = "chop.seqs";
        commands["clearcut"]                    = "clearcut";
+       commands["catchall"]                    = "catchall";
        commands["classify.seqs"]               = "MPIEnabled"; 
        commands["dist.seqs"]                   = "MPIEnabled";
        commands["filter.seqs"]                 = "MPIEnabled";
@@ -279,6 +281,7 @@ Command* CommandFactory::getCommand(string commandName, string optionString){
                else if(commandName == "make.group")                    {       command = new MakeGroupCommand(optionString);                           }
                else if(commandName == "chop.seqs")                             {       command = new ChopSeqsCommand(optionString);                            }
                else if(commandName == "clearcut")                              {       command = new ClearcutCommand(optionString);                            }
+               else if(commandName == "catchall")                              {       command = new CatchAllCommand(optionString);                            }
                else                                                                                    {       command = new NoCommand(optionString);                                          }
 
                return command;
index 7c214754fd27c4fa6a78757fe74be6dc69323a98..de1b77cd47e2134804f1bffc79f4994251f1c863 100644 (file)
--- a/makefile
+++ b/makefile
@@ -148,7 +148,8 @@ mothur : \
                ./helpcommand.o\
                ./makegroupcommand.o\
                ./chopseqscommand.o\
-               ./clearcutcommand.o\\r
+               ./clearcutcommand.o\
+               ./catchallcommand.o\\r
                ./inputdata.o\\r
                ./jackknife.o\\r
                ./kmer.o\\r
@@ -352,7 +353,8 @@ mothur : \
                ./helpcommand.o\
                ./makegroupcommand.o\
                ./chopseqscommand.o\
-               ./clearcutcommand.o\\r
+               ./clearcutcommand.o\
+               ./catchallcommand.o\\r
                ./inputdata.o\\r
                ./jackknife.o\\r
                ./kmer.o\\r
@@ -559,7 +561,8 @@ clean :
                ./helpcommand.o\
                ./makegroupcommand.o\
                ./chopseqscommand.o\
-               ./clearcutcommand.o\\r
+               ./clearcutcommand.o\
+               ./catchallcommand.o\\r
                ./inputdata.o\\r
                ./jackknife.o\\r
                ./kmer.o\\r
@@ -1668,6 +1671,10 @@ install : mothur
 
 # Item # 203 -- clearcutcommand --\r
 ./clearcutcommand.o : clearcutcommand.cpp\r
-       $(CC) $(CC_OPTIONS) clearcutcommand.cpp -c $(INCLUDE) -o ./clearcutcommand.o\r
+       $(CC) $(CC_OPTIONS) clearcutcommand.cpp -c $(INCLUDE) -o ./clearcutcommand.o
+
+# Item # 204 -- catchallcommand --\r
+./catchallcommand.o : catchallcommand.cpp\r
+       $(CC) $(CC_OPTIONS) catchallcommand.cpp -c $(INCLUDE) -o ./catchallcommand.o\r
 \r
 ##### END RUN ####\r
index 978b18874923c2273d71b02ca2fcda3aba2e7151..7e0574e24b5d690bb2ebff9864b7682424faae16 100644 (file)
@@ -41,7 +41,7 @@ PhyloDiversityCommand::PhyloDiversityCommand(string option)  {
                                m->mothurOut("You must execute the read.tree command, before you may execute the phylo.diversity command."); m->mothurOutEndLine(); abort = true;  }
 
                        string temp;
-                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "100"; }
+                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "0.10"; }
                        convert(temp, freq); 
                        
                        temp = validParameter.validFile(parameters, "iters", false);                    if (temp == "not found") { temp = "1000"; }
@@ -69,7 +69,16 @@ PhyloDiversityCommand::PhyloDiversityCommand(string option)  {
 
 void PhyloDiversityCommand::help(){
        try {
-
+               m->mothurOut("The phylo.diversity command can only be executed after a successful read.tree command.\n");
+               m->mothurOut("The phylo.diversity command parameters are groups, iters, freq and rarefy.  No parameters are required.\n");
+               m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. The group names are separated by dashes. By default all groups are used.\n");
+               m->mothurOut("The iters parameter allows you to specify the number of randomizations to preform, by default iters=1000, if you set rarefy to true.\n");
+               m->mothurOut("The freq parameter is used indicate when to output your data.  It is a percentage of the number of sequences.  By default it is set to 0.10, meaning 10%. \n");
+               m->mothurOut("The rarefy parameter allows you to create a rarefaction curve. The default is false.\n");
+               m->mothurOut("The phylo.diversity command should be in the following format: phylo.diversity(groups=yourGroups, rarefy=yourRarefy, iters=yourIters).\n");
+               m->mothurOut("Example phylo.diversity(groups=A-B-C, rarefy=T, iters=500).\n");
+               m->mothurOut("The phylo.diversity command output two files: .phylo.diversity and if rarefy=T, .rarefaction.\n");
+               m->mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
 
        }
        catch(exception& e) {
@@ -122,14 +131,17 @@ int PhyloDiversityCommand::execute(){
                        
                        numLeafNodes = randomLeaf.size();  //reset the number of leaf nodes you are using 
                        
+                       //convert freq percentage to number
+                       int increment = numLeafNodes * freq;
+                       
                        //each group, each sampling, if no rarefy iters = 1;
                        vector< vector<float> > diversity;
                        diversity.resize(globaldata->Groups.size());
                        
                        //initialize sampling spots
                        vector<int> numSampledList;
-                       for(int k = 0; k < numLeafNodes; k++){  if((k == 0) || (k+1) % freq == 0){  numSampledList.push_back(k); }   }
-                       if(numLeafNodes % freq != 0){   numSampledList.push_back(numLeafNodes);   }
+                       for(int k = 0; k < numLeafNodes; k++){  if((k == 0) || (k+1) % increment == 0){  numSampledList.push_back(k); }   }
+                       if(numLeafNodes % increment != 0){      numSampledList.push_back(numLeafNodes);   }
                        
                        //initialize diversity
                        for (int j = 0; j < diversity.size(); j++) {   diversity[j].resize(numSampledList.size(), 0.0);  }  //                  10sampled       20 sampled ...
@@ -147,7 +159,7 @@ int PhyloDiversityCommand::execute(){
                                        
                                        leavesSampled.push_back(randomLeaf[k]);
                                                
-                                       if((k == 0) || (k+1) % freq == 0){ //ready to calc?
+                                       if((k == 0) || (k+1) % increment == 0){ //ready to calc?
                                                
                                                data = phylo.getValues(trees[i], leavesSampled);
                                                
@@ -158,7 +170,7 @@ int PhyloDiversityCommand::execute(){
                                        }
                                }
                
-                               if(numLeafNodes % freq != 0){   
+                               if(numLeafNodes % increment != 0){      
                                        
                                        data = phylo.getValues(trees[i], leavesSampled);
                                        
index bd26173bfd5a2780ca745173dab40b53167b508c..8dd569bbcf567d1990465a2c17bf62ed4ad55831 100644 (file)
@@ -24,8 +24,9 @@ class PhyloDiversityCommand : public Command {
        
        private:
                GlobalData* globaldata;
-       
-               int iters, freq;  
+               
+               float freq;
+               int iters;  
                bool abort, rarefy;
                string groups, outputDir;
                vector<string> Groups, outputNames; //holds groups to be used, and outputFile names
index f5e7952688cdbb1dd182ca44df9c152ef46879d9..76f68296b209ec1eb8e2ff5a14668b32fd451b8b 100644 (file)
 
 /***********************************************************************/
 
-int Rarefact::getCurve(int increment = 1, int nIters = 1000){
+int Rarefact::getCurve(float percentFreq = 0.01, int nIters = 1000){
        try {
                RarefactionCurveData* rcd = new RarefactionCurveData();
                for(int i=0;i<displays.size();i++){
                        rcd->registerDisplay(displays[i]);
                }
-       
+               
+               //convert freq percentage to number
+               int increment = numSeqs * percentFreq;
+               
                for(int iter=0;iter<nIters;iter++){
                
                        for(int i=0;i<displays.size();i++){
@@ -73,7 +76,7 @@ int Rarefact::getCurve(int increment = 1, int nIters = 1000){
 
 /***********************************************************************/
 
-int Rarefact::getSharedCurve(int increment = 1, int nIters = 1000){
+int Rarefact::getSharedCurve(float percentFreq = 0.01, int nIters = 1000){
 try {
                SharedRarefactionCurveData* rcd = new SharedRarefactionCurveData();
                
@@ -87,6 +90,9 @@ try {
                //if jumble is false all iters will be the same
                if (globaldata->jumble == false)  {  nIters = 1;  }
                
+               //convert freq percentage to number
+               int increment = numSeqs * percentFreq;
+               
                for(int iter=0;iter<nIters;iter++){
                
                        for(int i=0;i<displays.size();i++){
index 9eab51d12303577405227e9c26cdcf9506e8a857..20c19251b132dd8ba512ab1530206546eb0bbbec 100644 (file)
@@ -17,8 +17,8 @@ public:
                                         lookup(shared), displays(disp) {  globaldata = GlobalData::getInstance(); m = MothurOut::getInstance(); }
 
        ~Rarefact(){};
-       int getCurve(int, int);
-       int getSharedCurve(int, int);
+       int getCurve(float, int);
+       int getSharedCurve(float, int);
        
 private:
        GlobalData* globaldata;
index 566561e9e695c3f74f7ffb1ce0b1d56ee0e3bc20..f62cea1e5253ce0d1a970491d8eb25b0a73e6bb1 100644 (file)
@@ -80,7 +80,7 @@ RareFactCommand::RareFactCommand(string option)  {
                        splitAtDash(calc, Estimators);
 
                        string temp;
-                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "100"; }
+                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "0.10"; }
                        convert(temp, freq); 
                        
                        temp = validParameter.validFile(parameters, "abund", false);                    if (temp == "not found") { temp = "10"; }
@@ -103,6 +103,7 @@ void RareFactCommand::help(){
                m->mothurOut("The rarefaction.single command can only be executed after a successful read.otu WTIH ONE EXECEPTION.\n");
                m->mothurOut("The rarefaction.single command can be executed after a successful cluster command.  It will use the .list file from the output of the cluster.\n");
                m->mothurOut("The rarefaction.single command parameters are label, iters, freq, calc and abund.  No parameters are required. \n");
+               m->mothurOut("The freq parameter is used indicate when to output your data.  It is a percentage of the number of sequences.  By default it is set to 0.10, meaning 10%. \n");
                m->mothurOut("The rarefaction.single command should be in the following format: \n");
                m->mothurOut("rarefaction.single(label=yourLabel, iters=yourIters, freq=yourFreq, calc=yourEstimators).\n");
                m->mothurOut("Example rarefaction.single(label=unique-.01-.03, iters=10000, freq=10, calc=sobs-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson).\n");
index dce1a0d4862190c01bb2082f8506d3a505bad899..f4492a2ec15e97a9cf52295202306689e2820961 100644 (file)
@@ -36,8 +36,9 @@ private:
        InputData* input;
        ValidCalculators* validCalculator;
        Rarefact* rCurve;
-       int freq, nIters, abund;
-
+       int nIters, abund;
+       float freq;
+       
        bool abort, allLines;
        set<string> labels; //holds labels to be used
        string label, calc;
index 37b54d1b850dbd9e72ca56fe4e506fa9a78439b4..357bc8708289e37063d731315b7411c715a05f1a 100644 (file)
@@ -28,7 +28,7 @@ RareFactSharedCommand::RareFactSharedCommand(string option)  {
                
                else {
                        //valid paramters for this command
-                       string Array[] =  {"iters","label","calc","groups", "jumble","outputdir","inputdir"};
+                       string Array[] =  {"iters","freq","label","calc","groups", "jumble","outputdir","inputdir"};
                        vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
                        
                        OptionParser parser(option);
@@ -84,6 +84,9 @@ RareFactSharedCommand::RareFactSharedCommand(string option)  {
                        globaldata->Groups = Groups;
                        
                        string temp;
+                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "0.10"; }
+                       convert(temp, freq); 
+                       
                        temp = validParameter.validFile(parameters, "iters", false);                    if (temp == "not found") { temp = "1000"; }
                        convert(temp, nIters); 
                        
@@ -130,6 +133,7 @@ void RareFactSharedCommand::help(){
                m->mothurOut("The rarefaction.shared command parameters are label, iters, groups, jumble and calc.  No parameters are required.\n");
                m->mothurOut("The rarefaction command should be in the following format: \n");
                m->mothurOut("rarefaction.shared(label=yourLabel, iters=yourIters, calc=yourEstimators, jumble=yourJumble, groups=yourGroups).\n");
+               m->mothurOut("The freq parameter is used indicate when to output your data.  It is a percentage of the number of sequences.  By default it is set to 0.10, meaning 10%. \n");
                m->mothurOut("Example rarefaction.shared(label=unique-0.01-0.03,  iters=10000, groups=B-C, jumble=T, calc=sharedobserved).\n");
                m->mothurOut("The default values for iters is 1000, freq is 100, and calc is sharedobserved which calculates the shared rarefaction curve for the observed richness.\n");
                m->mothurOut("The default value for groups is all the groups in your groupfile, and jumble is true.\n");
index da26d174ca3c3cc9da41027f5252aa8f58288f20..1bcddb5257f56967a63b66f0740e648811509204 100644 (file)
@@ -34,9 +34,10 @@ private:
        ValidCalculators* validCalculator;
        Rarefact* rCurve;
        vector<Display*> rDisplays;
-       int freq, nIters;
+       int nIters;
        string format;
-
+       float freq;
+       
        bool abort, allLines, jumble;
        set<string> labels; //holds labels to be used
        string label, calc, groups, outputDir;