]> git.donarmstrong.com Git - mothur.git/blobdiff - mothurout.cpp
added chimera.uchime
[mothur.git] / mothurout.cpp
index c2ef698db8ed4d9c0769fcd4295a27a886c65bfc..3205ae794165a5b8c045c473403d8a66b1b54f90 100644 (file)
@@ -1154,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){