]> git.donarmstrong.com Git - mothur.git/blobdiff - errorchecking.cpp
fixed some bugs
[mothur.git] / errorchecking.cpp
index 19d1f8aeacf25878fee069f1083b0465974d4645..caf7f73dc31cf02bd48ac7352f339e41b4f6cb96 100644 (file)
@@ -116,10 +116,10 @@ bool ErrorCheck::checkInput(string input) {
                                if (parameter == "soft" )                       { soft = value; }
                                if (parameter == "filter" )         { filter = value; }
                                if (parameter == "scale" )                      { scale = value;        }
-                               if (parameter == "ends" )                       { ends = value; }
+                               if (parameter == "countends" )          { countends = value; }
                                if (parameter == "processors" )         { processors = value;   }
                                if (parameter == "size" )                       { size = value; }
-                               if (parameter == "template")            { templatefile = value; }
+                               if (parameter == "candidate")           { candidatefile = value;        }
                                if (parameter == "search")                      { search = value;               }
                                if (parameter == "ksize")                       { ksize = value;                }
                                if (parameter == "align")                   { align = value;            }
@@ -166,10 +166,10 @@ bool ErrorCheck::checkInput(string input) {
                                if (parameter == "soft" )                       { soft = value; }
                                if (parameter == "filter" )         { filter = value; }
                                if (parameter == "scale" )                      { scale = value;        }
-                               if (parameter == "ends" )                       { ends = value; }
+                               if (parameter == "countends" )          { countends = value; }
                                if (parameter == "processors" )         { processors = value;   }
                                if (parameter == "size" )                       { size = value; }
-                               if (parameter == "template")            { templatefile = value; }
+                               if (parameter == "candidate")           { candidatefile = value;        }
                                if (parameter == "search")                      { search = value;               }
                                if (parameter == "ksize")                       { ksize = value;                }
                                if (parameter == "align")                   { align = value;            }
@@ -205,8 +205,8 @@ bool ErrorCheck::checkInput(string input) {
                        }
                }else if (commandName == "read.tree") { 
                        validateTreeFiles(); //checks the treefile and groupfile parameters
-               }else if (commandName == "deconvolute") {
-                       if (fastafile == "") { cout << "You must enter a fastafile with the deconvolute() command." << endl; return false; }
+               }else if (commandName == "unique.seqs") {
+                       if (fastafile == "") { cout << "You must enter a fastafile with the unique.seqs() command." << endl; return false; }
                        validateReadFiles();
                }
                
@@ -236,7 +236,7 @@ bool ErrorCheck::checkInput(string input) {
                
                //check for valid method
                if(commandName == "get.group") {
-                       if ((globaldata->getGroupFile() == "")) { cout << "You must read a group before you can use the get.group command." << endl; return false; }
+                       if ((globaldata->getSharedFile() == "")) { cout << "You must read a groupfile or a sharedfile before you can use the get.group command." << endl; return false; }
                }
                if (commandName == "get.label" || commandName == "get.line") {
                        if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { cout << "You must read a list, sabund or rabund before you can use the get.label or get.line command." << endl; return false; }
@@ -246,14 +246,31 @@ bool ErrorCheck::checkInput(string input) {
                        else {cout << "Not a valid clustering method.  Valid clustering algorithms are furthest, nearest or average." << endl; return false; }
                }
                
-               if ((commandName == "collect.single") || (commandName == "rarefaction.single") || (commandName == "summary.single") ){ 
+               if ((commandName == "collect.single") || (commandName == "rarefaction.single") || (commandName == "summary.single")){ 
                        if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { cout << "You must read a list, sabund or rabund before you can use the collect.single, rarefaction.single or summary.single commands." << endl; return false; }
                }
                
-               if ((commandName == "collect.shared") || (commandName == "rarefaction.shared") || (commandName == "summary.shared") || (commandName == "tree.shared") || (commandName == "bootstrap.shared")){ 
+               if (commandName == "get.rabund") {
+                       if (globaldata->getListFile() == "") { cout << "You must read a listfile before you can use the get.rabund command." << endl; return false; }
+               }
+               
+               if (commandName == "get.sabund") {
+                       if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "")) { cout << "You must read a list or rabund before you can use the get.sabund command." << endl; return false; }
+               }
+               
+               if ((commandName == "collect.shared") || (commandName == "rarefaction.shared") || (commandName == "summary.shared") || (commandName == "bootstrap.shared") || (commandName == "dist.shared")){ 
                        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, summary.shared, tree.shared or bootstrap.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, summary.shared, tree.shared or bootstrap.shared commands." << endl; return false; }
+                               if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared, summary.shared, tree.shared, bootstrap.shared or dist.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, summary.shared, tree.shared, bootstrap.shared or dist.shared commands." << endl; return false; }
+                       }
+               }
+               
+               if  (commandName == "tree.shared")  {
+                       //given no files                        
+                       if ((globaldata->getSharedFile() == "") && ((phylipfile == "") && (columnfile == "")))  { cout << "You must run the read.otu command or provide a distance file before running the tree.shared command." << endl; return false; }
+                       //you want to do single commands
+                       else if ((globaldata->getSharedFile() == "") && ((phylipfile != "") || (columnfile != ""))) {
+                               validateReadDist();
                        }
                }
                
@@ -263,26 +280,25 @@ bool ErrorCheck::checkInput(string input) {
                        }
                }
                
-               if ((commandName == "filter.seqs") || (commandName == "dist.seqs") || (commandName == "align.seqs")) { 
-                       if ((fastafile == "") && (nexusfile == "") && (clustalfile == "") && (phylipfile == "")) {
-                                cout << "You must enter either a fasta, nexus, clustal, or phylip file before you can use the filter.seqs, dist.seqs or align.seqs command." << endl; return false; 
-                       }else if ((commandName == "align.seqs") && (templatefile == "")) {
-                               cout << "You must enter a template to use the align.seqs command." << endl; return false; 
+               if ((commandName == "filter.seqs") || (commandName == "dist.seqs")) { 
+                       if (fastafile == "") {
+                                cout << "You must enter either a fasta file before you can use the filter.seqs or dist.seqs command." << endl; return false; 
                        }
                        validateSeqsFiles();
                }
                
-               if ((commandName == "bin.seqs")) { 
-                       if ((globaldata->getListFile() == "")) { cout << "You must read a list file before you can use the bin.seqs command." << endl; return false; }
-                       validateBinFiles();
+               if (commandName == "align.seqs") {
+                       if ((fastafile == "") || (candidatefile == "")) {
+                               cout << "You must enter fasta and a candidate file to use the align.seqs command." << endl; return false; 
+                       }
+                       validateSeqsFiles();
                }
                
-               if ((commandName == "get.repseqs")) { 
-                       if ((globaldata->getListFile() == "")) { cout << "You must read a list file before you can use the get.repseqs command." << endl; return false; }
-                       else if (groupfile == "") { cout << "You must provide a groupfile before you can use the get.repseqs command." << endl; return false; }
+               if ((commandName == "bin.seqs")) { 
+                       if ((globaldata->getListFile() == "")) { cout << "You must read a list file before you can use the bin.seqs commands." << endl; return false; }
                        validateBinFiles();
                }
-
+               
                
                if ((commandName == "get.oturep")) { 
                        if ((globaldata->gSparseMatrix == NULL) || (globaldata->gListVector == NULL)) {
@@ -290,6 +306,7 @@ bool ErrorCheck::checkInput(string input) {
                                errorFree = false;
                        }
                        if (listfile == "") { cout << "list is a required parameter for the get.oturep command." << endl; errorFree = false; }
+                       if (fastafile == "") { cout << "fasta is a required parameter for the get.oturep command." << endl; errorFree = false; }
                        validateBinFiles();
                } 
 
@@ -355,6 +372,12 @@ void ErrorCheck::validateReadFiles() {
                        //unable to open
                        if (ableToOpen == 1) {  errorFree = false; }
                        else { globaldata->inputFileName = sharedfile; }
+               }else if (groupfile != "") {
+                       ableToOpen = openInputFile(groupfile, filehandle);
+                       filehandle.close();
+                       if (ableToOpen == 1) { //unable to open
+                               errorFree = false;
+                       }
                }else{ //no file given
                        errorFree = false;
                }
@@ -386,8 +409,8 @@ void ErrorCheck::validateReadDist() {
                        if (ableToOpen == 1) {  errorFree = false; }
                }
                
-               if ((phylipfile == "") && (columnfile == "")) { cout << "When executing a read.dist you must enter a phylip or a column." << endl; errorFree = false; }
-               else if ((phylipfile != "") && (columnfile != "")) { cout << "When executing a read.dist you must enter ONLY ONE of the following: phylip or column." << endl; errorFree = false; }
+               if ((phylipfile == "") && (columnfile == "")) { cout << "When executing a read.dist or a tree.shared command with a distance file you must enter a phylip or a column." << endl; errorFree = false; }
+               else if ((phylipfile != "") && (columnfile != "")) { cout << "When executing a read.dist or a tree.shared command with a distance file you must enter ONLY ONE of the following: phylip or column." << endl; errorFree = false; }
                
                if (columnfile != "") {
                        if (namefile == "") {
@@ -436,7 +459,7 @@ void ErrorCheck::validateParseFiles() {
                                ableToOpen = openInputFile(groupfile, filehandle);
                                filehandle.close();
                                if (ableToOpen == 1) { //unable to open
-                                       errorFree = false;;
+                                       errorFree = false;
                                }
                        }
                }
@@ -584,8 +607,8 @@ void ErrorCheck::validateSeqsFiles() {
                                        errorFree = false;
                                }
                        }
-               }else if (templatefile != "") {
-                       ableToOpen = openInputFile(templatefile, filehandle);
+               }else if (candidatefile != "") {
+                       ableToOpen = openInputFile(candidatefile, filehandle);
                        filehandle.close();
                        if (ableToOpen == 1) { //unable to open
                                errorFree = false;
@@ -682,7 +705,7 @@ void ErrorCheck::clear() {
        fastafile       =   "";
        nexusfile       =   "";
        clustalfile     =   "";
-       templatefile    =       "";
+       candidatefile   =       "";
        line                    =       "";
        label                   =       "";
        method                  =   "furthest";