]> git.donarmstrong.com Git - mothur.git/blobdiff - unifracunweightedcommand.cpp
fixed bug in read.tree updates help and validparameters strings, added ability for...
[mothur.git] / unifracunweightedcommand.cpp
index dd1a3f9c236f9a86b022c99a3e6dd2d2109b1dfa..2b93df782bccc4d2dbc8533e7cdc38169059d6a7 100644 (file)
@@ -36,24 +36,23 @@ UnifracUnweightedCommand::UnifracUnweightedCommand() {
 /***********************************************************/
 int UnifracUnweightedCommand::execute() {
        try {
-       
+
                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
@@ -85,6 +85,7 @@ int UnifracUnweightedCommand::execute() {
                                        //add randoms score to validscores
                                        validScores[randomData[k]] = randomData[k];
                                }
+                               
                        }
                
                for(int a = 0; a < numComp; a++) {
@@ -101,6 +102,8 @@ int UnifracUnweightedCommand::execute() {
                        UWScoreSig[a].push_back(rCumul[a][userData[a]]);
                }
                
+               
+               
                printUnweightedFile();
                printUWSummaryFile();
                
@@ -168,11 +171,11 @@ void UnifracUnweightedCommand::printUWSummaryFile() {
 
                for(int a = 0; a < numComp; a++) {
                        if (UWScoreSig[a][0] > (1/(float)iters)) {
-                               outSum << setprecision(6) << groupComb[a] << '\t' << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << UWScoreSig[a][0] << endl;
-                               cout << setprecision(6)  << groupComb[a] << '\t' << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << UWScoreSig[a][0] << endl; 
+                               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' << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << "<" << (1/float(iters)) << endl;
-                               cout << setprecision(6)  << groupComb[a] << '\t' << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << "<" << (1/float(iters)) << endl; 
+                               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; 
                        }
                }
                
@@ -208,9 +211,11 @@ void UnifracUnweightedCommand::setGroups() {
                                if (globaldata->Groups.size() == 0) { 
                                        cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using all the groups in your groupfile." << endl; 
                                        for (int i = 0; i < tmap->namesOfGroups.size(); i++) {
-                                               globaldata->Groups.push_back(tmap->namesOfGroups[i]);
-                                               numGroups++;
-                                               allGroups += tmap->namesOfGroups[i] + "-";
+                                               if (tmap->namesOfGroups[i] != "xxx") {
+                                                       globaldata->Groups.push_back(tmap->namesOfGroups[i]);
+                                                       numGroups++;
+                                                       allGroups += tmap->namesOfGroups[i] + "-";
+                                               }
                                        }
                                        allGroups = allGroups.substr(0, allGroups.length()-1);
                                }else {
@@ -223,16 +228,20 @@ void UnifracUnweightedCommand::setGroups() {
                        }else{//user has enter "all" and wants the default groups
                                globaldata->Groups.clear();
                                for (int i = 0; i < tmap->namesOfGroups.size(); i++) {
-                                       globaldata->Groups.push_back(tmap->namesOfGroups[i]);
-                                       numGroups++;
-                                       allGroups += tmap->namesOfGroups[i] + "-";
+                                       if (tmap->namesOfGroups[i] != "xxx") {
+                                               globaldata->Groups.push_back(tmap->namesOfGroups[i]);
+                                               numGroups++;
+                                               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] + "-";
+                               if (tmap->namesOfGroups[i] != "xxx") {
+                                       allGroups += tmap->namesOfGroups[i] + "-";
+                               }
                        }
                        allGroups = allGroups.substr(0, allGroups.length()-1);
                        numGroups = 1;