]> git.donarmstrong.com Git - mothur.git/blobdiff - errorchecking.cpp
added heatmap command
[mothur.git] / errorchecking.cpp
index 5f587a9b83a1a140409fc0cbdfa4bba0169ea518..59095f76e3bf46c652361e7b270f1c9ca8ebc7a1 100644 (file)
@@ -44,7 +44,10 @@ void ErrorCheck::refresh() {
 
 /******************************************************/
 
-ErrorCheck::~ErrorCheck() {}
+ErrorCheck::~ErrorCheck() {
+       delete validCommand;
+       delete validParameter;
+}
 
 /*******************************************************/
 
@@ -81,7 +84,9 @@ bool ErrorCheck::checkInput(string input) {
                                splitAtEquals(parameter, value);
                                
                                //is it a valid parameter
-                               if (validParameter->isValidParameter(parameter, commandName) != true) { return false; }
+                               if (validParameter->isValidParameter(parameter, commandName, value) != true) { return false; }
+
+
                                
                                if (parameter == "phylip" )             { phylipfile = value; }
                                if (parameter == "column" )             { columnfile = value; }
@@ -112,7 +117,8 @@ bool ErrorCheck::checkInput(string input) {
                                value = optionText;
                                splitAtEquals(parameter, value);
                                //is it a valid parameter
-                               if (validParameter->isValidParameter(parameter, commandName) != true) { return false; }
+                               if (validParameter->isValidParameter(parameter, commandName, value) != true) { return false; }
+       
                                
                                if (parameter == "phylip" )             { phylipfile = value; }
                                if (parameter == "column" )             { columnfile = value; }                         
@@ -142,6 +148,7 @@ bool ErrorCheck::checkInput(string input) {
                //make sure the user does not use both the line and label parameters
                if ((line != "") && (label != "")) { cout << "You may use either the line or label parameters, but not both." << endl; return false; }
                
+               //check for valid files 
                if (commandName == "read.dist") { 
                        validateReadFiles();
                        validateReadDist();
@@ -149,12 +156,15 @@ bool ErrorCheck::checkInput(string input) {
                        //you want to do shared commands
                        if ((listfile != "") && (groupfile != ""))      {
                                validateParseFiles(); //checks the listfile and groupfile parameters
-                       }else if (listfile != "") { //you want to do single commands
+                       //you want to do single commands
+                       }else if ((listfile != "") || (rabundfile != "") || (sabundfile != "")){ 
                                validateReadFiles();
                                validateReadPhil();
-                       }else if ((listfile == "") && (sharedfile == "")) {
-                               cout << "You must enter either a listfile or a sharedfile with the read.otu command. " << endl; return false; 
-                       }else{//you are reading a shared file
+                       //you have not given a file
+                       }else if ((listfile == "") && (sharedfile == "") && (rabundfile == "") && (sabundfile == "")) {
+                               cout << "You must enter either a listfile, rabundfile, sabundfile or a sharedfile with the read.otu command. " << endl; return false; 
+                       //you want to do shared commands with a shared file
+                       }else if (sharedfile != "") {//you are reading a shared file
                                validateReadFiles();
                        }
                }else if (commandName == "read.tree") { 
@@ -171,8 +181,8 @@ bool ErrorCheck::checkInput(string input) {
                                errorFree = false;
                } 
                
-               if ((commandName == "libshuff") && (globaldata->gMatrix == NULL)) {
-                        cout << "You must read in a matrix before you use the libshuff command. " << endl; return false; 
+               if ((commandName == "libshuff") && ((globaldata->gMatrix == NULL) || (globaldata->gGroupmap == NULL))) {
+                        cout << "You must read in a matrix and groupfile using the read.dist command, before you use the libshuff command. " << endl; return false; 
                }
                
                if (commandName == "parsimony") {
@@ -210,6 +220,12 @@ bool ErrorCheck::checkInput(string input) {
                                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; }
                        }
                }
+               
+               if (commandName == "heatmap"){ 
+                       if ((globaldata->getListFile() == "") && (globaldata->getSharedFile() == "")) {
+                                cout << "You must read a list, or a list and a group, or a shared before you can use the heatmap command." << endl; return false; 
+                       }
+               }
 
                return errorFree;
 }
@@ -428,7 +444,7 @@ void ErrorCheck::validateReadPhil() {
                }else if (sabundfile != "") { 
                        if ((listfile != "") || (rabundfile != "")) { 
                                cout << "When executing a read.otu you must enter ONLY ONE of the following: list, rabund or sabund." << endl; errorFree = false; }
-               }else if ((listfile == "") && (rabundfile == "") && (sabundfile == "")) {
+               }else if ((listfile == "") && (rabundfile == "") && (sabundfile == "") && (sharedfile == "")) {
                            cout << "When executing a read.otu you must enter one of the following: list, rabund or sabund." << endl; errorFree = false; 
                }