]> git.donarmstrong.com Git - mothur.git/blobdiff - fileoutput.cpp
started work on classify.seqs command. changed the database class so that it does...
[mothur.git] / fileoutput.cpp
index 63130a83ba6c850bc8db4ea720ba51a15d80ff81..004ed8313511c2dd42d4b87aca93c0ad5750bce5 100644 (file)
@@ -27,7 +27,7 @@ void ThreeColumnFile::initFile(string label){
                        openInputFile(inName, inFile);
 
                        string inputBuffer;
-                       getline(inFile, inputBuffer);
+                       inputBuffer = getline(inFile);
                
                        outFile <<  inputBuffer << '\t' << label << "\tlci\thci" << endl;
                }
@@ -51,7 +51,7 @@ void ThreeColumnFile::output(int nSeqs, vector<double> data){
        try {
                if(counter != 0){               
                        string inputBuffer;
-                       getline(inFile, inputBuffer);
+                       inputBuffer = getline(inFile);
                
                        outFile <<  inputBuffer << setprecision(4) << '\t' << data[0] << '\t' << data[1] << '\t' << data[2] << endl;
                }
@@ -82,8 +82,10 @@ void ThreeColumnFile::resetFile(){
                renameOk = rename(outName.c_str(), inName.c_str());
                
                //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) {  mothurOut("Unable to rename necessary files."); mothurOutEndLine(); }
-
+               if ((renameOk != 0)) { 
+                       mothurOut("Unable to rename " + outName); mothurOutEndLine();
+                       perror(" : ");
+               }       
        }
        catch(exception& e) {
                errorOut(e, "ThreeColumnFile", "resetFile");
@@ -110,7 +112,7 @@ void ColumnFile::initFile(string label, vector<string> tags){
                        openInputFile(inName, inFile);
 
                        string inputBuffer;
-                       getline(inFile, inputBuffer);
+                       inputBuffer = getline(inFile);
                
                        outFile <<  inputBuffer << '\t'; 
                        for(int i = 0; i < tags.size(); i++) {
@@ -142,7 +144,7 @@ void ColumnFile::output(vector<double> data){
        
                if(counter != 0){               
                        string inputBuffer;
-                       getline(inFile, inputBuffer);
+                       inputBuffer = getline(inFile);
 
                        outFile << inputBuffer << '\t' << setprecision(6) << data[0] << setprecision(iters.length());
                        for (int i = 1; i< data.size(); i++) {
@@ -182,8 +184,10 @@ void ColumnFile::resetFile(){
                renameOk = rename(outName.c_str(), inName.c_str());
                
                //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) { mothurOut("Unable to rename necessary files."); mothurOutEndLine(); }
-
+               if ((renameOk != 0)) { 
+                       mothurOut("Unable to rename " + outName); mothurOutEndLine();
+                       perror(" : ");
+               }       
        }
        catch(exception& e) {
                errorOut(e, "ColumnFile", "resetFile");
@@ -210,7 +214,7 @@ void SharedThreeColumnFile::initFile(string label){
                        openInputFile(inName, inFile);
 
                        string inputBuffer;
-                       getline(inFile, inputBuffer);
+                       inputBuffer = getline(inFile);
                
                        outFile <<  inputBuffer << '\t' << label << "\tlci\thci" << endl;
                }
@@ -234,7 +238,7 @@ void SharedThreeColumnFile::output(int nSeqs, vector<double> data){
        try {
                if(counter != 0){               
                        string inputBuffer;
-                       getline(inFile, inputBuffer);
+                       inputBuffer = getline(inFile);
                
                        outFile <<  inputBuffer << setprecision(4) << '\t' << data[0] << '\t' << data[1] << '\t' << data[2] << endl;
                }
@@ -265,8 +269,10 @@ void SharedThreeColumnFile::resetFile(){
                renameOk = rename(outName.c_str(), inName.c_str());
                
                //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) { mothurOut("Unable to rename necessary files."); mothurOutEndLine(); }
-
+               if ((renameOk != 0)) { 
+                       mothurOut("Unable to rename " + outName); mothurOutEndLine();
+                       perror(" : ");
+               }       
        }
        catch(exception& e) {
                errorOut(e, "SharedThreeColumnFile", "resetFile");
@@ -294,7 +300,7 @@ void OneColumnFile::initFile(string label){
                        openInputFile(inName, inFile);
                
                        string inputBuffer;
-                       getline(inFile, inputBuffer);
+                       inputBuffer = getline(inFile);
                
                        outFile <<  inputBuffer << '\t' << label << endl;
                }
@@ -318,7 +324,7 @@ void OneColumnFile::output(int nSeqs, vector<double> data){
        try {   
                if(counter != 0){               
                        string inputBuffer;
-                       getline(inFile, inputBuffer);
+                       inputBuffer = getline(inFile);
                
                        outFile <<  inputBuffer << setprecision(4) << '\t'  << data[0] << endl;
                }
@@ -348,8 +354,10 @@ void OneColumnFile::resetFile(){
                renameOk = rename(outName.c_str(), inName.c_str());
                
                //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) { mothurOut("Unable to rename necessary files."); mothurOutEndLine(); }
-
+               if ((renameOk != 0)) { 
+                       mothurOut("Unable to rename " + outName); mothurOutEndLine();
+                       perror(" : ");
+               }       
        }
        catch(exception& e) {
                errorOut(e, "OneColumnFile", "resetFile");
@@ -376,7 +384,7 @@ void SharedOneColumnFile::initFile(string label){
                        openInputFile(inName, inFile);
                
                        string inputBuffer;
-                       getline(inFile, inputBuffer);
+                       inputBuffer = getline(inFile);
                
                        outFile <<  inputBuffer << '\t' << label  << endl;
 
@@ -409,7 +417,7 @@ void SharedOneColumnFile::output(int nSeqs, vector<double> data){
                        }
                        if(counter != 0){               
                                string inputBuffer;
-                               getline(inFile, inputBuffer);
+                               inputBuffer = getline(inFile);
 
                                outFile <<  inputBuffer << setprecision(2) << '\t' << dataOutput << endl;
                        }
@@ -435,14 +443,16 @@ void SharedOneColumnFile::resetFile(){
                        outFile.close();
                }       
                counter = 1;
-               
+
                remove(inName.c_str());
+
                renameOk = rename(outName.c_str(), inName.c_str());
                
                //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) { mothurOut("Unable to rename necessary files."); mothurOutEndLine(); }
-
-               
+               if ((renameOk != 0)) { 
+                       mothurOut("Unable to rename " + outName); mothurOutEndLine();
+                       perror(" : ");
+               }       
        }
        catch(exception& e) {
                errorOut(e, "SharedOneColumnFile", "resetFile");