X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=optionparser.cpp;h=1e8c4451538683d4725ed60e535a5a86a8a0ea79;hb=8dd3c225255d7084e3aff8740aa4f1f1cabb367a;hp=71714f184e644105041910933a5bf877539deb24;hpb=ca9ac1d80c62f57270b0dcd49410ebe08a8aecd6;p=mothur.git diff --git a/optionparser.cpp b/optionparser.cpp index 71714f1..1e8c445 100644 --- a/optionparser.cpp +++ b/optionparser.cpp @@ -104,7 +104,7 @@ map OptionParser::getParameters() { } }else{ it++; } } - + return parameters; } catch(exception& e) { @@ -113,4 +113,54 @@ map OptionParser::getParameters() { } } +/***********************************************************************/ +//pass a vector of filenames that may match the current namefile. +//this function will look at each one, if the rootnames match, mothur will warn +//the user that they may have neglected to provide a namefile. +//stops when it finds a match. +bool OptionParser::getNameFile(vector files) { + try { + string namefile = m->getNameFile(); + bool match = false; + + if (namefile != "") { + string temp = m->getRootName(m->getSimpleName(namefile)); + vector rootName; + m->splitAtChar(temp, rootName, '.'); + + for (int i = 0; i < files.size(); i++) { + temp = m->getRootName(m->getSimpleName(files[i])); + vector root; + m->splitAtChar(temp, root, '.'); + + int smallest = rootName.size(); + if (root.size() < smallest) { smallest = root.size(); } + + int numMatches = 0; + for(int j = 0; j < smallest; j++) { + if (root[j] == rootName[j]) { numMatches++; } + } + + if (smallest > 0) { + if ((numMatches >= (smallest-2)) && (root[0] == rootName[0])) { + m->mothurOut("[WARNING]: This command can take a namefile and you did not provide one. The current namefile is " + namefile + " which seems to match " + files[i] + "."); + m->mothurOutEndLine(); + match = true; + break; + } + } + } + + } + + + return match; + } + catch(exception& e) { + m->errorOut(e, "OptionParser", "getNameFile"); + exit(1); + } +} + + /***********************************************************************/