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(); }
}
if (taxonomyfile != "") { return true; }
if (treefile != "") { return true; }
if (flowfile != "") { return true; }
+ if (biomfile != "") { return true; }
if (processors != "1") { return true; }
return hasCurrent;
accnosfile = "";
taxonomyfile = "";
flowfile = "";
+ biomfile = "";
processors = "1";
}
catch(exception& e) {
//add / to name if needed
string lastChar = pathname.substr(pathname.length()-1);
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
if (lastChar != "/") { pathname += "/"; }
#else
if (lastChar != "\\") { pathname += "\\"; }
if (pid == 0) { //only one process should output to screen
#endif
- cout << output;
out << output;
+ logger() << output;
#ifdef USE_MPI
}
if (pid == 0) { //only one process should output to screen
#endif
- cout << endl;
out << endl;
+ logger() << endl;
#ifdef USE_MPI
}
if (pid == 0) { //only one process should output to screen
#endif
- cout << output;
+
out << output;
outputFile << output;
+ logger() << output;
#ifdef USE_MPI
}
#endif
+
}
catch(exception& e) {
errorOut(e, "MothurOut", "MothurOut");
if (pid == 0) { //only one process should output to screen
#endif
- cout << endl;
out << endl;
outputFile << endl;
+ logger() << endl;
#ifdef USE_MPI
}
//
// On failure, returns 0.0, 0.0
int MothurOut::mem_usage(double& vm_usage, double& resident_set) {
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
vm_usage = 0.0;
resident_set = 0.0;
}
/***********************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
#ifdef USE_COMPRESSION
inline bool endsWith(string s, const char * suffix){
size_t suffixLength = strlen(suffix);
string rootName = longName;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
#ifdef USE_COMPRESSION
if (endsWith(rootName, ".gz") || endsWith(rootName, ".bz2")) {
int pos = rootName.find_last_of('.');
}
/***********************************************************************/
+bool MothurOut::dirCheck(string& dirName){
+ try {
+
+ string tag = "";
+ #ifdef USE_MPI
+ int pid;
+ MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
+
+ tag = toString(pid);
+ #endif
+
+ //add / to name if needed
+ string lastChar = dirName.substr(dirName.length()-1);
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
+ if (lastChar != "/") { dirName += "/"; }
+ #else
+ if (lastChar != "\\") { dirName += "\\"; }
+ #endif
+
+ //test to make sure directory exists
+ dirName = getFullPathName(dirName);
+ string outTemp = dirName + tag + "temp";
+ ofstream out;
+ out.open(outTemp.c_str(), ios::trunc);
+ if(!out) {
+ mothurOut(dirName + " directory does not exist or is not writable."); mothurOutEndLine();
+ }else{
+ out.close();
+ mothurRemove(outTemp);
+ return true;
+ }
+
+ return false;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "dirCheck");
+ exit(1);
+ }
+
+}
+/***********************************************************************/
+
string MothurOut::hasPath(string longName){
try {
string path = "";
string MothurOut::getExtension(string longName){
try {
- string extension = longName;
+ string extension = "";
if(longName.find_last_of('.') != longName.npos){
int pos = longName.find_last_of('.');
string cwd;
//get current working directory
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
if (path.find("~") != -1) { //go to home directory
string homeDir;
}else if (path[(pos-1)] == '/') { //you want the current working dir ./
path = path.substr(0, pos);
}else if (pos == 1) { break; //you are at the end
- }else { cout << "cannot resolve path for " << fileName << endl; return fileName; }
+ }else { mothurOut("cannot resolve path for " + fileName + "\n"); return fileName; }
}
for (int i = index; i >= 0; i--) {
}else if (path[(pos-1)] == '\\') { //you want the current working dir ./
path = path.substr(0, pos);
}else if (pos == 1) { break; //you are at the end
- }else { cout << "cannot resolve path for " << fileName << endl; return fileName; }
+ }else { mothurOut("cannot resolve path for " + fileName + "\n"); return fileName; }
}
for (int i = index; i >= 0; i--) {
try {
//get full path name
string completeFileName = getFullPathName(fileName);
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
#ifdef USE_COMPRESSION
// check for gzipped or bzipped file
if (endsWith(completeFileName, ".gz") || endsWith(completeFileName, ".bz2")) {
//get full path name
string completeFileName = getFullPathName(fileName);
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
#ifdef USE_COMPRESSION
// check for gzipped or bzipped file
if (endsWith(completeFileName, ".gz") || endsWith(completeFileName, ".bz2")) {
int exist = openInputFile(newName, inTest, "");
inTest.close();
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
if (exist == 0) { //you could open it so you want to delete it
string command = "rm " + newName;
system(command.c_str());
try {
string completeFileName = getFullPathName(fileName);
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
#ifdef USE_COMPRESSION
// check for gzipped file
if (endsWith(completeFileName, ".gz") || endsWith(completeFileName, ".bz2")) {
int numLines = 0;
if (ableToOpen == 0) { //you opened it
- while(char c = input.get()){
+ while(!input.eof()){
+ char c = input.get();
if(input.eof()) { break; }
else { output << c; if (c == '\n') {numLines++;} }
}
//if you can, use the unix sort since its been optimized for years
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
string command = "sort -n -k +3 " + distFile + " -o " + outfile;
system(command.c_str());
#else //you are stuck with my best attempt...
while(isspace(d) && (d != in.eof())) { d=in.get(); count++;}
}
positions.push_back(count-1);
- cout << count-1 << endl;
+ //cout << count-1 << endl;
}
in.close();
fclose (pFile);
}
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
//estimate file breaks
unsigned long long chunkSize = 0;
}
in.close();
- return 0;
+ return nameMap.size();
}
catch(exception& e) {
}
in.close();
- return 0;
+ return nameMap.size();
}
catch(exception& e) {
if (control_pressed) { break; }
string firstCol, secondCol;
- in >> firstCol >> secondCol; gobble(in);
+ in >> firstCol; gobble(in);
+ in >> secondCol; gobble(in);
int num = getNumNames(secondCol);
exit(1);
}
}
+/***********************************************************************/
+//This function splits up the various option parameters
+void MothurOut::splitAtChar(string& prefix, string& suffix, char c){
+ try {
+ prefix = suffix.substr(0,suffix.find_first_of(c));
+ if ((suffix.find_first_of(c)+2) <= suffix.length()) { //checks to make sure you don't have comma at end of string
+ suffix = suffix.substr(suffix.find_first_of(c)+1, suffix.length());
+ string space = " ";
+ while(suffix.at(0) == ' ')
+ suffix = suffix.substr(1, suffix.length());
+ }
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "splitAtComma");
+ exit(1);
+ }
+}
+
/***********************************************************************/
//This function splits up the various option parameters