+void MothurOut::printCurrentFiles() {
+ try {
+ if (accnosfile != "") { mothurOut("accnos=" + accnosfile); mothurOutEndLine(); }
+ if (columnfile != "") { mothurOut("column=" + columnfile); mothurOutEndLine(); }
+ if (designfile != "") { mothurOut("design=" + designfile); mothurOutEndLine(); }
+ if (fastafile != "") { mothurOut("fasta=" + fastafile); mothurOutEndLine(); }
+ if (groupfile != "") { mothurOut("group=" + groupfile); mothurOutEndLine(); }
+ if (listfile != "") { mothurOut("list=" + listfile); mothurOutEndLine(); }
+ if (namefile != "") { mothurOut("name=" + namefile); mothurOutEndLine(); }
+ if (oligosfile != "") { mothurOut("oligos=" + oligosfile); mothurOutEndLine(); }
+ if (orderfile != "") { mothurOut("order=" + orderfile); mothurOutEndLine(); }
+ if (ordergroupfile != "") { mothurOut("ordergroup=" + ordergroupfile); mothurOutEndLine(); }
+ if (phylipfile != "") { mothurOut("phylip=" + phylipfile); mothurOutEndLine(); }
+ if (qualfile != "") { mothurOut("qfile=" + qualfile); mothurOutEndLine(); }
+ if (rabundfile != "") { mothurOut("rabund=" + rabundfile); mothurOutEndLine(); }
+ if (relabundfile != "") { mothurOut("relabund=" + relabundfile); mothurOutEndLine(); }
+ if (sabundfile != "") { mothurOut("sabund=" + sabundfile); mothurOutEndLine(); }
+ if (sfffile != "") { mothurOut("sff=" + sfffile); mothurOutEndLine(); }
+ if (sharedfile != "") { mothurOut("shared=" + sharedfile); mothurOutEndLine(); }
+ if (taxonomyfile != "") { mothurOut("taxonomy=" + taxonomyfile); mothurOutEndLine(); }
+ if (treefile != "") { mothurOut("tree=" + treefile); mothurOutEndLine(); }
+ if (flowfile != "") { mothurOut("flow=" + flowfile); mothurOutEndLine(); }
+ if (biomfile != "") { mothurOut("biom=" + biomfile); mothurOutEndLine(); }
+ if (processors != "1") { mothurOut("processors=" + processors); mothurOutEndLine(); }
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "printCurrentFiles");
+ exit(1);
+ }
+}
+/*********************************************************************************************/
+bool MothurOut::hasCurrentFiles() {
+ try {
+ bool hasCurrent = false;
+
+ if (accnosfile != "") { return true; }
+ if (columnfile != "") { return true; }
+ if (designfile != "") { return true; }
+ if (fastafile != "") { return true; }
+ if (groupfile != "") { return true; }
+ if (listfile != "") { return true; }
+ if (namefile != "") { return true; }
+ if (oligosfile != "") { return true; }
+ if (orderfile != "") { return true; }
+ if (ordergroupfile != "") { return true; }
+ if (phylipfile != "") { return true; }
+ if (qualfile != "") { return true; }
+ if (rabundfile != "") { return true; }
+ if (relabundfile != "") { return true; }
+ if (sabundfile != "") { return true; }
+ if (sfffile != "") { return true; }
+ if (sharedfile != "") { return true; }
+ if (taxonomyfile != "") { return true; }
+ if (treefile != "") { return true; }
+ if (flowfile != "") { return true; }
+ if (biomfile != "") { return true; }
+ if (processors != "1") { return true; }
+
+ return hasCurrent;
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "hasCurrentFiles");
+ exit(1);
+ }
+}
+
+/*********************************************************************************************/
+void MothurOut::clearCurrentFiles() {
+ try {
+ phylipfile = "";
+ columnfile = "";
+ listfile = "";
+ rabundfile = "";
+ sabundfile = "";
+ namefile = "";
+ groupfile = "";
+ designfile = "";
+ orderfile = "";
+ treefile = "";
+ sharedfile = "";
+ ordergroupfile = "";
+ relabundfile = "";
+ fastafile = "";
+ qualfile = "";
+ sfffile = "";
+ oligosfile = "";
+ accnosfile = "";
+ taxonomyfile = "";
+ flowfile = "";
+ biomfile = "";
+ processors = "1";
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "clearCurrentFiles");
+ exit(1);
+ }
+}
+/***********************************************************************/
+string MothurOut::findProgramPath(string programName){
+ try {
+
+ string envPath = getenv("PATH");
+ string pPath = "";
+
+ //delimiting path char
+ char delim;
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
+ delim = ':';
+#else
+ delim = ';';
+#endif
+
+ //break apart path variable by ':'
+ vector<string> dirs;
+ splitAtChar(envPath, dirs, delim);
+
+ if (debug) { mothurOut("[DEBUG]: dir's in path: \n"); }
+
+ //get path related to mothur
+ for (int i = 0; i < dirs.size(); i++) {
+
+ if (debug) { mothurOut("[DEBUG]: " + dirs[i] + "\n"); }
+
+ //to lower so we can find it
+ string tempLower = "";
+ for (int j = 0; j < dirs[i].length(); j++) { tempLower += tolower(dirs[i][j]); }
+
+ //is this mothurs path?
+ if (tempLower.find(programName) != -1) { pPath = dirs[i]; break; }
+ }
+
+ if (debug) { mothurOut("[DEBUG]: programPath = " + pPath + "\n"); }
+
+ if (pPath != "") {
+ //add programName so it looks like what argv would look like
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
+ pPath += "/" + programName;
+#else
+ pPath += "\\" + programName;
+#endif
+ }else {
+ //okay programName is not in the path, so the folder programName is in must be in the path
+ //lets find out which one
+
+ //get path related to the program
+ for (int i = 0; i < dirs.size(); i++) {
+
+ if (debug) { mothurOut("[DEBUG]: looking in " + dirs[i] + " for " + programName + " \n"); }
+
+ //is this the programs path?
+ ifstream in;
+ string tempIn = dirs[i];
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
+ tempIn += "/" + programName;
+#else
+ tempIn += "\\" + programName;
+#endif
+ openInputFile(tempIn, in, "");
+
+ //if this file exists
+ if (in) { in.close(); pPath = tempIn; if (debug) { mothurOut("[DEBUG]: found it, programPath = " + pPath + "\n"); } break; }
+ }
+ }
+
+ return pPath;
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "findProgramPath");
+ exit(1);
+ }
+}
+/*********************************************************************************************/