]> git.donarmstrong.com Git - mothur.git/blobdiff - errorchecking.cpp
adding treeclimber and unifrac pieces
[mothur.git] / errorchecking.cpp
index 7d63e9b5a53b77afcb277963f31418ac8bdfccd9..03844d5fa5b132e21ad1ae60e1c9e7b43e343aa2 100644 (file)
@@ -18,6 +18,12 @@ ErrorCheck::ErrorCheck() {
        validCommand = new ValidCommands();
        validParameter = new ValidParameters();
        validCalculator = new ValidCalculators();
+}
+/*******************************************************/
+
+/******************************************************/
+
+void ErrorCheck::refresh() {
        columnfile = globaldata->getColumnFile();
        phylipfile = globaldata->getPhylipFile();
        listfile = globaldata->getListFile();
@@ -31,8 +37,9 @@ ErrorCheck::ErrorCheck() {
        cutoff = globaldata->getCutOff();
        format = globaldata->getFormat();
        method = globaldata->getMethod();
-
+       randomtree = globaldata->getRandomTree();
 }
+
 /*******************************************************/
 
 /******************************************************/
@@ -46,7 +53,10 @@ ErrorCheck::~ErrorCheck() {}
 bool ErrorCheck::checkInput(string input) {
                errorFree = true;
                clear();
-
+               
+               //refresh variable
+               refresh();
+               
                //get command name and parameters
                int openParen = input.find_first_of('(');
                int closeParen = input.find_last_of(')');
@@ -91,6 +101,7 @@ bool ErrorCheck::checkInput(string input) {
                                if (parameter == "fileroot" )           { fileroot = value; }
                                if (parameter == "line" )                       { line = value; }
                                if (parameter == "label" )                      { label = value; }
+                               if (parameter == "randomtree" )         { randomtree = value;   }
 
                                if (parameter == "single") {//stores estimators in a vector
                                        singleEsimators.clear(); //clears out old values
@@ -160,6 +171,7 @@ bool ErrorCheck::checkInput(string input) {
                                if (parameter == "fileroot" )           { fileroot = value; }
                                if (parameter == "line" )                       { line = value; }
                                if (parameter == "label" )                      { label = value; }
+                               if (parameter == "randomtree" )         { randomtree = value;   }
 
                                if (parameter == "single") {//stores estimators in a vector
                                        singleEsimators.clear(); //clears out old values
@@ -234,6 +246,14 @@ bool ErrorCheck::checkInput(string input) {
                                errorFree = false;
                } 
                
+               if (commandName == "parsimony") {
+                       //are you trying to use parsimony without reading a tree or saying you want random distribution
+                       if (randomtree == "0")  {
+                               if ((globaldata->getTreeFile() == "") || (globaldata->getGroupFile() == "")) {
+                                       cout << "You must read a treefile and a groupfile or set the randomtree parameter to 1, before you may execute the parsimony command." << endl; return false;  }
+                       }
+               }
+               
                //check for valid method
                if (commandName == "cluster") {
                        if ((method == "furthest") || (method == "nearest") || (method == "average")) { }