]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed bug with parsimony(groups=all) and unifrac.unweighted(groups=all)
authorwestcott <westcott>
Tue, 21 Apr 2009 13:33:41 +0000 (13:33 +0000)
committerwestcott <westcott>
Tue, 21 Apr 2009 13:33:41 +0000 (13:33 +0000)
parsimonycommand.cpp
sharedutilities.cpp
unifracunweightedcommand.cpp
unifracunweightedcommand.h

index b5c59e87104cb7d413ca4984fee751fbe8707ba4..56305e2260d4af19050dfc0832add36c1208d13e 100644 (file)
@@ -36,12 +36,8 @@ ParsimonyCommand::ParsimonyCommand() {
                util->getCombos(groupComb, globaldata->Groups, numComp);
                globaldata->setGroups("");
                
-               //ABC
-               if (numComp != 1) {
-                       groupComb.push_back(allGroups);
-                       numComp++;
-               }
-
+               if (numGroups == 1) { numComp++; groupComb.push_back(allGroups); }
+               
                convert(globaldata->getIters(), iters);  //how many random trees to generate
                pars = new Parsimony(tmap);
                counter = 0;
index edd16c7cdee387c1c83f50471d6caf025c8352ec..454b7d4073396f74c804ad1bba68cbea57ac5f57 100644 (file)
@@ -211,24 +211,24 @@ void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups
                                for (int i=0; i < allGroups.size(); i++) { 
                                        if (allGroups[i] != "xxx") {
                                                userGroups.push_back(allGroups[i]);
-                                               label += allGroups[i] + "-";
                                        }
                                }
                        }
                }else { //the user has not entered groups
                        for (int i=0; i < allGroups.size(); i++) { 
                                if (allGroups[i] != "xxx") {
-                                       label += allGroups[i] + "-";
                                        if (mode == "weighted") {
                                                userGroups.push_back(allGroups[i]);
                                        }else {
                                                numGroups = 1;
+                                               label += allGroups[i] + "-";
                                        }
                                }
                        }
+                       //rip extra - off allgroups 
+                       label = label.substr(0, label.length()-1);
                }
                
-               
                if (mode == "weighted") {
                        //if the user only entered invalid groups
                        if (userGroups.size() == 0) { 
@@ -256,20 +256,11 @@ void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups
                                        for (int i = 0; i < allGroups.size(); i++) {
                                                if (allGroups[i] != "xxx") {
                                                        userGroups.push_back(allGroups[i]);
-                                                       label += allGroups[i] + "-";
                                                }
                                        }
-                               }else {
-                                       for (int i = 0; i < userGroups.size(); i++) {
-                                               label += userGroups[i] + "-";
-                                       }
                                }
                                
-                               //rip extra - off allgroups 
-                               label = label.substr(0, label.length()-1);
-                               
                                if (numGroups != 1) { numGroups = userGroups.size(); }
-               
                }
        }
        catch(exception& e) {
index a9b46bfc90154f48106a76bea85acd4729080070..fcff253fc4812bafea60669dcb07c301dfa8de62 100644 (file)
@@ -24,13 +24,8 @@ UnifracUnweightedCommand::UnifracUnweightedCommand() {
                util->getCombos(groupComb, globaldata->Groups, numComp);
                globaldata->setGroups("");
                
-               //ABC
-               if (numComp != 1) {
-                       groupComb.push_back(allGroups);
-                       numComp++;
-               }
-
-               
+               if (numGroups == 1) { numComp++; groupComb.push_back(allGroups); }
+                               
                convert(globaldata->getIters(), iters);  //how many random trees to generate
                unweighted = new Unweighted(tmap);
 
@@ -61,9 +56,6 @@ int UnifracUnweightedCommand::execute() {
                        
                        output = new ColumnFile(globaldata->getTreeFile()  + toString(i+1) + ".unweighted");
                        
-                       outSum << i+1 << '\t';
-                       cout << i+1 << '\t';
-                       
                        //get unweighted for users tree
                        rscoreFreq.resize(numComp);  
                        rCumul.resize(numComp);  
@@ -116,7 +108,7 @@ int UnifracUnweightedCommand::execute() {
                
                
                        printUnweightedFile();
-                       printUWSummaryFile();
+                       printUWSummaryFile(i);
                        
                        delete output;
                        rscoreFreq.clear(); 
@@ -171,7 +163,7 @@ void UnifracUnweightedCommand::printUnweightedFile() {
 }
 
 /***********************************************************/
-void UnifracUnweightedCommand::printUWSummaryFile() {
+void UnifracUnweightedCommand::printUWSummaryFile(int i) {
        try {
                                
                //format output
@@ -180,6 +172,9 @@ void UnifracUnweightedCommand::printUWSummaryFile() {
                //print each line
 
                for(int a = 0; a < numComp; a++) {
+                       outSum << i+1 << '\t';
+                       cout << i+1 << '\t';
+                       
                        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; 
index d9991e81ce3ddee08a4afc8fae19d78ce89f794e..e900af4f8b0cc434bf16fae2f15535779032f901 100644 (file)
@@ -51,7 +51,7 @@ class UnifracUnweightedCommand : public Command {
                ofstream outSum, out;
                ifstream inFile;
                
-               void printUWSummaryFile();
+               void printUWSummaryFile(int);
                void printUnweightedFile();