]> git.donarmstrong.com Git - mothur.git/blobdiff - errorchecking.cpp
modified bin.seqs and get.oturep commands to include use of a groupfile if provided...
[mothur.git] / errorchecking.cpp
index 8aaa8b04fbeeb80b4c727396bab06f9899840a7e..f8b34bba53ef6260d0c0756dfeec109cc946c9e8 100644 (file)
@@ -118,7 +118,15 @@ bool ErrorCheck::checkInput(string input) {
                                if (parameter == "scale" )                      { scale = value;        }
                                if (parameter == "ends" )                       { ends = value; }
                                if (parameter == "processors" )         { processors = value;   }
-
+                               if (parameter == "size" )                       { size = value; }
+                               if (parameter == "template")            { templatefile = value; }
+                               if (parameter == "search")                      { search = value;               }
+                               if (parameter == "ksize")                       { ksize = value;                }
+                               if (parameter == "align")                   { align = value;            }
+                               if (parameter == "match")                       { match = value;                }
+                               if (parameter == "mismatch")            { mismatch = value;         }
+                               if (parameter == "gapopen")                     { gapopen = value;              }
+                               if (parameter == "gapextend" )          { gapextend = value;    }
                        }
                        
                        //gets the last parameter and value
@@ -160,7 +168,16 @@ bool ErrorCheck::checkInput(string input) {
                                if (parameter == "scale" )                      { scale = value;        }
                                if (parameter == "ends" )                       { ends = value; }
                                if (parameter == "processors" )         { processors = value;   }
-
+                               if (parameter == "size" )                       { size = value; }
+                               if (parameter == "template")            { templatefile = value; }
+                               if (parameter == "search")                      { search = value;               }
+                               if (parameter == "ksize")                       { ksize = value;                }
+                               if (parameter == "align")                   { align = value;            }
+                               if (parameter == "match")                       { match = value;                }
+                               if (parameter == "mismatch")            { mismatch = value;         }
+                               if (parameter == "gapopen")                     { gapopen = value;              }
+                               if (parameter == "gapextend" )          { gapextend = value;    }
+                               
                        }
                }
                
@@ -233,10 +250,10 @@ bool ErrorCheck::checkInput(string input) {
                        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 == "collect.shared") || (commandName == "rarefaction.shared") || (commandName == "summary.shared") || (commandName == "tree.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; }
                        }
                }
                
@@ -246,18 +263,21 @@ bool ErrorCheck::checkInput(string input) {
                        }
                }
                
-               if ((commandName == "filter.seqs") || (commandName == "dist.seqs")) { 
+               if ((commandName == "filter.seqs") || (commandName == "dist.seqs") || (commandName == "align.seqs")) { 
                        if ((fastafile == "") && (nexusfile == "") && (clustalfile == "") && (phylipfile == "")) {
-                                cout << "You must read either a fasta, nexus, clustal, or phylip file before you can use the filter.seqs command." << endl; return false; 
+                                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; 
                        }
                        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; }
+                       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)) {
                                cout << "Before you use the get.oturep command, you first need to read in a distance matrix." << endl; 
@@ -558,9 +578,15 @@ void ErrorCheck::validateSeqsFiles() {
                                        errorFree = false;
                                }
                        }
-
+               }else if (templatefile != "") {
+                       ableToOpen = openInputFile(templatefile, 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";
@@ -583,7 +609,7 @@ void ErrorCheck::validateBinFiles() {
                int ableToOpen;
                
                if (fastafile == "") {
-                               cout << "fasta is a required parameter for bin.seqs and get.oturep commands." << endl; errorFree = false; 
+                               cout << "fasta is a required parameter for bin.seqs, get.oturep and get.repseqs commands." << endl; errorFree = false; 
                }else if (fastafile != "") {
                        //is it a valid filename'
                        ableToOpen = openInputFile(fastafile, filehandle);
@@ -610,9 +636,17 @@ void ErrorCheck::validateBinFiles() {
                        filehandle.close();
                        //unable to open
                        if (ableToOpen == 1) {  errorFree = false; }
+               }else if (groupfile != "") {
+                       //is it a valid filename'
+                       ifstream filehandle;
+                       int ableToOpen = openInputFile(groupfile, filehandle);
+                       filehandle.close();
+                       //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";
@@ -642,6 +676,7 @@ void ErrorCheck::clear() {
        fastafile       =   "";
        nexusfile       =   "";
        clustalfile     =   "";
+       templatefile    =       "";
        line                    =       "";
        label                   =       "";
        method                  =   "furthest";