X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=raredisplay.cpp;h=b82127c51e6a64b50480a0f9b359cda3cd8e75f0;hb=79ca496859f48f1c38803c0f7c603faac348fe4c;hp=6c5a5e5f6d5c22a08d609681d88f5539460881ac;hpb=30b3ffcd1cfd08e7144ae721bb53e27eb3f7a5d1;p=mothur.git diff --git a/raredisplay.cpp b/raredisplay.cpp index 6c5a5e5..b82127c 100644 --- a/raredisplay.cpp +++ b/raredisplay.cpp @@ -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 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); + } +} + /***********************************************************************/