X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=unifracunweightedcommand.cpp;h=75ab99682974b3152d3c5020130855788ef5f151;hb=485c02be0cdcd06ce08dd58d551a525b6a1b47c5;hp=6fd986fc6022d6642179d58ed3b497c4f2166439;hpb=a85da7303079652b569291eacb9c2964060e072b;p=mothur.git diff --git a/unifracunweightedcommand.cpp b/unifracunweightedcommand.cpp index 6fd986f..75ab996 100644 --- a/unifracunweightedcommand.cpp +++ b/unifracunweightedcommand.cpp @@ -40,20 +40,19 @@ int UnifracUnweightedCommand::execute() { userData.resize(numComp,0); //data[0] = unweightedscore randomData.resize(numComp,0); //data[0] = unweightedscore //create new tree with same num nodes and leaves as users - + + outSum << "Tree#" << '\t' << "Groups" << '\t' << "UWScore" <<'\t' << "UWSig" << endl; + cout << "Tree#" << '\t' << "Groups" << '\t' << "UWScore" << '\t' << "UWSig" << endl; + //get pscores for users trees for (int i = 0; i < T.size(); i++) { counter = 0; unweightedFile = globaldata->getTreeFile() + toString(i+1) + ".unweighted"; unweightedFileout = globaldata->getTreeFile() + "temp." + toString(i+1) + ".unweighted"; - //column headers -// outSum << "Tree# " << i+1 << endl; - outSum << "Tree#" << '\t' << "Groups" << '\t' << "UWScore" <<'\t' << "UWSig" << endl; -// cout << "Tree# " << i+1 << endl; - cout << "Tree#" << '\t' << "Groups" << '\t' << "UWScore" << '\t' << "UWSig" << endl; - - + outSum << i+1 << '\t'; + cout << i+1 << '\t'; + //get unweighted for users tree rscoreFreq.resize(numComp); rCumul.resize(numComp); @@ -66,6 +65,7 @@ int UnifracUnweightedCommand::execute() { for(int k = 0; k < numComp; k++) { //saves users score utreeScores[k].push_back(userData[k]); + } //get unweighted scores for random trees @@ -165,15 +165,14 @@ void UnifracUnweightedCommand::printUWSummaryFile() { outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint); //print each line - for (int i = 0; i< T.size(); i++) { - for(int a = 0; a < numComp; a++) { - if (UWScoreSig[a][i] > (1/(float)iters)) { - outSum << setprecision(globaldata->getIters().length()) << i+1 << '\t' << groupComb[a] << '\t' << utreeScores[a][i] << '\t' << UWScoreSig[a][i] << endl; - cout << setprecision(globaldata->getIters().length()) << i+1 << '\t' << groupComb[a] << '\t' << utreeScores[a][i] << '\t' << UWScoreSig[a][i] << endl; - }else { - outSum << setprecision(globaldata->getIters().length()) << i+1 << '\t' << groupComb[a] << '\t' << utreeScores[a][i] << '\t' << "<" << (1/float(iters)) << endl; - cout << setprecision(globaldata->getIters().length()) << i+1 << '\t' << groupComb[a] << '\t' << utreeScores[a][i] << '\t' << "<" << (1/float(iters)) << endl; - } + + for(int a = 0; a < numComp; a++) { + if (UWScoreSig[a][0] > (1/(float)iters)) { + outSum << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << UWScoreSig[a][0] << endl; + cout << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << UWScoreSig[a][0] << endl; + }else { + outSum << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << "<" << (1/float(iters)) << endl; + cout << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << "<" << (1/float(iters)) << endl; } } @@ -303,10 +302,10 @@ void UnifracUnweightedCommand::output(vector data){ getline(inFile, inputBuffer); // out << inputBuffer << setprecision(6) << '\t' << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << endl; - out << inputBuffer << setprecision(globaldata->getIters().length()-1) << '\t' << data[1] << '\t' << data[2] << endl; + out << inputBuffer << '\t' << setprecision(6) << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << endl; } else{ - out << setprecision(6) << data[0] << setprecision(globaldata->getIters().length()-1) << '\t' << data[1] << '\t' << data[2] << endl; + out << setprecision(6) << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << endl; } }