]> git.donarmstrong.com Git - mothur.git/blobdiff - aligncommand.cpp
changed reading of name file to use buffered reads. note the splitAtWhiteSpace functi...
[mothur.git] / aligncommand.cpp
index 8215de301b646f4d4571944de85dddb40478e7e5..75466f95b242ae08a71a88a40efec3a8fd230c86 100644 (file)
@@ -875,7 +875,7 @@ int AlignCommand::createProcesses(string alignFileName, string reportFileName, s
                        if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
                        in.close(); m->mothurRemove(tempFile);
                        
-                       appendAlignFiles((alignFileName + toString(processIDS[i]) + ".temp"), alignFileName);
+                       m->appendFiles((alignFileName + toString(processIDS[i]) + ".temp"), alignFileName);
                        m->mothurRemove((alignFileName + toString(processIDS[i]) + ".temp"));
                        
                        appendReportFiles((reportFileName + toString(processIDS[i]) + ".temp"), reportFileName);
@@ -892,7 +892,7 @@ int AlignCommand::createProcesses(string alignFileName, string reportFileName, s
                        rename(nonBlankAccnosFiles[0].c_str(), accnosFName.c_str());
                        
                        for (int h=1; h < nonBlankAccnosFiles.size(); h++) {
-                               appendAlignFiles(nonBlankAccnosFiles[h], accnosFName);
+                               m->appendFiles(nonBlankAccnosFiles[h], accnosFName);
                                m->mothurRemove(nonBlankAccnosFiles[h]);
                        }
                }else { //recreate the accnosfile if needed
@@ -957,7 +957,7 @@ int AlignCommand::createProcesses(string alignFileName, string reportFileName, s
                else { m->mothurRemove(accnosFName); } //remove so other files can be renamed to it
                
                for (int i = 1; i < processors; i++) {
-                       appendAlignFiles((alignFileName + toString(i) + ".temp"), alignFileName);
+                       m->appendFiles((alignFileName + toString(i) + ".temp"), alignFileName);
                        m->mothurRemove((alignFileName + toString(i) + ".temp"));
                        
                        appendReportFiles((reportFileName + toString(i) + ".temp"), reportFileName);
@@ -973,7 +973,7 @@ int AlignCommand::createProcesses(string alignFileName, string reportFileName, s
                        rename(nonBlankAccnosFiles[0].c_str(), accnosFName.c_str());
                        
                        for (int h=1; h < nonBlankAccnosFiles.size(); h++) {
-                               appendAlignFiles(nonBlankAccnosFiles[h], accnosFName);
+                               m->appendFiles(nonBlankAccnosFiles[h], accnosFName);
                                m->mothurRemove(nonBlankAccnosFiles[h]);
                        }
                }else { //recreate the accnosfile if needed
@@ -990,29 +990,6 @@ int AlignCommand::createProcesses(string alignFileName, string reportFileName, s
                exit(1);
        }
 }
-/**************************************************************************************************/
-
-void AlignCommand::appendAlignFiles(string temp, string filename) {
-       try{
-               
-               ofstream output;
-               ifstream input;
-               m->openOutputFileAppend(filename, output);
-               m->openInputFile(temp, input);
-               
-               while(char c = input.get()){
-                       if(input.eof())         {       break;                  }
-                       else                            {       output << c;    }
-               }
-               
-               input.close();
-               output.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCommand", "appendAlignFiles");
-               exit(1);
-       }
-}
 //**********************************************************************************************************************
 
 void AlignCommand::appendReportFiles(string temp, string filename) {
@@ -1025,10 +1002,11 @@ void AlignCommand::appendReportFiles(string temp, string filename) {
 
                while (!input.eof())    {       char c = input.get(); if (c == 10 || c == 13){  break;  }       } // get header line
                                
-               while(char c = input.get()){
-                       if(input.eof())         {       break;                  }
-                       else                            {       output << c;    }
-               }
+        char buffer[4096];        
+        while (!input.eof()) {
+            input.read(buffer, 4096);
+            output.write(buffer, input.gcount());
+        }
                
                input.close();
                output.close();