]> git.donarmstrong.com Git - mothur.git/blobdiff - optionparser.cpp
added code to check path for uchime and catchall executables
[mothur.git] / optionparser.cpp
index 0506da6ff441c5a85e296c1fd6f3033110622335..0d6ed2d4d0bfa681a7aa30693bcb7ae30a9c77fb 100644 (file)
@@ -21,11 +21,15 @@ OptionParser::OptionParser(string option) {
                        while((option.find_first_of(',') != -1)) {  //while there are parameters
                                m->splitAtComma(value, option);
                                m->splitAtEquals(key, value);
+                               if ((key == "candidate") || (key == "query")) { key = "fasta"; }
+                               if (key == "template") { key = "reference"; }
                                parameters[key] = value;
                        }
                        
                        //in case there is no comma and to get last parameter after comma
                        m->splitAtEquals(key, option);
+                       if ((key == "candidate") || (key == "query")) { key = "fasta"; }
+                       if (key == "template") { key = "reference"; }
                        parameters[key] = option;
                }
        }
@@ -49,7 +53,7 @@ map<string, string> OptionParser::getParameters() {
                        if (it->second == "current") {
                                
                                //look for file types
-                               if ((it->first == "fasta") || (it->first == "candidate")) {
+                               if (it->first == "fasta") {
                                        it->second = m->getFastaFile();
                                }else if (it->first == "qfile") {
                                        it->second = m->getQualFile();
@@ -87,6 +91,8 @@ map<string, string> OptionParser::getParameters() {
                                        it->second = m->getAccnosFile();
                                }else if (it->first == "taxonomy") {
                                        it->second = m->getTaxonomyFile();
+                }else if (it->first == "biom") {
+                        it->second = m->getBiomFile();
                                }else {
                                        m->mothurOut("[ERROR]: mothur does not save a current file for " + it->first); m->mothurOutEndLine();
                                }
@@ -100,7 +106,7 @@ map<string, string> OptionParser::getParameters() {
                                }
                        }else{ it++; }
                }
-       
+               
                return parameters;      
        }
        catch(exception& e) {
@@ -109,4 +115,54 @@ map<string, string> 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<string> files) { 
+       try {
+               string namefile = m->getNameFile();
+               bool match = false;
+               
+               if ((namefile != "")&&(!m->mothurCalling)) {
+                       string temp = m->getRootName(m->getSimpleName(namefile));
+                       vector<string> rootName;
+                       m->splitAtChar(temp, rootName, '.');
+                       
+                       for (int i = 0; i < files.size(); i++) {
+                               temp = m->getRootName(m->getSimpleName(files[i]));
+                               vector<string> 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);
+       }
+}
+
+                               
 /***********************************************************************/