From 8062b1d0ef60062809448074066f6b6a0f6619a8 Mon Sep 17 00:00:00 2001 From: westcott Date: Tue, 24 Feb 2009 18:24:50 +0000 Subject: [PATCH] changed unifrac.weighted() --- weighted.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/weighted.cpp b/weighted.cpp index a0d2f5e..c43180d 100644 --- a/weighted.cpp +++ b/weighted.cpp @@ -26,17 +26,18 @@ EstOutput Weighted::getValues(Tree* t) { //calculate number of comparisons i.e. with groups A,B,C = AB, AC, BC = 3; int n = 1; + int count = 0; for (int i=1; iGroups.size() == 0) { WScore[tmap->namesOfGroups[i-1]+tmap->namesOfGroups[l]] = 0.0; - D.push_back(0.0000); //initialize a spot in D for each combination }else { WScore[globaldata->Groups[i-1]+globaldata->Groups[l]] = 0.0; - D.push_back(0.0000); //initialize a spot in D for each combination } + D.push_back(0.0000); //initialize a spot in D for each combination + /********************************************************/ //calculate a D value for each group combo for(int v=0;vgetNumLeaves();v++){ @@ -64,7 +65,7 @@ EstOutput Weighted::getValues(Tree* t) { //is this sum from a sequence which is in this groupCombo if ((t->tree[v].getGroup() == tmap->namesOfGroups[i-1]) || (t->tree[v].getGroup() == tmap->namesOfGroups[l])) { sum /= (double)tmap->seqsPerGroup[t->tree[v].getGroup()]; - D[n-1] += sum; + D[count] += sum; } } }else { @@ -73,16 +74,17 @@ EstOutput Weighted::getValues(Tree* t) { //is this sum from a sequence which is in this groupCombo if ((t->tree[v].getGroup() == globaldata->Groups[i-1]) || (t->tree[v].getGroup() == globaldata->Groups[l])) { sum /= (double)tmap->seqsPerGroup[t->tree[v].getGroup()]; - D[n-1] += sum; + D[count] += sum; } } } } /*********************************************************/ + count++; } + n++; } - data.clear(); //clear out old values for(int i=0;igetNumNodes();i++){ @@ -143,22 +145,21 @@ EstOutput Weighted::getValues(Tree* t) { //calculate weighted score for each group combination double UN; n = 1; + count = 0; for (int i=1; iGroups.size() == 0) { - UN = (WScore[tmap->namesOfGroups[i-1]+tmap->namesOfGroups[l]] / D[n-1]); -cout << "W score = " << WScore[tmap->namesOfGroups[i-1]+tmap->namesOfGroups[l]] << endl; + UN = (WScore[tmap->namesOfGroups[i-1]+tmap->namesOfGroups[l]] / D[count]); }else {//they have entered specific groups - UN = (WScore[globaldata->Groups[i-1]+globaldata->Groups[l]] / D[n-1]); -cout << "W score = " << WScore[globaldata->Groups[i-1]+globaldata->Groups[l]] << endl; + UN = (WScore[globaldata->Groups[i-1]+globaldata->Groups[l]] / D[count]); } -cout << " D = "<< D[n-1] << endl; if (isnan(UN) || isinf(UN)) { UN = 0; } data.push_back(UN); + count++; } + n++; } - return data; } catch(exception& e) { -- 2.39.5