]> git.donarmstrong.com Git - mothur.git/commitdiff
added read.shared, broke up globaldata a bit
authorwestcott <westcott>
Fri, 13 Feb 2009 16:49:49 +0000 (16:49 +0000)
committerwestcott <westcott>
Fri, 13 Feb 2009 16:49:49 +0000 (16:49 +0000)
41 files changed:
Mothur.xcodeproj/project.pbxproj
averagelinkage.cpp
collectcommand.cpp
collectcommand.h
collectsharedcommand.cpp
collectsharedcommand.h
commandfactory.cpp
errorchecking.cpp
errorchecking.h
globaldata.cpp
globaldata.hpp
groupmap.cpp
groupmap.h
helpcommand.cpp
helpcommand.h
inputdata.cpp
inputdata.h
rarefactcommand.cpp
rarefactcommand.h
rarefactsharedcommand.cpp
rarefactsharedcommand.h
readmatrix.cpp
readsharedcommand.cpp [new file with mode: 0644]
readsharedcommand.h [new file with mode: 0644]
sharedlistvector.cpp
sharedordervector.cpp
sharedordervector.h
sharedrabundvector.cpp
sharedsobscollectsummary.h
summarycommand.cpp
summarycommand.h
summarysharedcommand.cpp
summarysharedcommand.h
tree.h
utilities.hpp
validcalculator.cpp
validcalculator.h
validcommands.cpp
validcommands.h
validparameter.cpp
validparameter.h

index d678294bcf11674e75ccdc40dd068df8300c7750..c3c2a7209784cb71d7e2a873046bf8b567f94b57 100644 (file)
@@ -21,6 +21,7 @@
                37AD4DBB0F28E2FE00AA2D49 /* tree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AD4DBA0F28E2FE00AA2D49 /* tree.cpp */; };
                37AD4DCA0F28F3DD00AA2D49 /* readtree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AD4DC90F28F3DD00AA2D49 /* readtree.cpp */; };
                37AFC71F0F445386005F492D /* sharedsobscollectsummary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AFC71E0F445386005F492D /* sharedsobscollectsummary.cpp */; };
+               37AFC7A30F44703E005F492D /* readsharedcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AFC7A20F44703E005F492D /* readsharedcommand.cpp */; };
                37B28F680F27590100808A62 /* deconvolutecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37B28F670F27590100808A62 /* deconvolutecommand.cpp */; };
                37D928550F21331F001D4494 /* ace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927B80F21331F001D4494 /* ace.cpp */; };
                37D928560F21331F001D4494 /* averagelinkage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927BA0F21331F001D4494 /* averagelinkage.cpp */; };
                37AD4DC90F28F3DD00AA2D49 /* readtree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readtree.cpp; sourceTree = "<group>"; };
                37AFC71D0F445386005F492D /* sharedsobscollectsummary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedsobscollectsummary.h; sourceTree = "<group>"; };
                37AFC71E0F445386005F492D /* sharedsobscollectsummary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedsobscollectsummary.cpp; sourceTree = "<group>"; };
+               37AFC7A10F44703E005F492D /* readsharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readsharedcommand.h; sourceTree = "<group>"; };
+               37AFC7A20F44703E005F492D /* readsharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readsharedcommand.cpp; sourceTree = "<group>"; };
                37B28F660F27590100808A62 /* deconvolutecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = deconvolutecommand.h; sourceTree = "<group>"; };
                37B28F670F27590100808A62 /* deconvolutecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = deconvolutecommand.cpp; sourceTree = "<group>"; };
                37D927B80F21331F001D4494 /* ace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ace.cpp; sourceTree = "<group>"; };
                                372E12950F263D5A0095CF7E /* readdistcommand.cpp */,
                                372E126E0F26365B0095CF7E /* readotucommand.h */,
                                372E126F0F26365B0095CF7E /* readotucommand.cpp */,
+                               37AFC7A10F44703E005F492D /* readsharedcommand.h */,
+                               37AFC7A20F44703E005F492D /* readsharedcommand.cpp */,
                                37E5F4900F2A3DA800F8D827 /* readtreecommand.h */,
                                37E5F4910F2A3DA800F8D827 /* readtreecommand.cpp */,
                                37D928270F21331F001D4494 /* sharedcommand.h */,
                                374610830F40652400460C57 /* unweighted.cpp in Sources */,
                                3746109D0F40657600460C57 /* unifracunweightedcommand.cpp in Sources */,
                                37AFC71F0F445386005F492D /* sharedsobscollectsummary.cpp in Sources */,
+                               37AFC7A30F44703E005F492D /* readsharedcommand.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 1ab5160f07720f2330c7a627654e8ed264098e54..43b3e5b535675d433e88cc5d3b9d10f038be7256 100644 (file)
@@ -1,3 +1,5 @@
+#ifndef AVERAGE_H
+#define AVERAGE_H
 
 #include "cluster.hpp"
 #include "rabundvector.hpp"
@@ -76,3 +78,7 @@ void AverageLinkage::update(){
 }
 
 /***********************************************************************/
+
+#endif
+
+
index 4687c6e8dcb35fa3b19296f2fe5cc0d39745d582..0f622c49b2a30632f53e4fa3ec0dfc3196113374 100644 (file)
@@ -27,25 +27,32 @@ CollectCommand::CollectCommand(){
                string fileNameRoot;
                fileNameRoot = getRootName(globaldata->inputFileName);
                int i;
-               for (i=0; i<globaldata->singleEstimators.size(); i++) {
-                       if (globaldata->singleEstimators[i] == "sobs") { 
-                               cDisplays.push_back(new CollectDisplay(new Sobs(), new OneColumnFile(fileNameRoot+"sobs")));
-                       }else if (globaldata->singleEstimators[i] == "chao") { 
-                               cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao")));
-                       }else if (globaldata->singleEstimators[i] == "ace") { 
-                               cDisplays.push_back(new CollectDisplay(new Ace(), new ThreeColumnFile(fileNameRoot+"ace")));
-                       }else if (globaldata->singleEstimators[i] == "jack") { 
-                               cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack")));
-                       }else if (globaldata->singleEstimators[i] == "shannon") { 
-                               cDisplays.push_back(new CollectDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"shannon")));
-                       }else if (globaldata->singleEstimators[i] == "npshannon") { 
-                               cDisplays.push_back(new CollectDisplay(new NPShannon(), new OneColumnFile(fileNameRoot+"np_shannon")));
-                       }else if (globaldata->singleEstimators[i] == "simpson") { 
-                               cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"simpson")));
-                       }else if (globaldata->singleEstimators[i] == "bootstrap") { 
-                               cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(fileNameRoot+"bootstrap")));
+               validCalculator = new ValidCalculators();
+               
+               for (i=0; i<globaldata->Estimators.size(); i++) {
+                       if (validCalculator->isValidCalculator("single", globaldata->Estimators[i]) == true) { 
+                               if (globaldata->Estimators[i] == "sobs") { 
+                                       cDisplays.push_back(new CollectDisplay(new Sobs(), new OneColumnFile(fileNameRoot+"sobs")));
+                               }else if (globaldata->Estimators[i] == "chao") { 
+                                       cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao")));
+                               }else if (globaldata->Estimators[i] == "ace") { 
+                                       cDisplays.push_back(new CollectDisplay(new Ace(), new ThreeColumnFile(fileNameRoot+"ace")));
+                               }else if (globaldata->Estimators[i] == "jack") { 
+                                       cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack")));
+                               }else if (globaldata->Estimators[i] == "shannon") { 
+                                       cDisplays.push_back(new CollectDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"shannon")));
+                               }else if (globaldata->Estimators[i] == "npshannon") { 
+                                       cDisplays.push_back(new CollectDisplay(new NPShannon(), new OneColumnFile(fileNameRoot+"np_shannon")));
+                               }else if (globaldata->Estimators[i] == "simpson") { 
+                                       cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"simpson")));
+                               }else if (globaldata->Estimators[i] == "bootstrap") { 
+                                       cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(fileNameRoot+"bootstrap")));
+                               }
                        }
                }
+               
+               //reset calc for next command
+               globaldata->setCalc("");
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the CollectCommand class Function CollectCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -72,6 +79,10 @@ CollectCommand::~CollectCommand(){
 int CollectCommand::execute(){
        try {
                int count = 1;
+               
+               //if the users entered no valid calculators don't execute command
+               if (cDisplays.size() == 0) { return 0; }
+
                read = new ReadPhilFile(globaldata->inputFileName);     
                read->read(&*globaldata); 
                
index b92b35034466d1dd61f29a04d478d620c8bc4ef2..686c4910c7f6e50fc572be4a4408d08d838b5933 100644 (file)
@@ -19,6 +19,7 @@
 #include "collect.h"
 #include "display.h"
 #include "readmatrix.hpp"
+#include "validcalculator.h"
 
 /*The collect() command:
        The collect command generates a collector's curve from the given file.  
@@ -49,6 +50,7 @@ private:
        OrderVector* order;
        InputData* input;
        Collect* cCurve;
+       ValidCalculators* validCalculator;
        vector<Display*> cDisplays;
        int freq;
 
index a6479da20d4e5b52a09cdb06d76676f26ed583e4..217045a4a1fc5dc0c83986f3b3a0345b755e1f6c 100644 (file)
@@ -28,34 +28,41 @@ CollectSharedCommand::CollectSharedCommand(){
                globaldata = GlobalData::getInstance();
                string fileNameRoot;
                fileNameRoot = getRootName(globaldata->inputFileName);
-               //groupmap = globaldata->gGroupmap;
+               format = globaldata->getFormat();
+               validCalculator = new ValidCalculators();
                
                int i;
-               for (i=0; i<globaldata->sharedEstimators.size(); i++) {
-                       if (globaldata->sharedEstimators[i] == "sharedChao") { 
-                               cDisplays.push_back(new CollectDisplay(new SharedChao1(), new SharedOneColumnFile(fileNameRoot+"shared.chao")));
-                       }else if (globaldata->sharedEstimators[i] == "sharedSobs") { 
-                               cDisplays.push_back(new CollectDisplay(new SharedSobsCS(), new SharedOneColumnFile(fileNameRoot+"shared.sobs")));
-                       }else if (globaldata->sharedEstimators[i] == "sharedAce") { 
-                               cDisplays.push_back(new CollectDisplay(new SharedAce(), new SharedOneColumnFile(fileNameRoot+"shared.ace")));
-                       }else if (globaldata->sharedEstimators[i] == "sharedJabund") {  
-                               cDisplays.push_back(new CollectDisplay(new SharedJAbund(), new SharedOneColumnFile(fileNameRoot+"shared.jabund")));
-                       }else if (globaldata->sharedEstimators[i] == "sharedSorensonAbund") { 
-                               cDisplays.push_back(new CollectDisplay(new SharedSorAbund(), new SharedOneColumnFile(fileNameRoot+"shared.sorabund")));
-                       }else if (globaldata->sharedEstimators[i] == "sharedJclass") { 
-                               cDisplays.push_back(new CollectDisplay(new SharedJclass(), new SharedOneColumnFile(fileNameRoot+"shared.jclass")));
-                       }else if (globaldata->sharedEstimators[i] == "sharedSorClass") { 
-                               cDisplays.push_back(new CollectDisplay(new SharedSorClass(), new SharedOneColumnFile(fileNameRoot+"shared.sorclass")));
-                       }else if (globaldata->sharedEstimators[i] == "sharedJest") { 
-                               cDisplays.push_back(new CollectDisplay(new SharedJest(), new SharedOneColumnFile(fileNameRoot+"shared.jest")));
-                       }else if (globaldata->sharedEstimators[i] == "sharedSorEst") { 
-                               cDisplays.push_back(new CollectDisplay(new SharedSorEst(), new SharedOneColumnFile(fileNameRoot+"shared.sorest")));
-                       }else if (globaldata->sharedEstimators[i] == "SharedThetaYC") { 
-                               cDisplays.push_back(new CollectDisplay(new SharedThetaYC(), new SharedOneColumnFile(fileNameRoot+"shared.thetayc")));
-                       }else if (globaldata->sharedEstimators[i] == "SharedThetaN") { 
-                               cDisplays.push_back(new CollectDisplay(new SharedThetaN(), new SharedOneColumnFile(fileNameRoot+"shared.thetan")));
+               for (i=0; i<globaldata->Estimators.size(); i++) {
+                       if (validCalculator->isValidCalculator("shared", globaldata->Estimators[i]) == true) { 
+                               if (globaldata->Estimators[i] == "sharedchao") { 
+                                       cDisplays.push_back(new CollectDisplay(new SharedChao1(), new SharedOneColumnFile(fileNameRoot+"shared.chao")));
+                               }else if (globaldata->Estimators[i] == "sharedsobs") { 
+                                       cDisplays.push_back(new CollectDisplay(new SharedSobsCS(), new SharedOneColumnFile(fileNameRoot+"shared.sobs")));
+                               }else if (globaldata->Estimators[i] == "sharedace") { 
+                                       cDisplays.push_back(new CollectDisplay(new SharedAce(), new SharedOneColumnFile(fileNameRoot+"shared.ace")));
+                               }else if (globaldata->Estimators[i] == "sharedjabund") {        
+                                       cDisplays.push_back(new CollectDisplay(new SharedJAbund(), new SharedOneColumnFile(fileNameRoot+"shared.jabund")));
+                               }else if (globaldata->Estimators[i] == "sharedsorensonabund") { 
+                                       cDisplays.push_back(new CollectDisplay(new SharedSorAbund(), new SharedOneColumnFile(fileNameRoot+"shared.sorabund")));
+                               }else if (globaldata->Estimators[i] == "sharedjclass") { 
+                                       cDisplays.push_back(new CollectDisplay(new SharedJclass(), new SharedOneColumnFile(fileNameRoot+"shared.jclass")));
+                               }else if (globaldata->Estimators[i] == "sharedsorclass") { 
+                                       cDisplays.push_back(new CollectDisplay(new SharedSorClass(), new SharedOneColumnFile(fileNameRoot+"shared.sorclass")));
+                               }else if (globaldata->Estimators[i] == "sharedjest") { 
+                                       cDisplays.push_back(new CollectDisplay(new SharedJest(), new SharedOneColumnFile(fileNameRoot+"shared.jest")));
+                               }else if (globaldata->Estimators[i] == "sharedsorest") { 
+                                       cDisplays.push_back(new CollectDisplay(new SharedSorEst(), new SharedOneColumnFile(fileNameRoot+"shared.sorest")));
+                               }else if (globaldata->Estimators[i] == "sharedthetayc") { 
+                                       cDisplays.push_back(new CollectDisplay(new SharedThetaYC(), new SharedOneColumnFile(fileNameRoot+"shared.thetayc")));
+                               }else if (globaldata->Estimators[i] == "sharedthetan") { 
+                                       cDisplays.push_back(new CollectDisplay(new SharedThetaN(), new SharedOneColumnFile(fileNameRoot+"shared.thetan")));
+                               }
                        }
                }
+               
+               //reset calc for next command
+               globaldata->setCalc("");
+
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the CollectSharedCommand class Function CollectSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -82,12 +89,25 @@ CollectSharedCommand::~CollectSharedCommand(){
 int CollectSharedCommand::execute(){
        try {
                int count = 1;
-               read = new ReadPhilFile(globaldata->inputFileName);     
-               read->read(&*globaldata); 
                
-               input = globaldata->ginput;
-               SharedList = globaldata->gSharedList;
-               order = SharedList->getSharedOrderVector();
+               //if the users entered no valid calculators don't execute command
+               if (cDisplays.size() == 0) { return 0; }
+               
+               if (format == "sharedfile") {
+                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read->read(&*globaldata); 
+                       
+                       input = globaldata->ginput;
+                       order = input->getSharedOrderVector();
+               }else {
+                       //you are using a list and a groupfile
+                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read->read(&*globaldata); 
+               
+                       input = globaldata->ginput;
+                       SharedList = globaldata->gSharedList;
+                       order = SharedList->getSharedOrderVector();
+               }
                
                while(order != NULL){
                
@@ -102,14 +122,20 @@ int CollectSharedCommand::execute(){
                                cout << order->getLabel() << '\t' << count << endl;
                        }
                        
-                       SharedList = input->getSharedListVector(); //get new list vector to process
-                       if (SharedList != NULL) {
-                               order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
-                               count++;
+                       //get next line to process
+                       if (format == "sharedfile") {
+                               order = input->getSharedOrderVector();
                        }else {
-                               break;
+                               //you are using a list and a groupfile
+                               SharedList = input->getSharedListVector(); //get new list vector to process
+                               if (SharedList != NULL) {
+                                       order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
+                               }else {
+                                       break;
+                               }
                        }
-               
+                       
+                       count++;
                }
        
                for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }       
index 6a8f96f1c9115548cc6dca8f7ff13835468ec441..ffc4278f3b690a4b2f4a0f5bf637146bee65ca3b 100644 (file)
@@ -20,6 +20,7 @@
 #include "collect.h"
 #include "display.h"
 #include "readmatrix.hpp"
+#include "validcalculator.h"
 
 /* The collect.shared() command:
        The collect command generates a collector's curve from the given file representing several groups.  
@@ -50,9 +51,11 @@ private:
        ReadMatrix* read;
        SharedOrderVector* order;
        InputData* input;
+       ValidCalculators* validCalculator;
        Collect* cCurve;
        vector<Display*> cDisplays;
        int freq;
+       string format;
 
 };
 
index dbcfb54be8c09fbf6177ad2d4ed10be8773d0358..0c1b3e075ee8ade15e0ea619463df962e9eac846 100644 (file)
@@ -10,6 +10,7 @@
 #include "command.hpp"
 #include "readdistcommand.h"
 #include "readtreecommand.h"
+#include "readsharedcommand.h"
 #include "readotucommand.h"
 #include "clustercommand.h"
 #include "parselistcommand.h"
@@ -55,6 +56,7 @@ Command* CommandFactory::getCommand(string commandName){
                         if(commandName == "read.dist")                         {       command = new ReadDistCommand();                        }
                else if(commandName == "read.otu")                              {       command = new ReadOtuCommand();                         }
                else if(commandName == "read.tree")                             {       command = new ReadTreeCommand();                        }
+               else if(commandName == "read.shared")                   {       command = new ReadSharedCommand();                      }
                else if(commandName == "cluster")                               {       command = new ClusterCommand();                         }
                else if(commandName == "deconvolute")                   {       command = new DeconvoluteCommand();                     }
                else if(commandName == "parsimony")                             {       command = new ParsimonyCommand();                       }
index 067d246d4c50f1427840c3879be04bac2ff7cdf8..8556c27266ab0c2fa56bd4c9ddeb644e1d81e0b8 100644 (file)
@@ -17,7 +17,6 @@ ErrorCheck::ErrorCheck() {
        globaldata = GlobalData::getInstance();
        validCommand = new ValidCommands();
        validParameter = new ValidParameters();
-       validCalculator = new ValidCalculators();
 }
 /*******************************************************/
 
@@ -38,6 +37,7 @@ void ErrorCheck::refresh() {
        format = globaldata->getFormat();
        method = globaldata->getMethod();
        randomtree = globaldata->getRandomTree();
+       sharedfile = globaldata->getSharedFile();
 }
 
 /*******************************************************/
@@ -76,8 +76,8 @@ bool ErrorCheck::checkInput(string input) {
                //reads in parameters and values
                if((optionText != "") && (commandName != "help")){
                        while((optionText.find_first_of(',') != -1) && (errorFree)) {  //while there are parameters
-                               globaldata->splitAtComma(value, optionText);
-                               globaldata->splitAtEquals(parameter, value);
+                               splitAtComma(value, optionText);
+                               splitAtEquals(parameter, value);
                                
                                //is it a valid parameter
                                if (validParameter->isValidParameter(parameter) != true) { return false; }
@@ -92,6 +92,7 @@ bool ErrorCheck::checkInput(string input) {
                                if (parameter == "fasta" )              { fastafile = value; }
                                if (parameter == "tree" )               { treefile = value; }
                                if (parameter == "group" )              { groupfile = value; }
+                               if (parameter == "shared" )             { sharedfile = value; }
                                if (parameter == "cutoff" )                     { cutoff = value; }
                                if (parameter == "precision" )          { precision = value; }
                                if (parameter == "iters" )                      { iters = value; }
@@ -103,52 +104,12 @@ bool ErrorCheck::checkInput(string input) {
                                if (parameter == "label" )                      { label = value; }
                                if (parameter == "randomtree" )         { randomtree = value;   }
 
-                               if (parameter == "single") {//stores estimators in a vector
-                                       singleEsimators.clear(); //clears out old values
-                                       globaldata->splitAtDash(value, singleEsimators);
-                                       for (int i = 0; i < singleEsimators.size(); i++) { //loop through estimators
-                                               //is it a valid calculator
-                                               if (validCalculator->isValidCalculator(parameter, singleEsimators[i]) != true) { return false; }
-                                       }
-                               }
-                               if (parameter == "rarefaction") {//stores estimators in a vector
-                                       rareEstimators.clear(); //clears out old values
-                                       globaldata->splitAtDash(value, rareEstimators);
-                                       for (int i = 0; i < rareEstimators.size(); i++) { //loop through estimators
-                                               //is it a valid calculator
-                                               if (validCalculator->isValidCalculator(parameter, rareEstimators[i]) != true) { return false; }
-                                       }
-                               }
-                               if (parameter == "shared") {//stores estimators in a vector
-                                       sharedEstimators.clear(); //clears out old values
-                                       globaldata->splitAtDash(value, sharedEstimators);
-                                       for (int i = 0; i < sharedEstimators.size(); i++) { //loop through estimators
-                                               //is it a valid calculator
-                                               if (validCalculator->isValidCalculator(parameter, sharedEstimators[i]) != true) { return false; }
-                                       }
-                               }
-                               if (parameter == "summary") { //stores summaries to be used in a vector
-                                       summaryEstimators.clear(); //clears out old values
-                                       globaldata->splitAtDash(value, summaryEstimators);
-                                       for (int i = 0; i < summaryEstimators.size(); i++) { //loop through estimators
-                                               //is it a valid calculator
-                                               if (validCalculator->isValidCalculator(parameter, summaryEstimators[i]) != true) { return false; }
-                                       }
-                               }
-                               if (parameter == "sharedrarefaction") { //stores summaries to be used in a vector
-                                       sharedRareEstimators.clear(); //clears out old values
-                                       globaldata->splitAtDash(value, sharedRareEstimators);
-                                       for (int i = 0; i < sharedRareEstimators.size(); i++) { //loop through estimators
-                                               //is it a valid calculator
-                                               if (validCalculator->isValidCalculator(parameter, sharedRareEstimators[i]) != true) { return false; }
-                                       }
-                               }
                        }
                        
                        //gets the last parameter and value
                        if (errorFree)  { //gets the last parameter and value
                                value = optionText;
-                               globaldata->splitAtEquals(parameter, value);
+                               splitAtEquals(parameter, value);
                                //is it a valid parameter
                                if (validParameter->isValidParameter(parameter) != true) { return false; }
                                
@@ -160,6 +121,7 @@ bool ErrorCheck::checkInput(string input) {
                                if (parameter == "name" )               { namefile = value; }
                                if (parameter == "order" )              { orderfile = value; }
                                if (parameter == "group" )              { groupfile = value; }
+                               if (parameter == "shared" )             { sharedfile = value; }
                                if (parameter == "fasta" )              { fastafile = value; }
                                if (parameter == "tree" )               { treefile = value; }
                                if (parameter == "cutoff" )                     { cutoff = value; }
@@ -173,47 +135,6 @@ bool ErrorCheck::checkInput(string input) {
                                if (parameter == "label" )                      { label = value; }
                                if (parameter == "randomtree" )         { randomtree = value;   }
 
-                               if (parameter == "single") {//stores estimators in a vector
-                                       singleEsimators.clear(); //clears out old values
-                                       globaldata->splitAtDash(value, singleEsimators);
-                                       for (int i = 0; i < singleEsimators.size(); i++) { //loop through estimators
-                                               //is it a valid calculator
-                                               if (validCalculator->isValidCalculator(parameter, singleEsimators[i]) != true) { return false; }
-                                       }
-                               }
-                               if (parameter == "rarefaction") {//stores estimators in a vector
-                                       rareEstimators.clear(); //clears out old values
-                                       globaldata->splitAtDash(value, rareEstimators);
-                                       for (int i = 0; i < rareEstimators.size(); i++) { //loop through estimators
-                                               //is it a valid calculator
-                                               if (validCalculator->isValidCalculator(parameter, rareEstimators[i]) != true) { return false; }
-                                       }
-                               }
-                               if (parameter == "shared") {//stores estimators in a vector
-                                       sharedEstimators.clear(); //clears out old values
-                                       globaldata->splitAtDash(value, sharedEstimators);
-                                       for (int i = 0; i < sharedEstimators.size(); i++) { //loop through estimators
-                                               //is it a valid calculator
-                                               if (validCalculator->isValidCalculator(parameter, sharedEstimators[i]) != true) { return false; }
-                                       }
-                               }
-                               if (parameter == "summary") { //stores summaries to be used in a vector
-                                       summaryEstimators.clear(); //clears out old values
-                                       globaldata->splitAtDash(value, summaryEstimators);
-                                       for (int i = 0; i < summaryEstimators.size(); i++) { //loop through estimators
-                                               //is it a valid calculator
-                                               if (validCalculator->isValidCalculator(parameter, summaryEstimators[i]) != true) { return false; }
-                                       }
-                               }
-                               if (parameter == "sharedrarefaction") { //stores summaries to be used in a vector
-                                       sharedRareEstimators.clear(); //clears out old values
-                                       globaldata->splitAtDash(value, sharedRareEstimators);
-                                       for (int i = 0; i < sharedRareEstimators.size(); i++) { //loop through estimators
-                                               //is it a valid calculator
-                                               if (validCalculator->isValidCalculator(parameter, sharedRareEstimators[i]) != true) { return false; }
-                                       }
-                               }
-
                        }
                }
                
@@ -232,6 +153,9 @@ bool ErrorCheck::checkInput(string input) {
                                validateReadFiles();
                                validateReadPhil();
                        }
+               }else if (commandName == "read.shared") { 
+                       //you want to do shared commands with just the shared file
+                       validateReadFiles();
                }else if (commandName == "read.tree") { 
                        validateTreeFiles(); //checks the treefile and groupfile parameters
                }else if (commandName == "deconvolute") {
@@ -270,11 +194,12 @@ bool ErrorCheck::checkInput(string input) {
                }
                
                if ((commandName == "collect.shared") || (commandName == "rarefaction.shared") || (commandName == "summary.shared") ){ 
-                       if (globaldata->getListFile() == "") { cout << "You must read a list and a group before you can use the collect.shared, rarefaction.shared or summary.shared commands." << endl; return false; }
-                       else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group before you can use the collect.shared, rarefaction.shared or summary.shared commands." << endl; return false; }
+                       if (globaldata->getSharedFile() == "") {
+                               if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared or summary.shared commands." << endl; return false; }
+                               else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared or summary.shared commands." << endl; return false; }
+                       }
                }
  
-               
                return errorFree;
 }
 
@@ -330,6 +255,12 @@ void ErrorCheck::validateReadFiles() {
                        //unable to open
                        if (ableToOpen == 1) {  errorFree = false; }
                        else { globaldata->inputFileName = fastafile; }
+               }else if (sharedfile != "") {
+                       ableToOpen = openInputFile(sharedfile, filehandle);
+                       filehandle.close();
+                       //unable to open
+                       if (ableToOpen == 1) {  errorFree = false; }
+                       else { globaldata->inputFileName = sharedfile; }
                }else{ //no file given
                        errorFree = false;
                }
@@ -515,6 +446,7 @@ void ErrorCheck::clear() {
        namefile                =       "";
        groupfile               =       ""; 
        orderfile               =       "";
+       sharedfile              =       "";
        line                    =       "";
        label                   =       "";
        method                  =   "furthest";
index 9387bc5954124d00612b5874bb7f084a90ca329d..1b023e079cf8ab15c8539596dc72841be7edf7a3 100644 (file)
@@ -14,7 +14,7 @@
 #include "globaldata.hpp"
 #include "validcommands.h"
 #include "validparameter.h"
-#include "validcalculator.h"
+#include "utilities.hpp"
 
 class ErrorCheck {
        public:
@@ -26,10 +26,6 @@ class ErrorCheck {
                GlobalData* globaldata;
                ValidCommands* validCommand;
                ValidParameters* validParameter;
-               ValidCalculators* validCalculator;
-               void splitAtDash(string&, vector<string>&);
-               void splitAtDash(string&, set<int>&);
-               void splitAtDash(string&, set<string>&);
                void validateReadFiles();
                void validateReadDist();
                void validateReadPhil();
@@ -37,11 +33,10 @@ class ErrorCheck {
                void validateTreeFiles();
                void clear();
                void refresh();
-               string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, treefile, cutoff, format; 
+               string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, treefile, sharedfile, cutoff, format; 
                string precision, method, fileroot, label, line, iters, jumble, freq, single, rarefaction, shared, summary, randomtree;
                string commandName, optionText;
                bool errorFree;
-               vector<string> singleEsimators, sharedEstimators, rareEstimators, summaryEstimators, sharedRareEstimators;
                
 };
 #endif
index e58d19181d156e00dff0190388552858a32dbbde..0348ae6bca626342104591d945ff8acd951d835b 100644 (file)
@@ -1,20 +1,9 @@
-#include <iostream>
-#include <iomanip>
-#include <string>
-#include <map>
-#include <sstream>
-#include <stdexcept>
-
-using namespace std;
-
 #include "globaldata.hpp"
 #include "sparsematrix.hpp"
 #include "tree.h"
 #include "rabundvector.hpp"
 #include "sabundvector.hpp"
 #include "listvector.hpp"
-#include <exception>
-#include <iostream>
 
 /*******************************************************/
 
@@ -47,7 +36,6 @@ void GlobalData::setListVector(ListVector* lv){
                exit(1);
        }
 }
-
 /*******************************************************/
 
 /******************************************************/
@@ -69,7 +57,6 @@ void GlobalData::setSparseMatrix(SparseMatrix* sm){
                cout << "An unknown error has occurred in the GlobalData class function setSparseMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
                exit(1);
        }
-
 }
 /*******************************************************/
 
@@ -80,9 +67,13 @@ void GlobalData::parseGlobalData(string commandString, string optionText){
                allLines = 1;
                commandName = commandString; //save command name to be used by other classes
                
+               //set all non filename paramters to default values
+               reset();
+               
                //clears out data from previous read
-               if ((commandName == "read.dist") || (commandName == "read.otu") || (commandName == "read.tree")) { 
+               if ((commandName == "read.dist") || (commandName == "read.otu") || (commandName == "read.tree") || (commandName == "read.shared")) { 
                        clear();
+                       gGroupmap = NULL;
                }
                
                //saves help request
@@ -104,6 +95,7 @@ void GlobalData::parseGlobalData(string commandString, string optionText){
                                if (key == "sabund" )   { sabundfile = value; inputFileName = value; fileroot = value; format = "sabund";       } 
                                if (key == "fasta" )    { fastafile = value; inputFileName = value; fileroot = value; format = "fasta";         } 
                                if (key == "tree" )             { treefile = value; inputFileName = value; fileroot = value; format = "tree";           }
+                               if (key == "shared" )   { sharedfile = value; inputFileName = value; fileroot = value; format = "sharedfile";   }
                                if (key == "name" )             { namefile = value;             }
                                if (key == "order" )    { orderfile = value;    }
                                if (key == "group" )    { groupfile = value;    }
@@ -116,37 +108,8 @@ void GlobalData::parseGlobalData(string commandString, string optionText){
                                if (key == "fileroot" )         { fileroot = value;             }
                                if (key == "randomtree" )       { randomtree = value;   }
                                if (key == "groups" )           { groups = value;       }
+                               if (key == "calc")                      { calc = value;         }
                                
-                               if (key == "single") {//stores estimators in a vector
-                                       singleEstimators.clear(); //clears out old values
-                                       if (value == "default") { value = "sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson-rarefraction"; }
-                                       splitAtDash(value, singleEstimators);
-                               }
-                               if (key == "rarefaction") {//stores estimators in a vector
-                                       rareEstimators.clear(); //clears out old values
-                                       if (value == "default") { value = "rarefraction"; }
-                                       splitAtDash(value, rareEstimators);
-                               }
-                               if (key == "shared") {//stores estimators in a vector
-                                       sharedEstimators.clear(); //clears out old values
-                                       if (value == "default") { value = "sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN"; }
-                                       splitAtDash(value, sharedEstimators);
-                               }
-                               if (key == "summary") { //stores summaries to be used in a vector
-                                       summaryEstimators.clear();
-                                       if (value == "default") { value = "summary-chao-ace-jack-bootstrap-shannon-npshannon-simpson"; }
-                                       splitAtDash(value, summaryEstimators);
-                               }
-                               if (key == "sharedsummary") { //stores sharedSummaries to be used in a vector
-                                       sharedSummaryEstimators.clear();
-                                       if (value == "default") { value = "sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN"; }
-                                       splitAtDash(value, sharedSummaryEstimators);
-                               }
-                               if (key == "sharedrarefaction") { //stores sharedrarefaction to be used in a vector
-                                       sharedRareEstimators.clear();
-                                       if (value == "default") { value = "sharedobserved"; }
-                                       splitAtDash(value, sharedRareEstimators);
-                               }
                                if (key == "line") {//stores lines to be used in a set
                                        lines.clear();
                                        line = value;
@@ -166,7 +129,6 @@ void GlobalData::parseGlobalData(string commandString, string optionText){
                                        groups = value;
                                        splitAtDash(value, Groups);
                                }
-
                        }
                        
                        //saves the last parameter
@@ -178,7 +140,8 @@ void GlobalData::parseGlobalData(string commandString, string optionText){
                        if (key == "rabund" )   { rabundfile = value; inputFileName = value; fileroot = value; format = "rabund";       }
                        if (key == "sabund" )   { sabundfile = value; inputFileName = value; fileroot = value; format = "sabund";       }
                        if (key == "fasta" )    { fastafile = value; inputFileName = value; fileroot = value; format = "fasta";         }
-                       if (key == "tree" )             { treefile = value; inputFileName = value; fileroot = value; format = "tree";           }  
+                       if (key == "tree" )             { treefile = value; inputFileName = value; fileroot = value; format = "tree";           } 
+                       if (key == "shared" )   { sharedfile = value; inputFileName = value; fileroot = value; format = "sharedfile";   } 
                        if (key == "name" )             { namefile = value;             }
                        if (key == "order" )    { orderfile = value;    }
                        if (key == "group" )    { groupfile = value;    }
@@ -191,39 +154,9 @@ void GlobalData::parseGlobalData(string commandString, string optionText){
                        if (key == "fileroot" )         { fileroot = value;             }
                        if (key == "randomtree" )       { randomtree = value;   }
                        if (key == "groups" )           { groups = value;       }
+                       if (key == "calc")                      { calc = value;         }
+
 
-                       
-                       if (key == "single") {//stores estimators in a vector
-                               singleEstimators.clear(); //clears out old values
-                               if (value == "default") { value = "sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson-rarefraction"; }
-                               splitAtDash(value, singleEstimators);
-                       }
-                       if (key == "rarefaction") {//stores estimators in a vector
-                               rareEstimators.clear(); //clears out old values
-                               if (value == "default") { value = "rarefraction"; }
-                               splitAtDash(value, rareEstimators);
-                       }
-                       if (key == "shared") {//stores estimators in a vector
-                               sharedEstimators.clear(); //clears out old values
-                               if (value == "default") { value = "sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN"; }
-                               splitAtDash(value, sharedEstimators);
-                       }
-                       if (key == "summary") { //stores summaries to be used in a vector
-                               summaryEstimators.clear();
-                               if (value == "default") { value = "summary-chao-ace-jack-bootstrap-shannon-npshannon-simpson"; }
-                               splitAtDash(value, summaryEstimators);
-                       }
-                       if (key == "sharedsummary") { //stores sharedSummaries to be used in a vector
-                               sharedSummaryEstimators.clear();
-                               if (value == "default") { value = "sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN"; }
-                               splitAtDash(value, sharedSummaryEstimators);
-                       }
-                       if (key == "sharedrarefaction") { //stores sharedrarefaction to be used in a vector
-                               sharedRareEstimators.clear();
-                               if (value == "default") { value = "sharedobserved"; }
-                               splitAtDash(value, sharedRareEstimators);
-                       }
-                       
                        if (key == "line") {//stores lines to be used in a vector
                                lines.clear();
                                line = value;
@@ -243,40 +176,49 @@ void GlobalData::parseGlobalData(string commandString, string optionText){
                                        groups = value;
                                        splitAtDash(value, Groups);
                        }
-
                }
                
                //set format for shared
                if ((listfile != "") && (groupfile != "")) { format = "shared"; }
                                
-               //input defaults
+               //input defaults for calculators
                if (commandName == "collect.single") {
-                       if (singleEstimators.size() == 0) { splitAtDash(single, singleEstimators); }
+                       if ((calc == "default") || (calc == "")) { calc = "sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson"; }
+                       Estimators.clear();
+                       splitAtDash(calc, Estimators); 
                }
                if (commandName == "rarefaction.single") {
-                       if (rareEstimators.size() == 0) { splitAtDash(rarefaction, rareEstimators);  }  
+                       if ((calc == "default") || (calc == "")) { calc = "sobs"; }
+                       Estimators.clear();
+                       splitAtDash(calc, Estimators); 
                }
                if (commandName == "collect.shared") {
-                       if (sharedEstimators.size() == 0) { splitAtDash(shared, sharedEstimators); }    
+                       if ((calc == "default") || (calc == "")) { calc = "sharedsobs-sharedchao-sharedace-sharedjabund-sharedsorensonabund-sharedjclass-sharedsorclass-sharedjest-sharedsorest-sharedthetayc-sharedthetan"; }
+                       Estimators.clear();
+                       splitAtDash(calc, Estimators); 
                }
                if (commandName == "summary.single") {
-                       if (summaryEstimators.size() == 0) { splitAtDash(summary, summaryEstimators); }
+                       if ((calc == "default") || (calc == "")) { calc = "sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson"; }
+                       Estimators.clear();
+                       splitAtDash(calc, Estimators); 
                }
                if (commandName == "summary.shared") {
-                       if (sharedSummaryEstimators.size() == 0) { splitAtDash(sharedsummary, sharedSummaryEstimators); }
+                       if ((calc == "default") || (calc == "")) { calc = "sharedsobs-sharedchao-sharedace-sharedjabund-sharedsorensonabund-sharedjclass-sharedsorclass-sharedjest-sharedsorest-sharedthetayc-sharedthetan"; }
+                       Estimators.clear();
+                       splitAtDash(calc, Estimators); 
                }
                if (commandName == "rarefaction.shared") {
-                       if (sharedRareEstimators.size() == 0) { splitAtDash(sharedrarefaction, sharedRareEstimators); }
+                       if ((calc == "default") || (calc == "")) { calc = "sharedobserved"; }
+                       Estimators.clear();
+                       splitAtDash(calc, Estimators); 
                }
 
-
                //if you have done a read.otu with a groupfile but don't want to use it anymore because you want to do single commands
                if ((commandName == "collect.single") || (commandName == "rarefaction.single") || (commandName == "summary.single")) {
                        if (listfile != "") { format = "list"; }
                        else if (sabundfile != "") { format = "sabund"; }
                        else if (rabundfile != "") { format = "rabund"; }
                }
-                               
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function parseGlobalData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -286,7 +228,6 @@ void GlobalData::parseGlobalData(string commandString, string optionText){
                cout << "An unknown error has occurred in the GlobalData class function parseGlobalData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
                exit(1);
        }
-
 }
 /*******************************************************/
 
@@ -301,6 +242,7 @@ string GlobalData::getNameFile()            {       return namefile;        }
 string GlobalData::getGroupFile()              {       return groupfile;       }
 string GlobalData::getOrderFile()              {       return orderfile;       }
 string GlobalData::getTreeFile()               {       return treefile;        }
+string GlobalData::getSharedFile()             {       return sharedfile;      }
 string GlobalData::getFastaFile()              {       return fastafile;       }
 string GlobalData::getCutOff()                 {       return cutoff;          }
 string GlobalData::getFormat()                 {       return format;          }
@@ -316,16 +258,14 @@ void GlobalData::setRabundFile(string file)       {       rabundfile = file;      inputFileName =
 void GlobalData::setSabundFile(string file)    {       sabundfile = file;      inputFileName = file;}
 void GlobalData::setPhylipFile(string file)    {       phylipfile = file;    inputFileName = file;}
 void GlobalData::setColumnFile(string file)    {       columnfile = file;    inputFileName = file;}
-//void GlobalData::setGroupFile(string file)   {       groupfile = file;               }
 void GlobalData::setNameFile(string file)              {       namefile = file;                }
 void GlobalData::setFormat(string Format)              {       format = Format;                }
 void GlobalData::setRandomTree(string Random)  {       randomtree = Random;    }
-
+void GlobalData::setCalc(string Calc)                  {       calc = Calc;    }
 
 /*******************************************************/
 
 /******************************************************/
-
 GlobalData::GlobalData() {
        //option definitions should go here...
        helpRequest = "";
@@ -334,7 +274,6 @@ GlobalData::GlobalData() {
 /*******************************************************/
 
 /******************************************************/
-
 void GlobalData::clear() {
        //option definitions should go here...
        phylipfile              =       "";
@@ -347,6 +286,7 @@ void GlobalData::clear() {
        orderfile               =       "";
        fastafile               =   "";
        treefile                =       "";
+       sharedfile              =       "";
        cutoff                  =       "10.00";
        format                  =       "";
        precision               =       "100";
@@ -359,17 +299,27 @@ void GlobalData::clear() {
        freq                    =       "100";
        method                  =       "furthest";
        fileroot                =       "";
-       single                  =       "sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson-rarefraction";
-       rarefaction             =       "sobs";
-       shared                  =       "sharedSobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN";
-       sharedsummary   =   "sharedSobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN";
-       summary                 =       "summary-chao-ace-jack-bootstrap-shannon-npshannon-simpson";
-       sharedrarefaction = "sharedobserved";
+       calc                    =       "";
 }
 /*******************************************************/
 
 /******************************************************/
+void GlobalData::reset() {
+       cutoff                  =       "10.00";
+       precision               =       "100";
+       iters                   =       "1000"; 
+       line                    =   "";
+       label                   =       "";
+       groups                  =       "";
+       jumble                  =       "1";    //0 means don't jumble, 1 means jumble.
+       randomtree              =       "0";  //0 means user will enter some user trees, 1 means they just want the random tree distribution.
+       freq                    =       "100";
+       method                  =       "furthest";
+       calc                    =       "";
+}
+/*******************************************************/
 
+/******************************************************/
 GlobalData::~GlobalData() {
        _uniqueInstance = 0;
        if(gListVector != NULL)         {       delete gListVector;             }
@@ -378,139 +328,5 @@ GlobalData::~GlobalData() {
 }
 /*******************************************************/
 
-/******************************************************/
-//This function parses the estimator options and puts them in a vector
-void GlobalData::splitAtDash(string& estim, vector<string>& container) {
-       try {
-               string individual;
-               
-               while (estim.find_first_of('-') != -1) {
-                       individual = estim.substr(0,estim.find_first_of('-'));
-                       if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
-                               estim = estim.substr(estim.find_first_of('-')+1, estim.length());
-                               container.push_back(individual);
-                       }
-               }
-               //get last one
-               container.push_back(estim);
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the GlobalData class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
-}
-/*******************************************************/
-
-/******************************************************/
-//This function parses the label options and puts them in a set
-void GlobalData::splitAtDash(string& estim, set<string>& container) {
-       try {
-               string individual;
-               
-               while (estim.find_first_of('-') != -1) {
-                       individual = estim.substr(0,estim.find_first_of('-'));
-                       if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
-                               estim = estim.substr(estim.find_first_of('-')+1, estim.length());
-                               container.insert(individual);
-                       }
-               }
-               //get last one
-               container.insert(estim);
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the GlobalData class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
-}
-/*******************************************************/
-
-/******************************************************/
-//This function parses the line options and puts them in a set
-void GlobalData::splitAtDash(string& estim, set<int>& container) {
-       try {
-               string individual;
-               int lineNum;
-               
-               while (estim.find_first_of('-') != -1) {
-                       individual = estim.substr(0,estim.find_first_of('-'));
-                       if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
-                               estim = estim.substr(estim.find_first_of('-')+1, estim.length());
-                               convert(individual, lineNum); //convert the string to int
-                               container.insert(lineNum);
-                       }
-               }
-               //get last one
-               convert(estim, lineNum); //convert the string to int
-               container.insert(lineNum);
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the GlobalData class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
-}
-/*******************************************************/
-
 /******************************************************/
 
-//This function splits up the various option parameters
-void GlobalData::splitAtComma(string& prefix, string& suffix){
-       try {
-               prefix = suffix.substr(0,suffix.find_first_of(','));
-               if ((suffix.find_first_of(',')+2) <= suffix.length()) {  //checks to make sure you don't have comma at end of string
-                       suffix = suffix.substr(suffix.find_first_of(',')+2, suffix.length());
-               }
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the GlobalData class function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
-}
-/*******************************************************/
-
-/******************************************************/
-//This function separates the key value from the option value i.e. dist=96_...
-void GlobalData::splitAtEquals(string& key, string& value){            
-       try {
-               if(value.find_first_of('=') != -1){
-                       key = value.substr(0,value.find_first_of('='));
-                       if ((value.find_first_of('=')+1) <= value.length()) {
-                               value = value.substr(value.find_first_of('=')+1, value.length());
-                       }
-               }else{
-                       key = value;
-                       value = 1;
-               }
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function splitAtEquals. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the GlobalData class function splitAtEquals. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
-}
-/*******************************************************/
-
-/******************************************************/
index 80891677d6e27d9f9e1e9671df4b128a962da116..277d351062fd67726f0ba05d53647d8c98b2a53c 100644 (file)
@@ -4,6 +4,13 @@
 #include <string>
 #include <vector>
 #include <set>
+#include <iostream>
+#include <iomanip>
+#include <map>
+#include <sstream>
+#include <stdexcept>
+#include <exception>
+
 #include "groupmap.h"
 #include "treemap.h"
 
@@ -34,7 +41,7 @@ public:
        TreeMap* gTreemap;
        string inputFileName, helpRequest, commandName;
        bool allLines;
-       vector<string> singleEstimators, summaryEstimators, sharedEstimators, rareEstimators, sharedRareEstimators, sharedSummaryEstimators; //holds estimators to be used
+       vector<string> Estimators; //holds estimators to be used
        set<int> lines; //hold lines to be used
        set<string> labels; //holds labels to be used
        vector<string> Groups;
@@ -49,6 +56,7 @@ public:
        string getOrderFile();
        string getFastaFile();
        string getTreeFile();
+       string getSharedFile();
        string getCutOff();
        string getFormat();
        string getPrecision();
@@ -66,22 +74,16 @@ public:
        void setSabundFile(string);
        void setFormat(string);
        void setRandomTree(string);
+       void setCalc(string);
 
        
        void setListVector(ListVector*);
        void setSparseMatrix(SparseMatrix*);
-       void clear(); 
-       
        void parseGlobalData(string, string);
-       void splitAtEquals(string&, string&);
-       void splitAtComma(string&, string&);
-       void splitAtDash(string&, vector<string>&);
-       void splitAtDash(string&, set<int>&);
-       void splitAtDash(string&, set<string>&);
-       
+               
 private:
-       string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, treefile, line, label, randomtree, groups;
-       string cutoff, format, precision, method, fileroot, iters, jumble, freq, single, rarefaction, shared, summary, sharedsummary, sharedrarefaction;
+       string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, treefile, sharedfile, line, label, randomtree, groups;
+       string cutoff, format, precision, method, fileroot, iters, jumble, freq, calc;
        static GlobalData* _uniqueInstance;
        GlobalData( const GlobalData& ); // Disable copy constructor
        void operator=( const GlobalData& ); // Disable assignment operator
@@ -89,10 +91,11 @@ private:
        ~GlobalData();
        ListVector* gListVector;
        SparseMatrix* gSparseMatrix;
+       void clear();  //clears all parameters
+       void reset();   //clears all non filename parameters
+       
        
        
 };
 
-//**********************************************************************************************************************
-
 #endif
index 27302dbce43f02a008fa54aaeb5e84bda8a8b003..1f22013699014c6afa0b6de5b7ce1722c43acbc0 100644 (file)
@@ -37,12 +37,7 @@ void GroupMap::readMap() {
                fileHandle.close();
 }
 /************************************************************/
-
-int GroupMap::getNumGroups() {
-                       
-       return namesOfGroups.size();    
-               
-}
+int GroupMap::getNumGroups() { return namesOfGroups.size();    }
 /************************************************************/
 
 string GroupMap::getGroup(string sequenceName) {
@@ -53,11 +48,13 @@ string GroupMap::getGroup(string sequenceName) {
        }else {
                return "not found";
        }
-               
 }
 
 /************************************************************/
-
+void GroupMap::setGroup(string sequenceName, string groupN) {
+       groupmap[sequenceName] = groupN;
+}
+/************************************************************/
 void GroupMap::setNamesOfGroups(string seqGroup) {
                        int i, count;
                        count = 0;
index a6b6fd7c25158a4ee7195d0f8e0432dfdecd078a..de69ca4d94c5e98342c666c7de0a768f61a3b267 100644 (file)
 
 class GroupMap {
 public:
+       GroupMap() {};
        GroupMap(string);
        ~GroupMap();
        void readMap();
        int getNumGroups();
        string getGroup(string);
+       void setGroup(string, string);
        vector<string> namesOfGroups;
        map<string, int> groupIndex;  //groupname, vectorIndex in namesOfGroups. - used by collectdisplays.
                
 private:
        ifstream fileHandle;
        string groupFileName;
-       int numGroups, index;
+       int index;
        map<string, string>::iterator it;
        void setNamesOfGroups(string); 
        map<string, string> groupmap; //sequence name and groupname
index bc17dbed4c95d7c74b04e03fc470078b8bc67496..0abab5a0fe25f7d4f0e5a100b379bf062f4ffb25 100644 (file)
 
 //**********************************************************************************************************************
 
-HelpCommand::HelpCommand(){}
+HelpCommand::HelpCommand(){
+       globaldata = GlobalData::getInstance();
+       validCommands = new ValidCommands();
+}
 
 //**********************************************************************************************************************
 
@@ -21,8 +24,6 @@ HelpCommand::~HelpCommand(){}
 
 int HelpCommand::execute(){
 
-       globaldata = GlobalData::getInstance();
-       
        if (globaldata->helpRequest == "read.dist") {
                cout << "The read.dist command parameter options are phylip or column, name, cutoff and precision" << "\n";
                cout << "The read.dist command should be in the following format: " << "\n";
@@ -47,7 +48,12 @@ int HelpCommand::execute(){
                cout << "It also must be run before using the parsimony command, unless you are using the randomtree parameter." << "\n";
                cout << "The read.tree command should be in the following format: read.tree(tree=yourTreeFile, group=yourGroupFile)." << "\n";
                cout << "The tree and group parameters are both required." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+               cout << "Note: No spaces between parameter labels (i.e. tree), '=' and parameters (i.e.yourTreefile)." << "\n" << "\n";
+       }else if (globaldata->helpRequest == "read.shared") {
+               cout << "The read.shared must be run before you execute a collect.shared, rarefaction.shared or summary.shared command." << "\n";
+               cout << "The read.shared command is used to read a shared file. The read.shared should be entered in the following format:" << "\n";
+               cout << "read.shared(shared=yourSharedFile). The shared parameter is required." << "\n";
+               cout << "Note: No spaces between parameter labels (i.e. shared), '=' and parameters (i.e.yourSharedfile)." << "\n" << "\n";
        }else if (globaldata->helpRequest == "cluster") {
                cout << "The cluster command can only be executed after a successful read.dist command." << "\n";
                cout << "The cluster command parameter options are method, cuttoff and precision. No parameters are required." << "\n";
@@ -64,60 +70,60 @@ int HelpCommand::execute(){
        }else if (globaldata->helpRequest == "collect.single") {
                cout << "The collect.single command can only be executed after a successful read.otu command. WITH ONE EXECEPTION. " << "\n";
                cout << "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";
-               cout << "The collect.single command parameters are label, line, freq, single.  No parameters are required, but you may not use " << "\n";
+               cout << "The collect.single command parameters are label, line, freq, calc.  No parameters are required, but you may not use " << "\n";
                cout << "both the line and label parameters at the same time. The collect.single command should be in the following format: " << "\n";
-               cout << "collect.single(label=yourLabel, line=yourLines, iters=yourIters, freq=yourFreq, single=yourEstimators)." << "\n";
-               cout << "Example collect(label=unique-.01-.03, line=0,5,10, iters=10000, freq=10, single=collect-chao-ace-jack)." << "\n";
-               cout << "The default values for freq is 100, and single are sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson." << "\n";
+               cout << "collect.single(label=yourLabel, line=yourLines, iters=yourIters, freq=yourFreq, calc=yourEstimators)." << "\n";
+               cout << "Example collect(label=unique-.01-.03, line=0,5,10, iters=10000, freq=10, calc=sobs-chao-ace-jack)." << "\n";
+               cout << "The default values for freq is 100, and calc are sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson." << "\n";
                cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+               cout << "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq)." << "\n" << "\n";
        }else if (globaldata->helpRequest == "collect.shared") {
                cout << "The collect.shared command can only be executed after a successful read.otu command." << "\n";
-               cout << "The collect.shared command parameters are label, line, freq, jumble, shared.  No parameters are required, but you may not use " << "\n";
+               cout << "The collect.shared command parameters are label, line, freq, jumble, calc.  No parameters are required, but you may not use " << "\n";
                cout << "both the line and label parameters at the same time. The collect.shared command should be in the following format: " << "\n";
-               cout << "collect.shared(label=yourLabel, line=yourLines, freq=yourFreq, jumble=yourJumble, shared=yourEstimators)." << "\n";
-               cout << "Example collect.shared(label=unique-.01-.03, line=0,5,10, freq=10, jumble=1, shared=sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN)." << "\n";
-               cout << "The default values for jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble), freq is 100 and shared are sharedsobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN." << "\n";
+               cout << "collect.shared(label=yourLabel, line=yourLines, freq=yourFreq, jumble=yourJumble, calc=yourEstimators)." << "\n";
+               cout << "Example collect.shared(label=unique-.01-.03, line=0,5,10, freq=10, jumble=1, calc=sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN)." << "\n";
+               cout << "The default values for jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble), freq is 100 and calc are sharedsobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN." << "\n";
                cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+               cout << "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq)." << "\n" << "\n";
        }else if (globaldata->helpRequest == "rarefaction.single") {
                cout << "The rarefaction.single command can only be executed after a successful read.otu WTIH ONE EXECEPTION." << "\n";
                cout << "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";
-               cout << "The rarefaction.single command parameters are label, line, iters, freq, rarefaction.  No parameters are required, but you may not use " << "\n";
+               cout << "The rarefaction.single command parameters are label, line, iters, freq, calc.  No parameters are required, but you may not use " << "\n";
                cout << "both the line and label parameters at the same time. The rarefaction.single command should be in the following format: " << "\n";
-               cout << "rarefaction.single(label=yourLabel, line=yourLines, iters=yourIters, freq=yourFreq, rarefaction=yourEstimators)." << "\n";
-               cout << "Example rarefaction.single(label=unique-.01-.03, line=0,5,10, iters=10000, freq=10, rarefaction=sobs-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson)." << "\n";
-               cout << "The default values for iters is 1000, freq is 100, and rarefaction is rarefaction which calculates the rarefaction curve for the observed richness." << "\n";
+               cout << "rarefaction.single(label=yourLabel, line=yourLines, iters=yourIters, freq=yourFreq, calc=yourEstimators)." << "\n";
+               cout << "Example rarefaction.single(label=unique-.01-.03, line=0,5,10, iters=10000, freq=10, calc=sobs-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson)." << "\n";
+               cout << "The default values for iters is 1000, freq is 100, and calc is rarefaction which calculates the rarefaction curve for the observed richness." << "\n";
                cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+               cout << "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq)." << "\n" << "\n";
        }else if (globaldata->helpRequest == "rarefaction.shared") {
                cout << "The rarefaction.shared command can only be executed after a successful read.otu command." << "\n";
-               cout << "The rarefaction.shared command parameters are label, line, iters, jumble and sharedrarefaction.  No parameters are required, but you may not use " << "\n";
+               cout << "The rarefaction.shared command parameters are label, line, iters, jumble and calc.  No parameters are required, but you may not use " << "\n";
                cout << "both the line and label parameters at the same time. The rarefaction command should be in the following format: " << "\n";
-               cout << "rarefaction.shared(label=yourLabel, line=yourLines, iters=yourIters, jumble=yourJumble, sharedrarefaction=yourEstimators)." << "\n";
-               cout << "Example rarefaction.shared(label=unique-.01-.03, line=0,5,10, iters=10000, jumble=1, sharedrarefaction=sharedobserved)." << "\n";
-               cout << "The default values for iters is 1000, jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble), freq is 100, and sharedrarefaction is sharedobserved which calculates the shared rarefaction curve for the observed richness." << "\n";
+               cout << "rarefaction.shared(label=yourLabel, line=yourLines, iters=yourIters, jumble=yourJumble, calc=yourEstimators)." << "\n";
+               cout << "Example rarefaction.shared(label=unique-.01-.03, line=0,5,10, iters=10000, jumble=1, calc=sharedobserved)." << "\n";
+               cout << "The default values for iters is 1000, jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble), freq is 100, and calc is sharedobserved which calculates the shared rarefaction curve for the observed richness." << "\n";
                cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+               cout << "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq)." << "\n" << "\n";
        }else if (globaldata->helpRequest == "summary.single") { 
                cout << "The summary.single command can only be executed after a successful read.otu WTIH ONE EXECEPTION." << "\n";
                cout << "The summary.single command can be executed after a successful cluster command.  It will use the .list file from the output of the cluster." << "\n";
-               cout << "The summary.single command parameters are label, line, summary.  No parameters are required, but you may not use " << "\n";
+               cout << "The summary.single command parameters are label, line, calc.  No parameters are required, but you may not use " << "\n";
                cout << "both the line and label parameters at the same time. The summary.single command should be in the following format: " << "\n";
-               cout << "summary.single(label=yourLabel, line=yourLines, summary=yourEstimators)." << "\n";
-               cout << "Example summary.single(label=unique-.01-.03, line=0,5,10, summary=sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson)." << "\n";
-               cout << "The default value summary is sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson" << "\n";
+               cout << "summary.single(label=yourLabel, line=yourLines, calc=yourEstimators)." << "\n";
+               cout << "Example summary.single(label=unique-.01-.03, line=0,5,10, calc=sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson)." << "\n";
+               cout << "The default value calc is sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson" << "\n";
                cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+               cout << "Note: No spaces between parameter labels (i.e. line), '=' and parameters (i.e.yourLines)." << "\n" << "\n";
        }else if (globaldata->helpRequest == "summary.shared") { 
                cout << "The summary.shared command can only be executed after a successful read.otu command." << "\n";
-               cout << "The summary.shared command parameters are label, line, jumble and sharedsummary.  No parameters are required, but you may not use " << "\n";
+               cout << "The summary.shared command parameters are label, line, jumble and calc.  No parameters are required, but you may not use " << "\n";
                cout << "both the line and label parameters at the same time. The summary.shared command should be in the following format: " << "\n";
-               cout << "summary.shared(label=yourLabel, line=yourLines, jumble=yourJumble, sharedsummary=yourEstimators)." << "\n";
-               cout << "Example summary.shared(label=unique-.01-.03, line=0,5,10, jumble=1, sharedsummary=sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN)." << "\n";
-               cout << "The default value for jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble) and sharedsummary is sharedsobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN" << "\n";
+               cout << "summary.shared(label=yourLabel, line=yourLines, jumble=yourJumble, calc=yourEstimators)." << "\n";
+               cout << "Example summary.shared(label=unique-.01-.03, line=0,5,10, jumble=1, calc=sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN)." << "\n";
+               cout << "The default value for jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble) and calc is sharedsobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN" << "\n";
                cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
-               cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+               cout << "Note: No spaces between parameter labels (i.e. line), '=' and parameters (i.e.yourLines)." << "\n" << "\n";
        }else if (globaldata->helpRequest == "parsimony") { 
                cout << "The parsimony command can only be executed after a successful read.tree command, unless you use the randomtree parameter." << "\n";
                cout << "The parsimony command parameters are randomtree and iters.  No parameters are required." << "\n";
@@ -150,7 +156,7 @@ int HelpCommand::execute(){
                cout << "The quit command will terminate Dotur and should be in the following format: " << "\n";
                cout << "quit()" << "\n" << "\n";
        }else if (globaldata->helpRequest == "") {
-               cout << "Valid commands are read.dist(), read.otu(), read.tree(), cluster(), deconvolute(), collect.single(), rarefaction.single(), summary.single(), collect.shared(), rarefaction.shared(), summary.shared(), parsimony(), unifrac.weighted(), unifrac.unweighted(), quit(), help()." << "\n";
+               validCommands->printCommands(cout);
                cout << "For more information about a specific command type 'help(commandName)' i.e. 'help(read.dist)'" << endl;
        }else {
                cout << globaldata->helpRequest << " is not a valid command" << endl;
index 6d95d86293c8660d3d514ac5895d4b57dccd68d2..d8f9b14d884e48d931f013f42badf8be4f38e42b 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "command.hpp"
 #include "globaldata.hpp"
+#include "validcommands.h"
 
 
 class HelpCommand : public Command {
@@ -23,6 +24,7 @@ public:
        int execute();
 private:
        GlobalData* globaldata;
+       ValidCommands* validCommands;
        
 private:
                
index 4ed9c2711d2f11b0182ec165884d3747eeb0be80..95e9d34974e005b50629d48502257fd7579f08c9 100644 (file)
@@ -89,7 +89,7 @@ ListVector* InputData::getListVector(){
 SharedListVector* InputData::getSharedListVector(){
        try {
                if(fileHandle){
-                       if (format == "shared"){
+                       if (format == "shared")  {
                                SharedList = new SharedListVector(fileHandle);
                        }
                                        
@@ -110,6 +110,33 @@ SharedListVector* InputData::getSharedListVector(){
        }       
 }
 
+/***********************************************************************/
+
+SharedOrderVector* InputData::getSharedOrderVector(){
+       try {
+               if(fileHandle){
+                       if (format == "sharedfile")  {
+                               SharedOrder = new SharedOrderVector(fileHandle);
+                       }
+                               
+                       gobble(fileHandle);
+                       return SharedOrder;
+                       
+               }else{
+                       return 0;
+               }
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the InputData class function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
+
+
 
 /***********************************************************************/
 
@@ -119,7 +146,7 @@ OrderVector* InputData::getOrderVector(){
                        if(format == "list") {
                                input = new ListVector(fileHandle);
                        }
-                       else if(format == "shared") {
+                       else if (format == "shared")  {
                                input = new SharedListVector(fileHandle);
                        }
                        else if(format == "rabund"){
@@ -138,7 +165,7 @@ OrderVector* InputData::getOrderVector(){
                        gobble(fileHandle);
                        output = new OrderVector();
                        *output = (input->getOrderVector());
-                       //delete input;
+                       
                        return output;
                }
                else{
@@ -163,7 +190,7 @@ SAbundVector* InputData::getSAbundVector(){
                        if (format == "list") {
                                input = new ListVector(fileHandle);
                        }
-                       else if(format == "shared") {
+                       else if (format == "shared")  {
                                input = new SharedListVector(fileHandle);
                        }
                        else if(format == "rabund"){
index abb343e98eb02677006af4316fbc10e4693f3a2a..b6912b3c8bef9803dae6aad648f97a80b3844b5b 100644 (file)
@@ -7,6 +7,7 @@
 #include <fstream>
 #include "ordervector.hpp"
 #include "sharedlistvector.h"
+#include "sharedordervector.h"
 #include "listvector.hpp"
 
 
@@ -21,6 +22,7 @@ public:
        ListVector* getListVector();
        SharedListVector* getSharedListVector();
        OrderVector* getOrderVector();
+       SharedOrderVector* getSharedOrderVector();
        SAbundVector* getSAbundVector();
        
 private:
@@ -30,6 +32,7 @@ private:
        ListVector* list;
        SharedListVector* SharedList;
        OrderVector* output;
+       SharedOrderVector* SharedOrder;
        SAbundVector* sabund;
        map<string,int> orderMap;
 };
index c2204e7a573969a2f4d1d80f41eb9defb3c53070..7e4ced55244665b4c3540f71491ce6dd4f003517 100644 (file)
@@ -25,28 +25,34 @@ RareFactCommand::RareFactCommand(){
                globaldata = GlobalData::getInstance();
                string fileNameRoot;
                fileNameRoot = getRootName(globaldata->inputFileName);
+               validCalculator = new ValidCalculators();
+               
                int i;
-               for (i=0; i<globaldata->rareEstimators.size(); i++) {
-                       if (globaldata->rareEstimators[i] == "sobs") { 
-                               rDisplays.push_back(new RareDisplay(new Sobs(), new ThreeColumnFile(fileNameRoot+"rarefaction")));
-                       }else if (globaldata->rareEstimators[i] == "chao") { 
-                               rDisplays.push_back(new RareDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"r_chao")));
-                       }else if (globaldata->rareEstimators[i] == "ace") { 
-                               rDisplays.push_back(new RareDisplay(new Ace(), new ThreeColumnFile(fileNameRoot+"r_ace")));
-                       }else if (globaldata->rareEstimators[i] == "jack") { 
-                               rDisplays.push_back(new RareDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"r_jack")));
-                       }else if (globaldata->rareEstimators[i] == "shannon") { 
-                               rDisplays.push_back(new RareDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"r_shannon")));
-                       }else if (globaldata->rareEstimators[i] == "npshannon") { 
-                               rDisplays.push_back(new RareDisplay(new NPShannon(), new ThreeColumnFile(fileNameRoot+"r_npshannon")));
-                       }else if (globaldata->rareEstimators[i] == "simpson") { 
-                               rDisplays.push_back(new RareDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"r_simpson")));
-                       }else if (globaldata->rareEstimators[i] == "bootstrap") { 
-                               rDisplays.push_back(new RareDisplay(new Bootstrap(), new ThreeColumnFile(fileNameRoot+"r_bootstrap")));
+               for (i=0; i<globaldata->Estimators.size(); i++) {
+                       if (validCalculator->isValidCalculator("rarefaction", globaldata->Estimators[i]) == true) { 
+                               if (globaldata->Estimators[i] == "sobs") { 
+                                       rDisplays.push_back(new RareDisplay(new Sobs(), new ThreeColumnFile(fileNameRoot+"rarefaction")));
+                               }else if (globaldata->Estimators[i] == "chao") { 
+                                       rDisplays.push_back(new RareDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"r_chao")));
+                               }else if (globaldata->Estimators[i] == "ace") { 
+                                       rDisplays.push_back(new RareDisplay(new Ace(), new ThreeColumnFile(fileNameRoot+"r_ace")));
+                               }else if (globaldata->Estimators[i] == "jack") { 
+                                       rDisplays.push_back(new RareDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"r_jack")));
+                               }else if (globaldata->Estimators[i] == "shannon") { 
+                                       rDisplays.push_back(new RareDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"r_shannon")));
+                               }else if (globaldata->Estimators[i] == "npshannon") { 
+                                       rDisplays.push_back(new RareDisplay(new NPShannon(), new ThreeColumnFile(fileNameRoot+"r_npshannon")));
+                               }else if (globaldata->Estimators[i] == "simpson") { 
+                                       rDisplays.push_back(new RareDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"r_simpson")));
+                               }else if (globaldata->Estimators[i] == "bootstrap") { 
+                                       rDisplays.push_back(new RareDisplay(new Bootstrap(), new ThreeColumnFile(fileNameRoot+"r_bootstrap")));
+                               }
                        }
                }
-       
-       
+               
+               //reset calc for next command
+               globaldata->setCalc("");
+
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the RareFactCommand class Function RareFactCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -73,6 +79,10 @@ RareFactCommand::~RareFactCommand(){
 int RareFactCommand::execute(){
        try {
                int count = 1;
+               
+               //if the users entered no valid calculators don't execute command
+               if (rDisplays.size() == 0) { return 0; }
+
                read = new ReadPhilFile(globaldata->inputFileName);     
                read->read(&*globaldata); 
 
index 0da5f0c20548196ed65d6e200620a8b0d9009d39..c81eb6fea19a3808ec93f0cdda1c779719947585 100644 (file)
@@ -18,6 +18,7 @@
 #include "rarefact.h"
 #include "display.h"
 #include "readmatrix.hpp"
+#include "validcalculator.h"
 
 
 /*The rarefaction() command:
@@ -49,6 +50,7 @@ private:
        ReadMatrix* read;
        OrderVector* order;
        InputData* input;
+       ValidCalculators* validCalculator;
        Rarefact* rCurve;
        int freq, nIters;
 };
index 5e36299505246ecbdbae8c64822a59e916f54dcc..45c2e2ebbdfc0004a8e1d6acb551649fe82b1239 100644 (file)
@@ -17,13 +17,21 @@ RareFactSharedCommand::RareFactSharedCommand(){
                globaldata = GlobalData::getInstance();
                string fileNameRoot;
                fileNameRoot = getRootName(globaldata->inputFileName);
+               format = globaldata->getFormat();
+               validCalculator = new ValidCalculators();
                                
                int i;
-               for (i=0; i<globaldata->sharedRareEstimators.size(); i++) {
-                       if (globaldata->sharedRareEstimators[i] == "sharedobserved") { 
-                               rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(fileNameRoot+"shared.rarefaction", "")));
+               for (i=0; i<globaldata->Estimators.size(); i++) {
+                       if (validCalculator->isValidCalculator("sharedrarefaction", globaldata->Estimators[i]) == true) { 
+                               if (globaldata->Estimators[i] == "sharedobserved") { 
+                                       rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(fileNameRoot+"shared.rarefaction", "")));
+                               }
                        }
                }
+               
+               //reset calc for next command
+               globaldata->setCalc("");
+
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the RareFactSharedCommand class Function RareFactSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -50,12 +58,25 @@ RareFactSharedCommand::~RareFactSharedCommand(){
 int RareFactSharedCommand::execute(){
        try {
                int count = 1;
-               read = new ReadPhilFile(globaldata->inputFileName);     
-               read->read(&*globaldata); 
                
-               input = globaldata->ginput;
-               SharedList = globaldata->gSharedList;
-               order = SharedList->getSharedOrderVector();
+               //if the users entered no valid calculators don't execute command
+               if (rDisplays.size() == 0) { return 0; }
+
+               if (format == "sharedfile") {
+                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read->read(&*globaldata); 
+                       
+                       input = globaldata->ginput;
+                       order = input->getSharedOrderVector();
+               }else {
+                       //you are using a list and a groupfile
+                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read->read(&*globaldata); 
+               
+                       input = globaldata->ginput;
+                       SharedList = globaldata->gSharedList;
+                       order = SharedList->getSharedOrderVector();
+               }
                
                while(order != NULL){
                
@@ -71,14 +92,20 @@ int RareFactSharedCommand::execute(){
                                cout << order->getLabel() << '\t' << count << endl;
                        }
                        
-                       SharedList = input->getSharedListVector(); //get new list vector to process
-                       if (SharedList != NULL) {
-                               order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
-                               count++;
+                       //get next line to process
+                       if (format == "sharedfile") {
+                               order = input->getSharedOrderVector();
                        }else {
-                               break;
+                               //you are using a list and a groupfile
+                               SharedList = input->getSharedListVector(); //get new list vector to process
+                               if (SharedList != NULL) {
+                                       order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
+                               }else {
+                                       break;
+                               }
                        }
-               
+                       
+                       count++;
                }
        
                for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    }       
index ab870242000bb0b07f3e28078feba84bcce1de4c..a0afb9607184e4d6e522fe92003047616e07c968 100644 (file)
@@ -19,6 +19,7 @@
 #include "rarefact.h"
 #include "display.h"
 #include "readmatrix.hpp"
+#include "validcalculator.h"
 
 /* The rarefaction.shared() command:
        The rarefaction command generates a rarefaction curve from a given file representing several groups.  
@@ -47,9 +48,11 @@ private:
        ReadMatrix* read;
        SharedOrderVector* order;
        InputData* input;
+       ValidCalculators* validCalculator;
        Rarefact* rCurve;
        vector<Display*> rDisplays;
        int freq, nIters;
+       string format;
 
 };
 
index 78a4bd4efe97b355513c51bec77616cbefa6a4e7..72dd799ec6d2e419dd843db6288de313fa0b4078 100644 (file)
@@ -346,7 +346,7 @@ void ReadPhilFile::read(GlobalData* globaldata){
                        //you have two inputs because in the next if statement if you only have one then it moves ahead in the same file.  
                        //So when you run the collect or summary commands you miss a line.
                        input = new InputData(philFile, globaldata->getFormat()); //format tells you whether philFile is list, rabund, sabund.
-                       inputSabund = new InputData(philFile, globaldata->getFormat()); //format tells you whether philFile is list, rabund, sabund.
+                       inputSabund = new InputData(philFile, globaldata->getFormat()); //format tells you whether philFile is list, rabund, sabund or shared.
                }else {//there is an orderfile
                        input = new InputData(philFile, globaldata->getOrderFile(), globaldata->getFormat());
                }
@@ -358,7 +358,7 @@ void ReadPhilFile::read(GlobalData* globaldata){
                        sabund = inputSabund->getSAbundVector(); 
                        globaldata->sabund = sabund; //saving to be used by summary command.
                }else if (globaldata->getFormat() == "shared") {
-                       SharedList = input->getSharedListVector(); //you are reading for parselist command, or shared commands.
+                       SharedList = input->getSharedListVector(); //you are reading for collect.shared, rarefaction.shared, summary.shared, parselist command, or shared commands.
                        globaldata->gSharedList = SharedList;
                }
        }
diff --git a/readsharedcommand.cpp b/readsharedcommand.cpp
new file mode 100644 (file)
index 0000000..0035156
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ *  readsharedcommand.cpp
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 2/12/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "readsharedcommand.h"
+
+//**********************************************************************************************************************
+ReadSharedCommand::ReadSharedCommand(){
+       try {
+               globaldata = GlobalData::getInstance();
+               filename = globaldata->inputFileName;
+               read = new ReadPhilFile(filename);
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the ReadSharedCommand class Function ReadSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the ReadSharedCommand class function ReadSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+}
+
+//**********************************************************************************************************************
+
+ReadSharedCommand::~ReadSharedCommand(){
+       delete read;
+}
+
+//**********************************************************************************************************************
+
+int ReadSharedCommand::execute(){
+       try {
+               read->read(&*globaldata); 
+       
+               return 0;
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the ReadSharedCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the ReadSharedCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
\ No newline at end of file
diff --git a/readsharedcommand.h b/readsharedcommand.h
new file mode 100644 (file)
index 0000000..8e7f290
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef READSHAREDCOMMAND_H
+#define READSHAREDCOMMAND_H
+/*
+ *  readsharedcommand.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 2/12/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+#include <iostream>
+#include <fstream>
+#include "command.hpp"
+#include "readmatrix.hpp"
+#include "inputdata.h"
+
+/* The read.shared must be run before you execute a collect.shared, rarefaction.shared or summary.shared command.
+The read.shared command is used to read a shared file. The read.shared should be entered in the following format:
+read.shared(shared=yourSharedFile). The shared parameter is required.  */
+
+class GlobalData;
+
+class ReadSharedCommand : public Command {
+public:
+       ReadSharedCommand();
+       ~ReadSharedCommand();
+       int execute();
+       
+private:
+       GlobalData* globaldata;
+       ReadMatrix* read;
+       InputData* input;
+       string filename;
+};
+
+#endif
+
+
+
+
index 62e37885d165c0abcd800f189c656664acb3f63b..81dd7281893a36667f4314f268fe9571c6bade61 100644 (file)
@@ -32,21 +32,22 @@ SharedListVector::SharedListVector(int n):  DataVector(), data(n, "") , maxRank(0
 SharedListVector::SharedListVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) {
        try {
                globaldata = GlobalData::getInstance();
-               
+
                //set up groupmap for later.
                groupmap = new GroupMap(globaldata->getGroupFile());
                groupmap->readMap();
 
                int hold;
+               string inputData;
                f >> label >> hold;
        
                data.assign(hold, "");
-               string inputData = "";
        
                for(int i=0;i<hold;i++){
                        f >> inputData;
                        set(i, inputData);
                }
+       
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function SharedListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
index 575ae18ea050e90c416efa480181773799a25af5..6aeb4ce5ab19a655c832343cb601c715777c2534 100644 (file)
@@ -26,25 +26,74 @@ SharedOrderVector::SharedOrderVector(string id, vector<individual>  ov) :
                updateStats();
 }
 
-/***********************************************************************
-
-//does not work since we don't have a shared order file format yet.
+/***********************************************************************/
+//This function is used to read a .shared file for the collect.shared, rarefaction.shared and summary.shared commands
+//if you don't use a list and groupfile.  
 
 SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() {
        try {
-               int hold;
-       
-               f >> label;
-               f >> hold;
-       
-               data.assign(hold, -1);
-       
-               int inputData;
-       
-               for(int i=0;i<hold;i++){
+               globaldata = GlobalData::getInstance();
+               
+               if (globaldata->gGroupmap == NULL) {  groupmap = new GroupMap(); }
+               
+               int num, inputData, pos, count;
+               count = 0;  numSeqs = 0;
+               string holdLabel, nextLabel, groupN;
+               individual newguy;
+               
+               //read in first row since you know there is at least 1 group.
+               f >> label >> groupN >> num;
+               holdLabel = label;
+               
+               if (globaldata->gGroupmap == NULL) { 
+                       //save group in groupmap
+                       groupmap->namesOfGroups.push_back(groupN);
+                       groupmap->groupIndex[groupN] = 0;
+               }
+               
+               for(int i=0;i<num;i++){
                        f >> inputData;
-                       set(i, inputData, inputData, group);
+                       for (int j = 0; j < inputData; j++) {
+                               push_back(i+1, i+1, groupN);
+                               numSeqs++;
+                       }
                }
+               
+               //save position in file in case next line is a new label.
+               pos = f.tellg();
+               
+               if (f.eof() != true) { f >> nextLabel; }
+               
+               //read the rest of the groups info in
+               while ((nextLabel == holdLabel) && (f.eof() != true)) {
+                       f >> groupN >> num;
+                       count++;
+                       
+                       if (globaldata->gGroupmap == NULL) { 
+                               //save group in groupmap
+                               groupmap->namesOfGroups.push_back(groupN);
+                               groupmap->groupIndex[groupN] = count;
+                       }
+                       
+                       for(int i=0;i<num;i++){
+                               f >> inputData;
+                               for (int j = 0; j < inputData; j++) {
+                                       push_back(i+1, i+1, groupN);
+                                       numSeqs++;
+                               }
+                       }
+                       
+                       //save position in file in case next line is a new label.
+                       pos = f.tellg();
+       
+                       if (f.eof() != true) { f >> nextLabel; }
+
+               }
+               
+               //put file pointer back since you are now at a new distance label
+               f.seekg(pos, ios::beg);
+       
+               if (globaldata->gGroupmap == NULL) { globaldata->gGroupmap = groupmap; }
        
                updateStats();
        }
@@ -57,10 +106,8 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() {
                exit(1);
        }
 }
-
 /***********************************************************************/
 
-
 int SharedOrderVector::getNumBins(){
        if(needToUpdate == 1){  updateStats();  }
        return numBins;
index b1b4a653dd51fb0280a5ea1189d690cf090614a4..94d91c5756da05a608253694a307ad6ea931baed 100644 (file)
@@ -29,6 +29,8 @@ struct individual {
 #include "rabundvector.hpp"
 #include "sharedrabundvector.h"
 #include "sharedsabundvector.h"
+#include "globaldata.hpp"
+#include "groupmap.h"
 
 class SharedOrderVector : public DataVector {
        
@@ -38,7 +40,7 @@ public:
        SharedOrderVector(const SharedOrderVector& ov)  : DataVector(ov.label), data(ov.data), maxRank(ov.maxRank), numBins(ov.numBins), numSeqs(ov.numSeqs), needToUpdate(ov.needToUpdate) {if(needToUpdate == 1){     updateStats();}};
 
        SharedOrderVector(string, vector<individual>);
-//     SharedOrderVector(ifstream&);
+       SharedOrderVector(ifstream&);
        ~SharedOrderVector(){};
        
        void set(int, int, int, string);        //index, OTU, abundance, group
@@ -63,6 +65,8 @@ public:
        SharedSAbundVector getSharedSAbundVector(string);       //get the sharedSabundvector for a sepecific group
        
 private:
+       GlobalData* globaldata;
+       GroupMap* groupmap;
        vector<individual>  data; 
        map< int, vector<individual> >::iterator it;
        int maxRank;
index a703e5577bbfa12cec108ade6c7e0e98b50ba7b5..a2b79362e273d3dd8168fb51231b66d381254f34 100644 (file)
@@ -65,10 +65,11 @@ SharedRAbundVector::SharedRAbundVector(string id, vector<individual> rav) : Data
 
 SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) {
        try {
-               int i, hold;
+               int i, num;
+               string holdLabel, group
                individual newGuy;
                
-               f >> label >> hold;
+               f >> label >> group >> num;
                
                //initialize data
                for (i=0; i<hold; i++) {
index 3ff35b15dacda761a51d52a64efcd1d760b5498e..97d938c484fe5029b7ce7c9d88f087feb76047d7 100644 (file)
@@ -10,6 +10,7 @@
  *
  */
 
+/* This calculator returns the number of shared species between 2 groups. */
 
 #include "calculator.h"
 
index c6170d10263a0b1e35fa4c03e39e61fc016e0087..7a3ad4a1e57e7f3f5dac9539fb2c974cd4e14cbe 100644 (file)
 SummaryCommand::SummaryCommand(){
        try {
                globaldata = GlobalData::getInstance();
+               validCalculator = new ValidCalculators();
                int i;
-               for (i=0; i<globaldata->summaryEstimators.size(); i++) {
-                       if(globaldata->summaryEstimators[i] == "sobs"){
-                               sumCalculators.push_back(new Sobs());
-                       }else if(globaldata->summaryEstimators[i] == "chao"){
-                               sumCalculators.push_back(new Chao1());
-                       }else if(globaldata->summaryEstimators[i] == "ace"){
-                               sumCalculators.push_back(new Ace());
-                       }else if(globaldata->summaryEstimators[i] == "jack"){
-                               sumCalculators.push_back(new Jackknife());
-                       }else if(globaldata->summaryEstimators[i] == "shannon"){
-                               sumCalculators.push_back(new Shannon());
-                       }else if(globaldata->summaryEstimators[i] == "npshannon"){
-                               sumCalculators.push_back(new NPShannon());
-                       }else if(globaldata->summaryEstimators[i] == "simpson"){
-                               sumCalculators.push_back(new Simpson());
-                       }else if(globaldata->summaryEstimators[i] == "bootstrap"){
-                               sumCalculators.push_back(new Bootstrap());
+               
+               for (i=0; i<globaldata->Estimators.size(); i++) {
+                       if (validCalculator->isValidCalculator("summary", globaldata->Estimators[i]) == true) { 
+                               if(globaldata->Estimators[i] == "sobs"){
+                                       sumCalculators.push_back(new Sobs());
+                               }else if(globaldata->Estimators[i] == "chao"){
+                                       sumCalculators.push_back(new Chao1());
+                               }else if(globaldata->Estimators[i] == "ace"){
+                                       sumCalculators.push_back(new Ace());
+                               }else if(globaldata->Estimators[i] == "jack"){
+                                       sumCalculators.push_back(new Jackknife());
+                               }else if(globaldata->Estimators[i] == "shannon"){
+                                       sumCalculators.push_back(new Shannon());
+                               }else if(globaldata->Estimators[i] == "npshannon"){
+                                       sumCalculators.push_back(new NPShannon());
+                               }else if(globaldata->Estimators[i] == "simpson"){
+                                       sumCalculators.push_back(new Simpson());
+                               }else if(globaldata->Estimators[i] == "bootstrap"){
+                                       sumCalculators.push_back(new Bootstrap());
+                               }
                        }
                }
+               
+               //reset calc for next command
+               globaldata->setCalc("");
+
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the SummaryCommand class Function SummaryCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -64,6 +72,10 @@ SummaryCommand::~SummaryCommand(){
 
 int SummaryCommand::execute(){
        try {
+       
+               //if the users entered no valid calculators don't execute command
+               if (sumCalculators.size() == 0) { return 0; }
+
                outputFileName = ((getRootName(globaldata->inputFileName)) + "summary");
                openOutputFile(outputFileName, outputFileHandle);
                outputFileHandle << "label";
index c03a6c61b34cef50b064593e346518d4ad741083..8e2d74b0b52252250cd5cede8a1bf9b10a689449 100644 (file)
@@ -17,6 +17,7 @@
 #include "inputdata.h"
 #include "calculator.h"
 #include "readmatrix.hpp"
+#include "validcalculator.h"
 
 /* The summary() command:
        The summary command can only be executed after a successful read.list, read.sabund or read.rabund command, with one exception. 
@@ -44,6 +45,7 @@ private:
        ReadMatrix* read;
        vector<Calculator*> sumCalculators;     
        InputData* input;
+       ValidCalculators* validCalculator;
        SAbundVector* sabund;
        string outputFileName;
        ofstream outputFileHandle;
index c451ef7aeb6ead4065f55a18bea99cb1840b530f..f31f7e10e1f19e47781d2d47dd9db09ebafa05cf 100644 (file)
 SummarySharedCommand::SummarySharedCommand(){
        try {
                globaldata = GlobalData::getInstance();
+               outputFileName = ((getRootName(globaldata->inputFileName)) + "shared.summary");
+               openOutputFile(outputFileName, outputFileHandle);
+               format = globaldata->getFormat();
+               validCalculator = new ValidCalculators();
                
                int i;
-               for (i=0; i<globaldata->sharedSummaryEstimators.size(); i++) {
-                       if (globaldata->sharedSummaryEstimators[i] == "sharedSobs") { 
-                               sumCalculators.push_back(new SharedSobsCS());
-                       }else if (globaldata->sharedSummaryEstimators[i] == "sharedChao") { 
-                               sumCalculators.push_back(new SharedChao1());
-                       }else if (globaldata->sharedSummaryEstimators[i] == "sharedAce") { 
-                               sumCalculators.push_back(new SharedAce());
-                       }else if (globaldata->sharedSummaryEstimators[i] == "sharedJabund") {   
-                               sumCalculators.push_back(new SharedJAbund());
-                       }else if (globaldata->sharedSummaryEstimators[i] == "sharedSorensonAbund") { 
-                               sumCalculators.push_back(new SharedSorAbund());
-                       }else if (globaldata->sharedSummaryEstimators[i] == "sharedJclass") { 
-                               sumCalculators.push_back(new SharedJclass());
-                       }else if (globaldata->sharedSummaryEstimators[i] == "sharedSorClass") { 
-                               sumCalculators.push_back(new SharedSorClass());
-                       }else if (globaldata->sharedSummaryEstimators[i] == "sharedJest") { 
-                               sumCalculators.push_back(new SharedJest());
-                       }else if (globaldata->sharedSummaryEstimators[i] == "sharedSorEst") { 
-                               sumCalculators.push_back(new SharedSorEst());
-                       }else if (globaldata->sharedSummaryEstimators[i] == "SharedThetaYC") { 
-                               sumCalculators.push_back(new SharedThetaYC());
-                       }else if (globaldata->sharedSummaryEstimators[i] == "SharedThetaN") { 
-                               sumCalculators.push_back(new SharedThetaN());
+               for (i=0; i<globaldata->Estimators.size(); i++) {
+                       if (validCalculator->isValidCalculator("sharedsummary", globaldata->Estimators[i]) == true) { 
+                               if (globaldata->Estimators[i] == "sharedsobs") { 
+                                       sumCalculators.push_back(new SharedSobsCS());
+                               }else if (globaldata->Estimators[i] == "sharedchao") { 
+                                       sumCalculators.push_back(new SharedChao1());
+                               }else if (globaldata->Estimators[i] == "sharedace") { 
+                                       sumCalculators.push_back(new SharedAce());
+                               }else if (globaldata->Estimators[i] == "sharedjabund") {        
+                                       sumCalculators.push_back(new SharedJAbund());
+                               }else if (globaldata->Estimators[i] == "sharedsorensonabund") { 
+                                       sumCalculators.push_back(new SharedSorAbund());
+                               }else if (globaldata->Estimators[i] == "sharedjclass") { 
+                                       sumCalculators.push_back(new SharedJclass());
+                               }else if (globaldata->Estimators[i] == "sharedsorclass") { 
+                                       sumCalculators.push_back(new SharedSorClass());
+                               }else if (globaldata->Estimators[i] == "sharedjest") { 
+                                       sumCalculators.push_back(new SharedJest());
+                               }else if (globaldata->Estimators[i] == "sharedsorest") { 
+                                       sumCalculators.push_back(new SharedSorEst());
+                               }else if (globaldata->Estimators[i] == "sharedthetayc") { 
+                                       sumCalculators.push_back(new SharedThetaYC());
+                               }else if (globaldata->Estimators[i] == "sharedthetan") { 
+                                       sumCalculators.push_back(new SharedThetaN());
+                               }
                        }
                }
+               
+               //reset calc for next command
+               globaldata->setCalc("");
+
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the SummarySharedCommand class Function SummarySharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -73,23 +83,34 @@ SummarySharedCommand::~SummarySharedCommand(){
 
 int SummarySharedCommand::execute(){
        try {
-               outputFileName = ((getRootName(globaldata->inputFileName)) + "shared.summary");
-               openOutputFile(outputFileName, outputFileHandle);
-       
-               read = new ReadPhilFile(globaldata->inputFileName);     
-               read->read(&*globaldata); 
+               int count = 1;  
                
+               //if the users entered no valid calculators don't execute command
+               if (sumCalculators.size() == 0) { return 0; }
+
+               if (format == "sharedfile") {
+                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read->read(&*globaldata); 
+                       
+                       input = globaldata->ginput;
+                       order = input->getSharedOrderVector();
+               }else {
+                       //you are using a list and a groupfile
+                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read->read(&*globaldata); 
+               
+                       input = globaldata->ginput;
+                       SharedList = globaldata->gSharedList;
+                       order = SharedList->getSharedOrderVector();
+               }
+               
+               //output estimator names as column headers
                outputFileHandle << "label" <<'\t' << "comparison" << '\t'; 
                for(int i=0;i<sumCalculators.size();i++){
                        outputFileHandle << '\t' << sumCalculators[i]->getName();
                }
                outputFileHandle << endl;
-               
-               SharedList = globaldata->gSharedList;
-               input = globaldata->ginput;
-               order = SharedList->getSharedOrderVector();
-               
-               int count = 1;
+
                while(order != NULL){
                
                        if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){                       
@@ -115,13 +136,19 @@ int SummarySharedCommand::execute(){
                                }
                        }
                
-                       SharedList = input->getSharedListVector(); //get new list vector to process
-                       if (SharedList != NULL) {
-                               order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
-                               count++;
+                       //get next line to process
+                       if (format == "sharedfile") {
+                               order = input->getSharedOrderVector();
                        }else {
-                               break;
+                               //you are using a list and a groupfile
+                               SharedList = input->getSharedListVector(); //get new list vector to process
+                               if (SharedList != NULL) {
+                                       order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
+                               }else {
+                                       break;
+                               }
                        }
+                       count++;
                }
        
                return 0;
index ab1d7ac4d8af610748c5dab7c26f42e2ff320da5..c531b8aafafc03632db7e3e7f52c48a29cdca83c 100644 (file)
@@ -18,6 +18,7 @@
 #include "calculator.h"
 #include "readmatrix.hpp"
 #include "sharedlistvector.h"
+#include "validcalculator.h"
 
 /*The summary.shared() command
        The summary.shared command can only be executed after a successful read.shared command. 
@@ -50,11 +51,12 @@ private:
        ReadMatrix* read;
        vector<Calculator*> sumCalculators;     
        InputData* input;
+       ValidCalculators* validCalculator;
        SharedListVector* SharedList;
        SharedOrderVector* order;
        vector<SharedRAbundVector*> lookup;
        SharedRAbundVector* shared1, shared2;
-       string outputFileName;
+       string outputFileName, format;
        ofstream outputFileHandle;
 
 };
diff --git a/tree.h b/tree.h
index 2ef8b23e94d0ad3921456c75518294c464a7ec0a..d7dcc3ddd790e0894347aa1bcb37d2da9608a567 100644 (file)
--- a/tree.h
+++ b/tree.h
 
 using namespace std;
 
-#include <string>
-#include <iostream>
-#include <vector>
-#include <fstream>
-#include <iomanip>
-#include <sstream>
-#include <map>
-
 #include "treenode.h"
 #include "globaldata.hpp"
 
index 16e762c295708ddbc3c0cd4835cd4b60bc8e9162..0c67561e427737ec95e2bb9e0ae29e8b87ff46ef 100644 (file)
@@ -10,6 +10,7 @@ using namespace std;
 #include <cmath>
 #include <vector>
 #include <stdexcept>
+#include <set>
 
 typedef unsigned long long ull;
 
@@ -196,4 +197,134 @@ inline int openOutputFile(string fileName, ofstream& fileHandle){
 
 /***********************************************************************/
 
+//This function parses the estimator options and puts them in a vector
+inline void splitAtDash(string& estim, vector<string>& container) {
+       try {
+               string individual;
+               
+               while (estim.find_first_of('-') != -1) {
+                       individual = estim.substr(0,estim.find_first_of('-'));
+                       if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
+                               estim = estim.substr(estim.find_first_of('-')+1, estim.length());
+                               container.push_back(individual);
+                       }
+               }
+               //get last one
+               container.push_back(estim);
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the utilities class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+
+}
+
+/***********************************************************************/
+//This function parses the label options and puts them in a set
+inline void splitAtDash(string& estim, set<string>& container) {
+       try {
+               string individual;
+               
+               while (estim.find_first_of('-') != -1) {
+                       individual = estim.substr(0,estim.find_first_of('-'));
+                       if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
+                               estim = estim.substr(estim.find_first_of('-')+1, estim.length());
+                               container.insert(individual);
+                       }
+               }
+               //get last one
+               container.insert(estim);
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the utilities class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+
+}
+/***********************************************************************/
+//This function parses the line options and puts them in a set
+inline void splitAtDash(string& estim, set<int>& container) {
+       try {
+               string individual;
+               int lineNum;
+               
+               while (estim.find_first_of('-') != -1) {
+                       individual = estim.substr(0,estim.find_first_of('-'));
+                       if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
+                               estim = estim.substr(estim.find_first_of('-')+1, estim.length());
+                               convert(individual, lineNum); //convert the string to int
+                               container.insert(lineNum);
+                       }
+               }
+               //get last one
+               convert(estim, lineNum); //convert the string to int
+               container.insert(lineNum);
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the utilities class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+
+}
+/***********************************************************************/
+
+//This function splits up the various option parameters
+inline void splitAtComma(string& prefix, string& suffix){
+       try {
+               prefix = suffix.substr(0,suffix.find_first_of(','));
+               if ((suffix.find_first_of(',')+2) <= suffix.length()) {  //checks to make sure you don't have comma at end of string
+                       suffix = suffix.substr(suffix.find_first_of(',')+2, suffix.length());
+               }
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the utilities class function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+
+}
+/***********************************************************************/
+
+//This function separates the key value from the option value i.e. dist=96_...
+inline void splitAtEquals(string& key, string& value){         
+       try {
+               if(value.find_first_of('=') != -1){
+                       key = value.substr(0,value.find_first_of('='));
+                       if ((value.find_first_of('=')+1) <= value.length()) {
+                               value = value.substr(value.find_first_of('=')+1, value.length());
+                       }
+               }else{
+                       key = value;
+                       value = 1;
+               }
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtEquals. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the utilities class function splitAtEquals. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+
+}
+/*******************************************************/
+
+
+
 #endif
index 1e25fe6d63a76e13c3f394c5377a47d828d39527..e75613f3044cb7bb6c6ec1798e850f0617243936 100644 (file)
@@ -42,37 +42,72 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
                        //is it valid
                        if ((single.find(calculator)) != (single.end())) {
                                return true;
-                       }else { cout << calculator << " is not a valid single estimator. Valid single estimators are collect-chao-ace-jack-bootstrap-shannon-npshannon-simpson." << endl; return false; }
+                       }else { 
+                               cout << calculator << " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ";
+                               for (it = single.begin(); it != single.end(); it++) {
+                                       cout << it->first << ", ";
+                               }
+                               cout << endl;
+                               return false; }
                //are you looking for a calculator for a shared parameter
                }else if (parameter == "shared") {
                        //is it valid
                        if ((shared.find(calculator)) != (shared.end())) {
                                return true;
-                       }else { cout << calculator << " is not a valid shared estimator.  Valid shared estimators are sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN." << endl; return false; }
+                       }else { 
+                               cout << calculator << " is not a valid estimator for the collect.shared command and will be disregarded.  Valid estimators are ";
+                               for (it = shared.begin(); it != shared.end(); it++) {
+                                       cout << it->first << ", ";
+                               }
+                               cout << endl;
+                               return false; }
                //are you looking for a calculator for a rarefaction parameter
                }else if (parameter == "rarefaction") {
                        //is it valid
                        if ((rarefaction.find(calculator)) != (rarefaction.end())) {
                                return true;
-                       }else { cout << calculator << " is not a valid rarefaction estimator. Valid rarefaction estimators are rarefaction-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson." << endl; return false; }
+                       }else { 
+                               cout << calculator << " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ";
+                               for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
+                                       cout << it->first << ", ";
+                               }
+                               cout << endl;
+                               return false; }
                //are you looking for a calculator for a summary parameter
                }else if (parameter == "summary") {
                        //is it valid
                        if ((summary.find(calculator)) != (summary.end())) {
                                return true;
-                       }else { cout << calculator << " is not a valid summary estimator. Valid summary estimators are collect-chao-ace-jack-bootstrap-shannon-npshannon-simpson." << endl; return false; }
+                       }else { 
+                               cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
+                               for (it = summary.begin(); it != summary.end(); it++) {
+                                       cout << it->first << ", ";
+                               }
+                               cout << endl;
+                               return false; }
                //are you looking for a calculator for a sharedsummary parameter
                }else if (parameter == "sharedsummary") {
                        //is it valid
                        if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
                                return true;
-                       }else { cout << calculator << " is not a valid sharedsummary estimator. Valid sharedsummary estimators are: sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN." << endl; return false; }
-
+                       }else { 
+                               cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
+                               for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
+                                       cout << it->first << ", ";
+                               }
+                               cout << endl;
+                               return false; }
                }else if (parameter == "sharedrarefaction") {
                        //is it valid
                        if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
                                return true;
-                       }else { cout << calculator << " is not a valid sharedrarefaction estimator. Valid sharedrarefaction estimator is sharedobserved." << endl; return false; }
+                       }else { 
+                               cout << calculator << " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ";
+                               for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
+                                       cout << it->first << ", ";
+                               }
+                               cout << endl;
+                               return false; }
                //not a valid paramter
                }else { return false; }
                
@@ -114,17 +149,17 @@ void ValidCalculators::initialSingle() {
 /********************************************************************/
 void ValidCalculators::initialShared() {
        try {   
-               shared["sharedSobs"]                    = "sharedSobs";
-               shared["sharedChao"]                    = "sharedChao";
-               shared["sharedAce"]                             = "sharedAce";
-               shared["sharedJabund"]                  = "sharedJabund";
-               shared["sharedSorensonAbund"]   = "sharedSorensonAbund";
-               shared["sharedJclass"]                  = "sharedJclass";
-               shared["sharedSorClass"]                = "sharedSorClass";
-               shared["sharedJest"]                    = "sharedJest";
-               shared["sharedSorEst"]                  = "sharedSorEst";
-               shared["SharedThetaYC"]                 = "SharedThetaYC";
-               shared["SharedThetaN"]                  = "SharedThetaN";
+               shared["sharedsobs"]                    = "sharedsobs";
+               shared["sharedchao"]                    = "sharedchao";
+               shared["sharedace"]                             = "sharedace";
+               shared["sharedjabund"]                  = "sharedjabund";
+               shared["sharedsorensonabund"]   = "sharedsorensonabund";
+               shared["sharedjclass"]                  = "sharedjclass";
+               shared["sharedsorclass"]                = "sharedsorclass";
+               shared["sharedjest"]                    = "sharedjest";
+               shared["sharedsorest"]                  = "sharedsorest";
+               shared["sharedthetayc"]                 = "sharedthetayc";
+               shared["sharedthetan"]                  = "sharedthetan";
                shared["default"]                   = "default";
        }
        catch(exception& e) {
@@ -187,17 +222,17 @@ void ValidCalculators::initialSummary() {
 /********************************************************************/
 void ValidCalculators::initialSharedSummary() {
        try {   
-               sharedsummary["sharedSobs"]                             = "sharedSobs";
-               sharedsummary["sharedChao"]                             = "sharedChao";
-               sharedsummary["sharedAce"]                              = "sharedAce";
-               sharedsummary["sharedJabund"]                   = "sharedJabund";
-               sharedsummary["sharedSorensonAbund"]    = "sharedSorensonAbund";
-               sharedsummary["sharedJclass"]                   = "sharedJclass";
-               sharedsummary["sharedSorClass"]                 = "sharedSorClass";
-               sharedsummary["sharedJest"]                             = "sharedJest";
-               sharedsummary["sharedSorEst"]                   = "sharedSorEst";
-               sharedsummary["SharedThetaYC"]                  = "SharedThetaYC";
-               sharedsummary["SharedThetaN"]                   = "SharedThetaN";
+               sharedsummary["sharedsobs"]                             = "sharedsobs";
+               sharedsummary["sharedchao"]                             = "sharedchao";
+               sharedsummary["sharedace"]                              = "sharedace";
+               sharedsummary["sharedjabund"]                   = "sharedjabund";
+               sharedsummary["sharedsorensonabund"]    = "sharedsorensonabund";
+               sharedsummary["sharedjclass"]                   = "sharedjclass";
+               sharedsummary["sharedsorclass"]                 = "sharedsorclass";
+               sharedsummary["sharedjest"]                             = "sharedjest";
+               sharedsummary["sharedsorest"]                   = "sharedsorest";
+               sharedsummary["sharedthetayc"]                  = "sharedthetayc";
+               sharedsummary["sharedthetan"]                   = "sharedthetan";
                sharedsummary["default"]                                = "default";
        }
        catch(exception& e) {
index b23c24f0b287d926d68090c25533007b3a86dca9..9d4cef9337bc3f693b0b1baf5b4e78304e078b57 100644 (file)
@@ -33,6 +33,8 @@ class ValidCalculators {
                map<string, string> summary;
                map<string, string> sharedrarefaction;
                map<string, string> sharedsummary;
+               map<string, string>::iterator it;
+               
                void initialSingle();
                void initialShared();
                void initialRarefaction();
index 53ee7431b49fecc06002e5b9330259371bd35729..79b09d38dbad7325c8bbbff8e352a17d0ddaeaba 100644 (file)
@@ -17,6 +17,7 @@ ValidCommands::ValidCommands() {
                commands["read.dist"]                   = "read.dist"; 
                commands["read.otu"]                    = "read.otu";
                commands["read.tree"]                   = "read.tree"; 
+               commands["read.shared"]                 = "read.shared";
                commands["cluster"]                             = "cluster"; 
                commands["deconvolute"]                 = "deconvolute"; 
                commands["parsimony"]                   = "parsimony";
@@ -55,7 +56,11 @@ bool ValidCommands::isValidCommand(string command) {
                if ((commands.find(command)) != (commands.end())) {
                        return true;
                }else{
-                       cout << command << " is not a valid command in Mothur.  Valid commands are read.dist(), read.otu(), read.tree(), cluster(), deconvolute(), collect.single(), collect.shared(), rarefaction.single(), rarefaction.shared(), summary.single(), summary.shared(), parsimony(), unifrac.weighted(), unifrac.unweighted(), quit(), help()." << endl;
+                       cout << command << " is not a valid command in Mothur.  Valid commands are ";
+                       for (it = commands.begin(); it != commands.end(); it++) {
+                               cout << it->first << ", ";
+                       }
+                       cout << endl;
                        return false;
                }
                
@@ -71,3 +76,24 @@ bool ValidCommands::isValidCommand(string command) {
 }
 
 /***********************************************************************/
+void ValidCommands::printCommands(ostream& out) {
+       try {   
+               out << "Valid commands are ";
+               for (it = commands.begin(); it != commands.end(); it++) {
+                       out << it->first << ", ";
+               }
+               out << endl;
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the ValidCommands class Function printCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the ValidCommands class function printCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+}
+
+
+
+
index 19554979d087cf82dc25027e0e441b883424e305..1b83b9bf4bab5060e35839b254bb59d45b3ef39e 100644 (file)
@@ -25,8 +25,10 @@ class ValidCommands {
                ValidCommands();
                ~ValidCommands();
                bool isValidCommand(string);
+               void printCommands(ostream&);
        private:
                map<string, string> commands;
+               map<string, string>::iterator it;
 
 };
 
index fbb368ed2a81ff413805b8deb20f4a79149dd53f..1c6cd60143c95fff34c531615b108d5d73925be4 100644 (file)
@@ -42,6 +42,7 @@ ValidParameters::ValidParameters() {
                parameters["sharedsummary"]             = "sharedsummary";
                parameters["randomtree"]                = "randomtree";
                parameters["groups"]                    = "groups";
+               parameters["calc"]                              = "calc";
                
        }
        catch(exception& e) {
@@ -66,7 +67,12 @@ bool ValidParameters::isValidParameter(string parameter) {
                if ((parameters.find(parameter)) != (parameters.end())) {
                        return true;
                }else{
-                       cout << parameter << " is not a valid parameter in Mothur." << endl;
+                       cout << parameter << " is not a valid parameter in Mothur. Valid parameters are " << endl;
+                       for (it = parameters.begin(); it != parameters.end(); it++) {
+                               cout << it->first << ", ";
+                       }
+                       cout << endl;
+
                        return false;
                }
                
index e0477aab0e9c1f39ffa19c836ef960de2c0e2bfa..a4dd51675445db321b6babad8a51048a11432114 100644 (file)
@@ -28,6 +28,7 @@ class ValidParameters {
                bool isValidParameter(string);
        private:
                map<string, string> parameters;
+               map<string, string>::iterator it;
 
 };