From: westcott Date: Wed, 23 Feb 2011 13:34:08 +0000 (+0000) Subject: fixed bug in unifrac commands with unrooted trees X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=commitdiff_plain;h=5334a314651228c55fd0f206dec0209bc3148b24 fixed bug in unifrac commands with unrooted trees --- diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index 902e927..e479725 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -1625,7 +1625,7 @@ attributes = { ORGANIZATIONNAME = "Schloss Lab"; }; - buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "Mothur" */; + buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "mothur" */; compatibilityVersion = "Xcode 3.1"; developmentRegion = English; hasScannedForEncodings = 1; @@ -2048,7 +2048,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "Mothur" */ = { + 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "mothur" */ = { isa = XCConfigurationList; buildConfigurations = ( 1DEB928A08733DD80010E9CD /* Debug */, diff --git a/trimseqscommand.cpp b/trimseqscommand.cpp index 53bdc7e..dd5bf34 100644 --- a/trimseqscommand.cpp +++ b/trimseqscommand.cpp @@ -349,7 +349,7 @@ int TrimSeqsCommand::execute(){ createProcessesCreateTrim(fastaFile, qFileName, trimSeqFile, scrapSeqFile, trimQualFile, scrapQualFile, outputGroupFileName, fastaFileNames, qualFileNames); } #else - driverCreateTrim(fastaFile, qFileName, trimSeqFile, scrapSeqFile, trimQualFile, scrapQualFile, outputGroupFile, fastaFileNames, qualFileNames, lines[0], qLines[0]); + driverCreateTrim(fastaFile, qFileName, trimSeqFile, scrapSeqFile, trimQualFile, scrapQualFile, outputGroupFileName, fastaFileNames, qualFileNames, lines[0], qLines[0]); #endif if (m->control_pressed) { return 0; } diff --git a/unweighted.cpp b/unweighted.cpp index ea66294..fb2f0b2 100644 --- a/unweighted.cpp +++ b/unweighted.cpp @@ -232,7 +232,11 @@ EstOutput Unweighted::driver(Tree* t, vector< vector > namesOfGroupCombo } }else if ((nodePcountSize[lc] == 0) && (nodePcountSize[rc] == 0)) { tempTotals[i] = 0.0; //we don't care about you }else { //if no, your tempTotal is your childrens temp totals + your branch length - tempTotals[i] = tempTotals[lc] + tempTotals[rc] + abs(t->tree[i].getBranchLength()); + if (t->tree[i].getBranchLength() != -1) { + tempTotals[i] = tempTotals[lc] + tempTotals[rc] + abs(t->tree[i].getBranchLength()); + }else { + tempTotals[i] = tempTotals[lc] + tempTotals[rc]; + } } //cout << "temptotal = "<< tempTotals[i] << endl; } @@ -482,7 +486,11 @@ EstOutput Unweighted::driver(Tree* t, vector< vector > namesOfGroupCombo } }else if ((nodePcountSize[lc] == 0) && (nodePcountSize[rc] == 0)) { tempTotals[i] = 0.0; //we don't care about you }else { //if no, your tempTotal is your childrens temp totals + your branch length - tempTotals[i] = tempTotals[lc] + tempTotals[rc] + abs(copyTree->tree[i].getBranchLength()); + if (t->tree[i].getBranchLength() != -1) { + tempTotals[i] = tempTotals[lc] + tempTotals[rc] + abs(copyTree->tree[i].getBranchLength()); + }else { + tempTotals[i] = tempTotals[lc] + tempTotals[rc]; + } } } diff --git a/weighted.cpp b/weighted.cpp index 30e4a76..a0d593c 100644 --- a/weighted.cpp +++ b/weighted.cpp @@ -231,10 +231,13 @@ EstOutput Weighted::driver(Tree* t, vector< vector > namesOfGroupCombos, //if this is not the root then add it if (rootForGrouping[namesOfGroupCombos[h]].count(i) == 0) { - u = abs(u * t->tree[i].getBranchLength()); - WScore[(groupA+groupB)] += u; + if (t->tree[i].getBranchLength() != -1) { + u = abs(u * t->tree[i].getBranchLength()); + WScore[(groupA+groupB)] += u; + } } + } } @@ -244,7 +247,6 @@ EstOutput Weighted::driver(Tree* t, vector< vector > namesOfGroupCombos, count = 0; for (int h = start; h < (start+num); h++) { UN = (WScore[namesOfGroupCombos[h][0]+namesOfGroupCombos[h][1]] / D[count]); - if (isnan(UN) || isinf(UN)) { UN = 0; } results.push_back(UN); count++; @@ -319,12 +321,14 @@ EstOutput Weighted::getValues(Tree* t, string groupA, string groupB) { //if this is not the root then add it if (rootForGrouping[groups].count(i) == 0) { - u = abs(u * t->tree[i].getBranchLength()); - WScore[(groupA+groupB)] += u; + if (t->tree[i].getBranchLength() != -1) { + u = abs(u * t->tree[i].getBranchLength()); + WScore[(groupA+groupB)] += u; + } } } /********************************************************/ - + //calculate weighted score for the group combination double UN; UN = (WScore[(groupA+groupB)] / D);