X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=errorchecking.cpp;h=06524921a4db4670bdb4a7253977178f468c9b19;hb=0024441c1ff9a98467ba53cc7420a37c98f32e86;hp=8b80580a26faf27b8504f55039e494952a9f1be9;hpb=cdcf99b7760701e6869ca8e4e6e91c8e8c4ae186;p=mothur.git diff --git a/errorchecking.cpp b/errorchecking.cpp index 8b80580..0652492 100644 --- a/errorchecking.cpp +++ b/errorchecking.cpp @@ -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,17 +246,34 @@ 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") || (commandName == "dist.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, 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(); + } + } + if ((commandName == "heatmap") || (commandName == "venn")) { 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 or venn commands." << endl; return false; @@ -289,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(); } @@ -354,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; } @@ -385,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 == "") { @@ -435,7 +459,7 @@ void ErrorCheck::validateParseFiles() { ableToOpen = openInputFile(groupfile, filehandle); filehandle.close(); if (ableToOpen == 1) { //unable to open - errorFree = false;; + errorFree = false; } } }