From d873f7bf94309317a08c8757e0d0d60b06fbd473 Mon Sep 17 00:00:00 2001 From: westcott Date: Thu, 21 May 2009 14:13:47 +0000 Subject: [PATCH] fixed Thomas' calculators --- Mothur.xcodeproj/project.pbxproj | 6 +++--- boneh.cpp | 7 +++---- shen.cpp | 14 +++++++++----- shen.h | 2 ++ 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index 8136cc2..c49b637 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -636,14 +636,14 @@ isa = PBXGroup; children = ( 37D927BE0F21331F001D4494 /* calculator.h */, - 373C69950FC1E63600137ACD /* boneh.h */, - 373C69940FC1E63600137ACD /* boneh.cpp */, - 3792948D0F2E271100B9034A /* treecalculator.h */, 37D927BD0F21331F001D4494 /* calculator.cpp */, + 3792948D0F2E271100B9034A /* treecalculator.h */, 37D927B90F21331F001D4494 /* ace.h */, 37D927B80F21331F001D4494 /* ace.cpp */, EB1216860F619B83004A865F /* bergerparker.h */, EB1216870F619B83004A865F /* bergerparker.cpp */, + 373C69950FC1E63600137ACD /* boneh.h */, + 373C69940FC1E63600137ACD /* boneh.cpp */, 37D927BC0F21331F001D4494 /* bootstrap.h */, 37D927BB0F21331F001D4494 /* bootstrap.cpp */, EB1216E30F61ACFB004A865F /* bstick.h */, diff --git a/boneh.cpp b/boneh.cpp index 7117e35..2025ae7 100644 --- a/boneh.cpp +++ b/boneh.cpp @@ -70,10 +70,9 @@ EstOutput Boneh::getValues(SAbundVector* rank){ sum = 0; for(int j = 1; j < rank->size(); j++) { - double Xi = 0; //I didn't know what this was, simply replace the 0 - //with the appropriate expression for the boneh calculator - //to work. - sum += pow(1 - Xi / n, n) * (1 - pow(1 - Xi / n, m)) + v * pow(1 - f1/(n*v), n) * (1 - pow(1 - f1/(n*v), m)); + for (int i = 0; i < rank->get(j); i++) { + sum += pow(1 - j / n, n) * (1 - pow(1 - j / n, m)) + v * pow(1 - f1/(n*v), n) * (1 - pow(1 - f1/(n*v), m)); + } } } diff --git a/shen.cpp b/shen.cpp index c8368c6..61291a6 100644 --- a/shen.cpp +++ b/shen.cpp @@ -8,23 +8,27 @@ */ #include "shen.h" -#include +#include "ace.h" /***********************************************************************/ EstOutput Shen::getValues(SAbundVector* rank){ try { + globaldata = GlobalData::getInstance(); + data.resize(1,0); double n = (double)rank->getNumSeqs(); double f1 = (double)rank->get(1); - double D_rare = 0; //I didn't know what this was. Simply replace the '0' with the appropriate expression. - double C_rare = 1; //I didn't know what this was. Simply replace the '1' with the appropriate expression. - double Y_rare = 1; //I didn't know what this was. Simply replace the '1' with the appropriate expression. + int abund; + convert(globaldata->getAbund(), abund); + + Ace* calc = new Ace(abund); + EstOutput ace = calc->getValues(rank); - double f0 = D_rare/C_rare + f1/C_rare * Y_rare*Y_rare - D_rare; + double f0 = n - ace[0]; data[0] = f0 * (1 - pow(1 - f1/n/f0, m)); diff --git a/shen.h b/shen.h index d9a080a..a96abe9 100644 --- a/shen.h +++ b/shen.h @@ -11,6 +11,7 @@ */ #include "calculator.h" +#include "globaldata.hpp" /* This class implements the shen calculator on single group. It is a child of the calculator class. */ @@ -25,6 +26,7 @@ public: EstOutput getValues(vector) {return data;}; private: int m; + GlobalData* globaldata; }; -- 2.39.2