X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=chao1.cpp;h=ad1faa242b81c1520d29fb6395fa5f5825d179ec;hp=c05bdef2b7179a01f722cf497ab67f5b72ed7e3c;hb=050a3ff02473a3d4c0980964e1a9ebe52e55d6b8;hpb=e4827e0945cbda536064e5a345996b2a7dfcbb81 diff --git a/chao1.cpp b/chao1.cpp index c05bdef..ad1faa2 100644 --- a/chao1.cpp +++ b/chao1.cpp @@ -15,11 +15,21 @@ EstOutput Chao1::getValues(SAbundVector* rank){ data.resize(3,0); double sobs = (double)rank->getNumBins(); - - double singles = (double)rank->get(1); - double doubles = (double)rank->get(2); + + //this is a modification do to a vector fill error that occurs when an empty sharedRabund creates a sabund + //in that case there is no 1 0r 2. + double singles; + if (rank->size() > 1) { + singles = (double)rank->get(1); + }else{ singles = 0.0; } + + double doubles; + if (rank->size() > 2) { + doubles = (double)rank->get(2); + }else{ doubles = 0.0; } + double chaovar = 0.0000; - +//cout << "singles = " << singles << " doubles = " << doubles << " sobs = " << sobs << endl; double chao = sobs + singles*(singles-1)/(2*(doubles+1)); if(singles > 0 && doubles > 0){ @@ -60,13 +70,9 @@ EstOutput Chao1::getValues(SAbundVector* rank){ return data; } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the Chao1 class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "Chao1", "getValues"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the Chao1 class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } -}; +} /***********************************************************************/