X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=chao1.cpp;h=ad1faa242b81c1520d29fb6395fa5f5825d179ec;hp=b601b51f727490aeb3804f23b2aaa20ef1fad135;hb=615301e57c25e241356a9c2380648d117709458d;hpb=510b1cfc25cd79391d6973ca20c5ec25fb1bb3b2 diff --git a/chao1.cpp b/chao1.cpp index b601b51..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,7 +70,7 @@ EstOutput Chao1::getValues(SAbundVector* rank){ return data; } catch(exception& e) { - errorOut(e, "Chao1", "getValues"); + m->errorOut(e, "Chao1", "getValues"); exit(1); } }