]> git.donarmstrong.com Git - mothur.git/blobdiff - errorchecking.cpp
dist.seqs can now use n processors, and only outputs the phylip formatted distance...
[mothur.git] / errorchecking.cpp
index e4c1877907e272c89a0be023ec21ad6bf2947f50..db16ef377cd67eb9cc5e086bcb1afcd7be31bc40 100644 (file)
@@ -95,8 +95,6 @@ bool ErrorCheck::checkInput(string input) {
                                if (parameter == "name" )               { namefile = value; }
                                if (parameter == "order" )              { orderfile = value; }
                                if (parameter == "fasta" )              { fastafile = value; }
-                               if (parameter == "nexus" )              { nexusfile = value; }
-                               if (parameter == "clustal" )    { clustalfile = value; }
                                if (parameter == "tree" )               { treefile = value; }
                                if (parameter == "group" )                      { groupfile = value; }
                                if (parameter == "shared" )                     { sharedfile = value; }
@@ -147,8 +145,6 @@ bool ErrorCheck::checkInput(string input) {
                                if (parameter == "group" )              { groupfile = value; }
                                if (parameter == "shared" )             { sharedfile = value; }
                                if (parameter == "fasta" )              { fastafile = value; }
-                               if (parameter == "nexus" )              { nexusfile = value; }
-                               if (parameter == "clustal" )    { clustalfile = value; }
                                if (parameter == "tree" )               { treefile = value; }
                                if (parameter == "cutoff" )                     { cutoff = value; }
                                if (parameter == "precision" )          { precision = value; }
@@ -205,8 +201,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();
                }
                
@@ -246,10 +242,18 @@ 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 == "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, bootstrap.shared or dist.shared commands." << endl; return false; }
@@ -272,18 +276,36 @@ bool ErrorCheck::checkInput(string input) {
                        }
                }
                
-               if ((commandName == "filter.seqs") || (commandName == "dist.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 or dist.seqs command." << endl; return false; 
+               if (commandName == "filter.seqs") { 
+                       if (fastafile == "") {
+                                cout << "You must enter either a fasta file before you can use the filter.seqs command." << endl; return false; 
+                       }
+                       validateReadFiles();
+               }
+               
+               if (commandName == "dist.seqs") {
+                       if (fastafile == "") {
+                                cout << "You must enter either a fasta file before you can use the dist.seqs command." << endl; return false; 
+                       }else {
+                               ifstream filehandle;
+                               int ableToOpen = openInputFile(fastafile, filehandle);
+                               filehandle.close();
+                               //unable to open
+                               if (ableToOpen == 1) { return false; }
                        }
-                       validateSeqsFiles();
                }
                
                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();
+                       validateReadFiles();
+                       
+                       ifstream filehandle;
+                       int ableToOpen = openInputFile(candidatefile, filehandle);
+                       filehandle.close();
+                       //unable to open
+                       if (ableToOpen == 1) {  return false; }
                }
                
                if ((commandName == "bin.seqs")) { 
@@ -298,6 +320,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();
                } 
 
@@ -549,77 +572,6 @@ void ErrorCheck::validateReadPhil() {
 }
 /*******************************************************/
 
-/******************************************************/
-//This function checks to make sure the user entered appropriate
-// format parameters on a distfile read
-void ErrorCheck::validateSeqsFiles() {
-       try {
-               ifstream filehandle;
-               int ableToOpen;
-               
-               //checks to make sure only one file type is given
-               if (phylipfile != "") { 
-                       if ((nexusfile != "") || (fastafile != "") || (clustalfile != "")) { 
-                               cout << "You may enter ONLY ONE of the following: phylip, fasta, nexus or clustal." << endl; errorFree = false; }
-                       else {
-                               ableToOpen = openInputFile(phylipfile, filehandle);
-                               filehandle.close();
-                               if (ableToOpen == 1) { //unable to open
-                                       errorFree = false;
-                               }
-                       }
-               }else if (nexusfile != "") { 
-                       if ((phylipfile != "") || (fastafile != "") || (clustalfile != "")) { 
-                               cout << "You may enter ONLY ONE of the following: phylip, fasta, nexus or clustal." << endl; errorFree = false; }
-                       else {
-                               ableToOpen = openInputFile(nexusfile, filehandle);
-                               filehandle.close();
-                               if (ableToOpen == 1) { //unable to open
-                                       errorFree = false;
-                               }
-                       }
-               }else if (fastafile != "") { 
-                       if ((phylipfile != "") || (nexusfile != "") || (clustalfile != "")) { 
-                               cout << "You may enter ONLY ONE of the following: phylip, fasta, nexus or clustal." << endl; errorFree = false; }
-                       else {
-                               ableToOpen = openInputFile(fastafile, filehandle);
-                               filehandle.close();
-                               if (ableToOpen == 1) { //unable to open
-                                       errorFree = false;
-                               }
-                       }
-               }else if (clustalfile != "") { 
-                       if ((phylipfile != "") || (nexusfile != "") || (fastafile != "")) { 
-                               cout << "You may enter ONLY ONE of the following: phylip, fasta, nexus or clustal." << endl; errorFree = false; }
-                       else {
-                               ableToOpen = openInputFile(clustalfile, filehandle);
-                               filehandle.close();
-                               if (ableToOpen == 1) { //unable to open
-                                       errorFree = false;
-                               }
-                       }
-               }else if (candidatefile != "") {
-                       ableToOpen = openInputFile(candidatefile, filehandle);
-                       filehandle.close();
-                       if (ableToOpen == 1) { //unable to open
-                               errorFree = false;
-                       }
-               }
-               
-               
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ErrorCheck class Function validateSeqsFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ErrorCheck class function validateSeqsFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-}
-
-/*******************************************************/
-
 /******************************************************/
 //This function checks to make sure the user entered appropriate
 // format parameters on a bin.seq command
@@ -664,9 +616,6 @@ void ErrorCheck::validateBinFiles() {
                        //unable to open
                        if (ableToOpen == 1) {  errorFree = false; }
                }
-
-
-
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the ErrorCheck class Function validateBinFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -694,8 +643,6 @@ void ErrorCheck::clear() {
        orderfile               =       "";
        sharedfile              =       "";
        fastafile       =   "";
-       nexusfile       =   "";
-       clustalfile     =   "";
        candidatefile   =       "";
        line                    =       "";
        label                   =       "";