+
+ m->mothurRemove(inName);
+ renameOk = rename(outName.c_str(), inName.c_str());
+
+ //renameFile(outName, inName);
+
+ //checks to make sure user was able to rename and remove successfully
+ if ((renameOk != 0)) {
+ m->mothurOut("Unable to rename " + outName); m->mothurOutEndLine();
+ perror(" : ");
+ }
+ }
+ catch(exception& e) {
+ m->errorOut(e, "ThreeColumnFile", "resetFile");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+/***********************************************************************/
+
+ColumnFile::~ColumnFile(){
+
+ inFile.close();
+ outFile.close();
+ m->mothurRemove(outName);
+}
+
+/***********************************************************************/
+
+void ColumnFile::initFile(string label, vector<string> tags){
+ try {
+ if(counter != 0){
+ m->openOutputFile(outName, outFile);
+ m->openInputFile(inName, inFile);
+
+ string inputBuffer;
+ inputBuffer = m->getline(inFile);
+
+ outFile << inputBuffer << '\t';
+ for(int i = 0; i < tags.size(); i++) {
+ outFile << label + tags[i] << '\t';
+ }
+ outFile << endl;
+ }
+ else{
+ m->openOutputFile(outName, outFile);
+ for(int i = 0; i < tags.size(); i++) {
+ outFile << label + tags[i] << '\t';
+ }
+ outFile << endl;
+ }
+
+ outFile.setf(ios::fixed, ios::floatfield);
+ outFile.setf(ios::showpoint);
+ }
+ catch(exception& e) {
+ m->errorOut(e, "ColumnFile", "initFile");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
+void ColumnFile::output(vector<double> data){
+ try {
+
+ if(counter != 0){
+ string inputBuffer;
+ inputBuffer = m->getline(inFile);
+
+ outFile << inputBuffer << '\t' << setprecision(6) << data[0] << setprecision(iters.length());
+ for (int i = 1; i< data.size(); i++) {
+ outFile << '\t' << data[i];
+ }
+ outFile << endl;
+ }
+ else{
+ outFile << setprecision(6) << data[0] << setprecision(iters.length());
+ for (int i = 1; i< data.size(); i++) {
+ outFile << '\t' << data[i];
+ }
+ outFile << endl;
+ }
+