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 (processors != "1") { mothurOut("processors=" + processors); mothurOutEndLine(); }
}
catch(exception& e) {
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 (processors != "1") { return true; }
+
+ return hasCurrent;
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "hasCurrentFiles");
+ exit(1);
+ }
+}
+
/*********************************************************************************************/
void MothurOut::clearCurrentFiles() {
try {
sfffile = "";
oligosfile = "";
accnosfile = "";
- taxonomyfile = "";
+ taxonomyfile = "";
+ flowfile = "";
+ processors = "1";
}
catch(exception& e) {
errorOut(e, "MothurOut", "clearCurrentFiles");
string line = "";
- while (!fileHandle.eof()) {
+ while (fileHandle) {
//get next character
char c = fileHandle.get();
//are you at the end of the line
- if ((c == '\n') || (c == '\r') || (c == '\f')){ break; }
+ if ((c == '\n') || (c == '\r') || (c == '\f') || (c == EOF)){ break; }
else { line += c; }
}
exit(1);
}
}
-
+/**************************************************************************************************/
+int MothurOut::divideFile(string filename, int& proc, vector<string>& files) {
+ try{
+
+ vector<unsigned long int> filePos = divideFile(filename, proc);
+
+ for (int i = 0; i < (filePos.size()-1); i++) {
+
+ //read file chunk
+ ifstream in;
+ openInputFile(filename, in);
+ in.seekg(filePos[i]);
+ unsigned long int size = filePos[(i+1)] - filePos[i];
+ char* chunk = new char[size];
+ in.read(chunk, size);
+ in.close();
+
+ //open new file
+ string fileChunkName = filename + "." + toString(i) + ".tmp";
+ ofstream out;
+ openOutputFile(fileChunkName, out);
+
+ out << chunk << endl;
+ out.close();
+ delete[] chunk;
+
+ //save name
+ files.push_back(fileChunkName);
+ }
+
+ return 0;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "divideFile");
+ exit(1);
+ }
+}
/***********************************************************************/
bool MothurOut::isTrue(string f){
exit(1);
}
}
+/**********************************************************************************************************************/
+int MothurOut::readNames(string namefile, vector<seqPriorityNode>& nameVector, map<string, string>& fastamap) {
+ try {
+ int error = 0;
+
+ //open input file
+ ifstream in;
+ openInputFile(namefile, in);
+
+ while (!in.eof()) {
+ if (control_pressed) { break; }
+
+ string firstCol, secondCol;
+ in >> firstCol >> secondCol; gobble(in);
+
+ int num = getNumNames(secondCol);
+
+ map<string, string>::iterator it = fastamap.find(firstCol);
+ if (it == fastamap.end()) {
+ error = 1;
+ mothurOut("[ERROR]: " + firstCol + " is not in your fastafile, but is in your namesfile, please correct."); mothurOutEndLine();
+ }else {
+ seqPriorityNode temp(num, it->second, firstCol);
+ nameVector.push_back(temp);
+ }
+ }
+ in.close();
+
+ return error;
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "readNames");
+ exit(1);
+ }
+}
/***********************************************************************/
exit(1);
}
}
-
+/**************************************************************************************************/
+bool MothurOut::isContainingOnlyDigits(string input) {
+ try{
+
+ //are you a digit in ascii code
+ for (int i = 0;i < input.length(); i++){
+ if( input[i]>47 && input[i]<58){}
+ else { return false; }
+ }
+
+ return true;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "isContainingOnlyDigits");
+ exit(1);
+ }
+}
/**************************************************************************************************/