]> git.donarmstrong.com Git - mothur.git/commitdiff
changed format of output in unifrac and parsimony files
authorwestcott <westcott>
Fri, 6 Mar 2009 13:37:09 +0000 (13:37 +0000)
committerwestcott <westcott>
Fri, 6 Mar 2009 13:37:09 +0000 (13:37 +0000)
parsimonycommand.cpp
unifracunweightedcommand.cpp
unifracweightedcommand.cpp

index ec1549a94530626a44d068408ad57d23da8c6c8e..474f732ef9b3c448e6bfe27753df7d59c4dec300 100644 (file)
@@ -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; r<numGroups; r++) { 
                        for (int l = r+1; l < numGroups; l++) {
-                               groupComb.push_back(globaldata->Groups[r]+globaldata->Groups[l]);
+                               groupComb.push_back(globaldata->Groups[r]+ "-" +globaldata->Groups[l]);
                                numComp++;
                        }
                }
index 3fa44b50014de39006037771bdc9899f0bc357f3..bebd43b7d5ed7c4d24a82a4d0a8f96e15aed908f 100644 (file)
@@ -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; r<numGroups; r++) { 
                        for (int l = r+1; l < numGroups; l++) {
-                               groupComb.push_back(globaldata->Groups[r]+globaldata->Groups[l]);
+                               groupComb.push_back(globaldata->Groups[r]+ "-" + globaldata->Groups[l]);
                                numComp++;
                        }
                }
@@ -288,10 +299,10 @@ void UnifracUnweightedCommand::output(vector<double> 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;
                }
 
        }
index 91e898f658556d840aab261995ba285c96d84f9d..6d8f75ba9dc3a4edeca6a4430937cc476b886090 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
@@ -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]);
                        }
                }
        }