]> git.donarmstrong.com Git - mothur.git/blobdiff - mothurout.cpp
added chimera.uchime
[mothur.git] / mothurout.cpp
index 65296221759fa879e591bb0967b0f20872106adc..3205ae794165a5b8c045c473403d8a66b1b54f90 100644 (file)
@@ -39,6 +39,8 @@ void MothurOut::printCurrentFiles()  {
                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) {
@@ -70,6 +72,8 @@ bool MothurOut::hasCurrentFiles()  {
                if (sharedfile != "")           {  return true;                 }
                if (taxonomyfile != "")         {  return true;                 }
                if (treefile != "")                     {  return true;                 }
+               if (flowfile != "")                     {  return true;                 }
+               if (processors != "1")          {  return true;                 }
                
                return hasCurrent;
                
@@ -101,7 +105,9 @@ void MothurOut::clearCurrentFiles()  {
                sfffile = "";
                oligosfile = "";
                accnosfile = "";
-               taxonomyfile = "";              
+               taxonomyfile = "";      
+               flowfile = "";
+               processors = "1";
        }
        catch(exception& e) {
                errorOut(e, "MothurOut", "clearCurrentFiles");
@@ -432,12 +438,12 @@ string MothurOut::getline(ifstream& fileHandle) {
        
                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;              }
                }
                
@@ -1148,7 +1154,43 @@ vector<unsigned long int> MothurOut::divideFile(string filename, int& proc) {
                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){