]> git.donarmstrong.com Git - mothur.git/blobdiff - raredisplay.cpp
sffinfo bug with flow grams right index when clipQualRight=0
[mothur.git] / raredisplay.cpp
index 6c5a5e5f6d5c22a08d609681d88f5539460881ac..b82127c51e6a64b50480a0f9b359cda3cd8e75f0 100644 (file)
@@ -16,7 +16,7 @@ void RareDisplay::init(string label){
                this->label = label;
        }
        catch(exception& e) {
-               errorOut(e, "RareDisplay", "init");
+               m->errorOut(e, "RareDisplay", "init");
                exit(1);
        }
 }
@@ -49,7 +49,7 @@ void RareDisplay::update(SAbundVector* rank){
                }
        }
        catch(exception& e) {
-               errorOut(e, "RareDisplay", "update");
+               m->errorOut(e, "RareDisplay", "update");
                exit(1);
        }
 }
@@ -82,7 +82,7 @@ void RareDisplay::update(vector<SharedRAbundVector*> shared, int numSeqs, int nu
                }
        }
        catch(exception& e) {
-               errorOut(e, "RareDisplay", "update");
+               m->errorOut(e, "RareDisplay", "update");
                exit(1);
        }
 }
@@ -95,7 +95,7 @@ void RareDisplay::reset(){
                index = 0;
        }
        catch(exception& e) {
-               errorOut(e, "RareDisplay", "reset");
+               m->errorOut(e, "RareDisplay", "reset");
                exit(1);
        }
 }
@@ -131,10 +131,59 @@ void RareDisplay::close(){
                output->resetFile();
        }
        catch(exception& e) {
-               errorOut(e, "RareDisplay", "close");
+               m->errorOut(e, "RareDisplay", "close");
                exit(1);
        }
 }
+/***********************************************************************/
+
+void RareDisplay::inputTempFiles(string filename){
+       try {
+               ifstream in;
+               m->openInputFile(filename, in);
+               
+               int thisIters;
+               in >> thisIters; m->gobble(in);
+               
+               for (int i = 0; i < seqs.size(); i++) {
+                       double tempresult, tempvar;
+                       in >> tempresult >> tempvar; m->gobble(in);
+                       
+                       //find weighted result
+                       results[i] = ((nIters * results[i]) + (thisIters * tempresult)) / (float)(nIters + thisIters);
+                       
+                       var[i] = ((nIters * var[i]) + (thisIters * tempvar)) / (float)(nIters + thisIters);
+               }
+               
+               in.close();
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RareDisplay", "inputTempFiles");
+               exit(1);
+       }
+}
+
+/***********************************************************************/
+
+void RareDisplay::outputTempFiles(string filename){
+       try {
+               ofstream out;
+               m->openOutputFile(filename, out);
+               
+               out << nIters << endl;
+               
+               for (int i = 0; i < seqs.size(); i++) {
+                       out << results[i] << '\t' << var[i] << endl;
+               }
+               
+               out.close();
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RareDisplay", "outputTempFiles");
+               exit(1);
+       }
+}
+
 
 /***********************************************************************/