]> git.donarmstrong.com Git - mothur.git/blobdiff - unifracweightedcommand.cpp
fixed valid parameters to include shared parameter for read.shared command.
[mothur.git] / unifracweightedcommand.cpp
index 91e898f658556d840aab261995ba285c96d84f9d..2652f8f6de6cc1198e81112c2d7e3d88d417fad3 100644 (file)
@@ -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
@@ -165,8 +164,8 @@ void UnifracWeightedCommand::printWeightedFile() {
 void UnifracWeightedCommand::printWSummaryFile() {
        try {
                //column headers
-               outSum << "Tree#" << '\t' << "Groups" << '\t' << '\t' << "WScore" << '\t' << '\t' << "WSig" <<  endl;
-               cout << "Tree#" << '\t' << "Groups" << '\t' << '\t' << "WScore" << '\t' << '\t' << "WSig" <<  endl;
+               outSum << "Tree#" << '\t' << "Groups" << '\t' << "WScore" << '\t' << "WSig" <<  endl;
+               cout << "Tree#" << '\t' << "Groups" << '\t' << "WScore" << '\t' << "WSig" <<  endl;
                
                //format output
                outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint);
@@ -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(6) << i+1 << '\t' << '\t' << groupComb[j] << '\t' << '\t'  << utreeScores[count] << '\t' << setprecision(globaldata->getIters().length()) << WScoreSig[count] << endl; 
+                                       cout << setprecision(6) << i+1 << '\t' << '\t' << groupComb[j] << '\t' << '\t'  << utreeScores[count] << '\t' << setprecision(globaldata->getIters().length()) << WScoreSig[count] << endl; 
+                               }else{
+                                       outSum << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << setprecision(globaldata->getIters().length()) << "<" << (1/float(iters)) << endl; 
+                                       cout << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << setprecision(globaldata->getIters().length()) << "<" << (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]);
                        }
                }
        }
@@ -336,7 +340,7 @@ void UnifracWeightedCommand::initFile(string label){
                        string inputBuffer;
                        getline(inFile, inputBuffer);
                
-                       out     <<  inputBuffer << '\t' << label + "Score" << '\t' << label + "RandFreq" << '\t' << label + "RandCumul" << endl;                
+                       out     <<  inputBuffer << '\t' << label + "RandFreq" << '\t' << label + "RandCumul" << endl;           
                }else{
                        openOutputFile(weightedFileout, out);
                        out     << label + "Score" << '\t' << label + "RandFreq" << '\t' << label + "RandCumul" << endl;
@@ -362,13 +366,14 @@ void UnifracWeightedCommand::output(vector<double> data){
                if(counter != 0){               
                        string inputBuffer;
                        getline(inFile, inputBuffer);
-               
-                       out     <<  inputBuffer << setprecision(globaldata->getIters().length()) << '\t' << data[0] << '\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(globaldata->getIters().length()) << data[0] << '\t' << data[1] << '\t' << data[2] << endl;
-               }
+                       out << setprecision(6) << data[0] << setprecision(globaldata->getIters().length())  << '\t' << data[1] << '\t' << data[2] << endl;
 
+               }
+               
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the UnifracWeightedCommand class Function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";