From ed04a159be4f1fab2850fa4dd2f40bf51e94e974 Mon Sep 17 00:00:00 2001 From: westcott Date: Fri, 6 Mar 2009 13:37:09 +0000 Subject: [PATCH] changed format of output in unifrac and parsimony files --- parsimonycommand.cpp | 25 +++++++++++++++++-------- unifracunweightedcommand.cpp | 35 +++++++++++++++++++++++------------ unifracweightedcommand.cpp | 12 ++++++++---- 3 files changed, 48 insertions(+), 24 deletions(-) diff --git a/parsimonycommand.cpp b/parsimonycommand.cpp index ec1549a..474f732 100644 --- a/parsimonycommand.cpp +++ b/parsimonycommand.cpp @@ -65,7 +65,6 @@ int ParsimonyCommand::execute() { if (randomtree == "") { //get pscores for users trees for (int i = 0; i < T.size(); i++) { - cout << "Processing tree " << i+1 << endl; userData = pars->getValues(T[i]); //data = AB, AC, BC, ABC. //output scores for each combination @@ -228,6 +227,7 @@ void ParsimonyCommand::printUSummaryFile() { try { //column headers outSum << "Tree#" << '\t' << "Comb" << '\t' << "ParsScore" << '\t' << '\t' << "ParsSig" << endl; + cout << "Tree#" << '\t' << "Comb" << '\t' << "ParsScore" << '\t' << '\t' << "ParsSig" << endl; //format output outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint); @@ -236,8 +236,13 @@ void ParsimonyCommand::printUSummaryFile() { //print each line for (int i = 0; i< T.size(); i++) { for(int a = 0; a < numComp; a++) { - outSum << setprecision(globaldata->getIters().length()) << i+1 << '\t' << groupComb[a] << '\t' << '\t' << userTreeScores[a][i] << '\t' << UScoreSig[a][i] << endl; - cout << setprecision(globaldata->getIters().length()) << i+1 << '\t' << groupComb[a] << '\t' << '\t' << userTreeScores[a][i] << '\t' << UScoreSig[a][i] << endl; + if (UScoreSig[a][i] > (1/(float)iters)) { + outSum << setprecision(globaldata->getIters().length()) << i+1 << '\t' << groupComb[a] << '\t' << '\t' << userTreeScores[a][i] << '\t' << UScoreSig[a][i] << endl; + cout << setprecision(globaldata->getIters().length()) << i+1 << '\t' << groupComb[a] << '\t' << '\t' << userTreeScores[a][i] << '\t' << UScoreSig[a][i] << endl; + }else { + outSum << setprecision(globaldata->getIters().length()) << i+1 << '\t' << groupComb[a] << '\t' << '\t' << userTreeScores[a][i] << '\t' << "<" << (1/float(iters)) << endl; + cout << setprecision(globaldata->getIters().length()) << i+1 << '\t' << groupComb[a] << '\t' << '\t' << userTreeScores[a][i] << '\t' << "<" << (1/float(iters)) << endl; + } } } @@ -324,26 +329,30 @@ void ParsimonyCommand::setGroups() { for (int i = 0; i < tmap->namesOfGroups.size(); i++) { globaldata->Groups.push_back(tmap->namesOfGroups[i]); numGroups++; - allGroups += tmap->namesOfGroups[i]; + allGroups += tmap->namesOfGroups[i] + "-"; } + allGroups = allGroups.substr(0, allGroups.length()-1); }else { for (int i = 0; i < globaldata->Groups.size(); i++) { - allGroups += tmap->namesOfGroups[i]; + allGroups += globaldata->Groups[i] + "-"; numGroups++; } + allGroups = allGroups.substr(0, allGroups.length()-1); } }else{//user has enter "all" and wants the default groups for (int i = 0; i < tmap->namesOfGroups.size(); i++) { globaldata->Groups.push_back(tmap->namesOfGroups[i]); numGroups++; - allGroups += tmap->namesOfGroups[i]; + allGroups += tmap->namesOfGroups[i] + "-"; } + allGroups = allGroups.substr(0, allGroups.length()-1); globaldata->setGroups(""); } }else { for (int i = 0; i < tmap->namesOfGroups.size(); i++) { - allGroups += tmap->namesOfGroups[i]; + allGroups += tmap->namesOfGroups[i] + "-"; } + allGroups = allGroups.substr(0, allGroups.length()-1); numGroups = 1; } @@ -351,7 +360,7 @@ void ParsimonyCommand::setGroups() { numComp = 0; for (int r=0; rGroups[r]+globaldata->Groups[l]); + groupComb.push_back(globaldata->Groups[r]+ "-" +globaldata->Groups[l]); numComp++; } } diff --git a/unifracunweightedcommand.cpp b/unifracunweightedcommand.cpp index 3fa44b5..bebd43b 100644 --- a/unifracunweightedcommand.cpp +++ b/unifracunweightedcommand.cpp @@ -46,9 +46,13 @@ int UnifracUnweightedCommand::execute() { counter = 0; unweightedFile = globaldata->getTreeFile() + toString(i+1) + ".unweighted"; unweightedFileout = globaldata->getTreeFile() + "temp." + toString(i+1) + ".unweighted"; - //column headers + + //column headers outSum << "Tree# " << i+1 << endl; outSum << "Comb" << '\t' << "UWScore" << '\t' << '\t' << "UWSig" << endl; + cout << "Tree# " << i+1 << endl; + cout << "Comb" << '\t' << "UWScore" << '\t' << '\t' << "UWSig" << endl; + //get unweighted for users tree rscoreFreq.resize(numComp); @@ -56,7 +60,6 @@ int UnifracUnweightedCommand::execute() { utreeScores.resize(numComp); UWScoreSig.resize(numComp); - cout << "Processing tree " << i+1 << endl; userData = unweighted->getValues(T[i]); //userData[0] = unweightedscore //output scores for each combination @@ -71,7 +74,6 @@ int UnifracUnweightedCommand::execute() { randomData = unweighted->getValues(T[i], "", ""); for(int k = 0; k < numComp; k++) { -//cout << "iter " << j << " comp " << k << " = " << randomData[k] << endl; //add trees unweighted score to map of scores it2 = rscoreFreq[k].find(randomData[k]); if (it2 != rscoreFreq[k].end()) {//already have that score @@ -164,8 +166,13 @@ void UnifracUnweightedCommand::printUWSummaryFile() { //print each line for(int a = 0; a < numComp; a++) { - outSum << setprecision(6) << groupComb[a] << '\t' << '\t' << utreeScores[a][0] << '\t' << UWScoreSig[a][0] << endl; - cout << setprecision(6) << groupComb[a] << '\t' << '\t' << utreeScores[a][0] << '\t' << UWScoreSig[a][0] << endl; + if (UWScoreSig[a][0] > (1/(float)iters)) { + outSum << setprecision(globaldata->getIters().length()) << groupComb[a] << '\t' << '\t' << utreeScores[a][0] << '\t' << UWScoreSig[a][0] << endl; + cout << setprecision(globaldata->getIters().length()) << groupComb[a] << '\t' << '\t' << utreeScores[a][0] << '\t' << UWScoreSig[a][0] << endl; + }else { + outSum << setprecision(globaldata->getIters().length()) << groupComb[a] << '\t' << '\t' << utreeScores[a][0] << '\t' << "<" << (1/float(iters)) << endl; + cout << setprecision(globaldata->getIters().length()) << groupComb[a] << '\t' << '\t' << utreeScores[a][0] << '\t' << "<" << (1/float(iters)) << endl; + } } } @@ -202,26 +209,30 @@ void UnifracUnweightedCommand::setGroups() { for (int i = 0; i < tmap->namesOfGroups.size(); i++) { globaldata->Groups.push_back(tmap->namesOfGroups[i]); numGroups++; - allGroups += tmap->namesOfGroups[i]; + allGroups += tmap->namesOfGroups[i] + "-"; } + allGroups = allGroups.substr(0, allGroups.length()-1); }else { for (int i = 0; i < globaldata->Groups.size(); i++) { - allGroups += globaldata->Groups[i]; + allGroups += globaldata->Groups[i] + "-"; numGroups++; } + allGroups = allGroups.substr(0, allGroups.length()-1); } }else{//user has enter "all" and wants the default groups for (int i = 0; i < tmap->namesOfGroups.size(); i++) { globaldata->Groups.push_back(tmap->namesOfGroups[i]); numGroups++; - allGroups += tmap->namesOfGroups[i]; + allGroups += tmap->namesOfGroups[i] + "-"; } + allGroups = allGroups.substr(0, allGroups.length()-1); globaldata->setGroups(""); } }else { for (int i = 0; i < tmap->namesOfGroups.size(); i++) { - allGroups += tmap->namesOfGroups[i]; + allGroups += tmap->namesOfGroups[i] + "-"; } + allGroups = allGroups.substr(0, allGroups.length()-1); numGroups = 1; } @@ -229,7 +240,7 @@ void UnifracUnweightedCommand::setGroups() { numComp = 0; for (int r=0; rGroups[r]+globaldata->Groups[l]); + groupComb.push_back(globaldata->Groups[r]+ "-" + globaldata->Groups[l]); numComp++; } } @@ -288,10 +299,10 @@ void UnifracUnweightedCommand::output(vector data){ string inputBuffer; getline(inFile, inputBuffer); - out << inputBuffer << setprecision(6) << '\t' << data[0] << '\t' << data[1] << '\t' << data[2] << endl; + out << inputBuffer << setprecision(globaldata->getIters().length()) << '\t' << data[0] << '\t' << data[1] << '\t' << data[2] << endl; } else{ - out << setprecision(6) << data[0] << '\t' << data[1] << '\t' << data[2] << endl; + out << setprecision(globaldata->getIters().length()) << data[0] << '\t' << data[1] << '\t' << data[2] << endl; } } diff --git a/unifracweightedcommand.cpp b/unifracweightedcommand.cpp index 91e898f..6d8f75b 100644 --- a/unifracweightedcommand.cpp +++ b/unifracweightedcommand.cpp @@ -52,7 +52,6 @@ int UnifracWeightedCommand::execute() { weightedFile = globaldata->getTreeFile() + toString(i+1) + ".weighted"; weightedFileout = globaldata->getTreeFile() + "temp." + toString(i+1) + ".weighted"; - cout << "Processing tree " << i+1 << endl; userData = weighted->getValues(T[i]); //userData[0] = weightedscore //save users score @@ -175,8 +174,13 @@ void UnifracWeightedCommand::printWSummaryFile() { int count = 0; for (int i = 0; i < T.size(); i++) { for (int j = 0; j < numComp; j++) { - outSum << setprecision(globaldata->getIters().length()) << i+1 << '\t' << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << WScoreSig[count] << endl; - cout << setprecision(globaldata->getIters().length()) << i+1 << '\t' << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << WScoreSig[count] << endl; + if (WScoreSig[count] > (1/(float)iters)) { + outSum << setprecision(globaldata->getIters().length()) << i+1 << '\t' << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << WScoreSig[count] << endl; + cout << setprecision(globaldata->getIters().length()) << i+1 << '\t' << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << WScoreSig[count] << endl; + }else{ + outSum << setprecision(globaldata->getIters().length()) << i+1 << '\t' << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << "<" << (1/float(iters)) << endl; + cout << setprecision(globaldata->getIters().length()) << i+1 << '\t' << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << "<" << (1/float(iters)) << endl; + } count++; } } @@ -261,7 +265,7 @@ void UnifracWeightedCommand::setGroups() { numComp += i; for (int l = i+1; l < numGroups; l++) { //set group comparison labels - groupComb.push_back(globaldata->Groups[i]+globaldata->Groups[l]); + groupComb.push_back(globaldata->Groups[i] + "-" + globaldata->Groups[l]); } } } -- 2.39.2