X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=errorchecking.cpp;h=c866ca0060960ab20f50f53ffbd774c066ffc628;hb=ec453945974b5c72af0bea042e3517312566d592;hp=728d4d27303a3c3b9d9ad602693ba4b309a36202;hpb=dc08123b7f14e2305e5bb2b3a8fcef96fc829b07;p=mothur.git diff --git a/errorchecking.cpp b/errorchecking.cpp index 728d4d2..c866ca0 100644 --- a/errorchecking.cpp +++ b/errorchecking.cpp @@ -23,6 +23,7 @@ ErrorCheck::ErrorCheck() { /******************************************************/ void ErrorCheck::refresh() { + //columnfile = globaldata->getColumnFile(); //phylipfile = globaldata->getPhylipFile(); //listfile = globaldata->getListFile(); @@ -38,6 +39,7 @@ void ErrorCheck::refresh() { //method = globaldata->getMethod(); //randomtree = globaldata->getRandomTree(); //sharedfile = globaldata->getSharedFile(); + } /*******************************************************/ @@ -74,7 +76,6 @@ bool ErrorCheck::checkInput(string input) { //is it a valid command if (validCommand->isValidCommand(commandName) != true) { return false; } - string parameter, value; //reads in parameters and values @@ -94,9 +95,11 @@ 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; } + if (parameter == "group" ) { groupfile = value; } + if (parameter == "shared" ) { sharedfile = value; } if (parameter == "cutoff" ) { cutoff = value; } if (parameter == "precision" ) { precision = value; } if (parameter == "iters" ) { iters = value; } @@ -107,10 +110,15 @@ bool ErrorCheck::checkInput(string input) { if (parameter == "line" ) { line = value; } if (parameter == "label" ) { label = value; } if (parameter == "abund" ) { abund = value; } - if (parameter == "random" ) { randomtree = value; } - if (parameter == "sorted" ) { sorted = value; } + if (parameter == "random" ) { randomtree = value; } + if (parameter == "sorted" ) { sorted = value; } + if (parameter == "trump" ) { trump = value; } + if (parameter == "soft" ) { soft = value; } + if (parameter == "filter" ) { filter = value; } if (parameter == "scale" ) { scale = value; } - + if (parameter == "ends" ) { ends = value; } + if (parameter == "processors" ) { processors = value; } + } //gets the last parameter and value @@ -131,6 +139,8 @@ 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; } @@ -144,7 +154,13 @@ bool ErrorCheck::checkInput(string input) { if (parameter == "random" ) { randomtree = value; } if (parameter == "abund" ) { abund = value; } if (parameter == "sorted" ) { sorted = value; } + if (parameter == "trump" ) { trump = value; } + if (parameter == "soft" ) { soft = value; } + if (parameter == "filter" ) { filter = value; } if (parameter == "scale" ) { scale = value; } + if (parameter == "ends" ) { ends = value; } + if (parameter == "processors" ) { processors = value; } + } } @@ -230,6 +246,13 @@ bool ErrorCheck::checkInput(string input) { } } + if ((commandName == "filter.seqs") || (commandName == "dist.seq")) { + 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; + } + 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(); @@ -486,6 +509,71 @@ 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; + } + } + + } + + } + 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 @@ -551,6 +639,9 @@ void ErrorCheck::clear() { groupfile = ""; orderfile = ""; sharedfile = ""; + fastafile = ""; + nexusfile = ""; + clustalfile = ""; line = ""; label = ""; method = "furthest";