]> git.donarmstrong.com Git - mothur.git/blobdiff - parsimonycommand.cpp
put back no command and worked on libshuff
[mothur.git] / parsimonycommand.cpp
index 633ddad982df6be8931b463dfe6d6c2e1b0cd8ef..493af9b867e5542ee4c4c93acfa6c40a9c95fc5a 100644 (file)
@@ -28,8 +28,8 @@ ParsimonyCommand::ParsimonyCommand() {
                }else { //user wants random distribution
                        savetmap = globaldata->gTreemap;
                        getUserInput();
-                       parsFile = randomtree + ".rd_parsimony";
-                       parsFileout = globaldata->getTreeFile() + "temp" + ".rd_parsimony";
+                       parsFile = randomtree;
+                       parsFileout = globaldata->getTreeFile() + "temp";
                }
                
                //set users groups to analyze
@@ -166,7 +166,11 @@ int ParsimonyCommand::execute() {
                if (randomtree == "") { printUSummaryFile(); }
                
                //reset globaldata's treemap if you just did random distrib
-               if (randomtree != "") { globaldata->gTreemap = savetmap; }
+               if (randomtree != "") {
+                       //memory leak prevention
+                       //if (globaldata->gTreemap != NULL) { delete globaldata->gTreemap;  }
+                       globaldata->gTreemap = savetmap;
+               }
                
                //reset randomTree parameter to ""
                globaldata->setRandomTree("");
@@ -226,8 +230,8 @@ void ParsimonyCommand::printParsimonyFile() {
 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;
+               outSum << "Tree#" << '\t' << "Groups" << '\t'  <<  "ParsScore" << '\t' << "ParsSig" <<  endl;
+               cout << "Tree#" << '\t' << "Groups" << '\t'  <<  "ParsScore" << '\t' << "ParsSig" <<  endl;
                
                //format output
                outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint);
@@ -237,11 +241,11 @@ void ParsimonyCommand::printUSummaryFile() {
                for (int i = 0; i< T.size(); i++) {
                        for(int a = 0; a < numComp; a++) {
                                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;
+                                       outSum << setprecision(6) << i+1 << '\t' << groupComb[a]  << '\t' << userTreeScores[a][i] << setprecision(globaldata->getIters().length()) << '\t' << UScoreSig[a][i] << endl;
+                                       cout << setprecision(6) << i+1 << '\t' << groupComb[a]  << '\t' << userTreeScores[a][i] << setprecision(globaldata->getIters().length()) << '\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;
+                                       outSum << setprecision(6) << i+1 << '\t' << groupComb[a] << '\t' << userTreeScores[a][i] << setprecision(globaldata->getIters().length())  << '\t' << "<" << (1/float(iters)) << endl;
+                                       cout << setprecision(6) << i+1 << '\t' << groupComb[a] << '\t' << userTreeScores[a][i] << setprecision(globaldata->getIters().length()) << '\t' << "<" << (1/float(iters)) << endl;
                                }
                        }
                }
@@ -293,6 +297,8 @@ void ParsimonyCommand::getUserInput() {
                getline(cin, s);
                
                //save tmap for later
+               //memory leak prevention
+               //if (globaldata->gTreemap != NULL) { delete globaldata->gTreemap;  }
                globaldata->gTreemap = tmap;
                
        }
@@ -397,7 +403,7 @@ void ParsimonyCommand::initFile(string label){
                        if (randomtree == "") {
                                out <<  inputBuffer << '\t' << label + "Score" << '\t' << label + "UserFreq" << '\t' << label + "UserCumul" << '\t' << label + "RandFreq" << '\t' << label + "RandCumul" << endl;
                        }else {
-                               out <<  inputBuffer << '\t' << label + "Score" << '\t' << label + "RandFreq" << '\t' << label + "RandCumul" << endl;
+                               out <<  inputBuffer << '\t' << "Score" << '\t' << "RandFreq" << '\t' << "RandCumul" << endl;
                        }
                }else{
                        openOutputFile(parsFileout, out);
@@ -405,7 +411,7 @@ void ParsimonyCommand::initFile(string label){
                        if (randomtree == "") {
                                out << label + "Score" << '\t' << label + "UserFreq" << '\t' << label + "UserCumul" << '\t' << label + "RandFreq" << '\t' << label + "RandCumul" << endl;
                        }else {
-                               out << label + "Score" << '\t' << label + "RandFreq" << '\t' << label + "RandCumul" << endl;
+                               out << "Score" << '\t' << "RandFreq" << '\t' << "RandCumul" << endl;
                        }
                }
 
@@ -431,16 +437,16 @@ void ParsimonyCommand::output(vector<double> data){
                        getline(inFile, inputBuffer);
                
                        if (randomtree == "") {
-                               out << inputBuffer << '\t' << setprecision(globaldata->getIters().length()) << data[0] << '\t' << data[1] << '\t' << data[2] << '\t' << data[3] << '\t' << data[4] << endl;
+                               out << inputBuffer << '\t' << setprecision(6) << data[0] << setprecision(globaldata->getIters().length())  << '\t' << data[1] << '\t' << data[2] << '\t' << data[3] << '\t' << data[4] << endl;
                        }else{
-                               out << inputBuffer << '\t' << setprecision(globaldata->getIters().length()) << 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{
                        if (randomtree == "") {
-                               out << setprecision(globaldata->getIters().length()) << data[0] << '\t' << data[1] << '\t' << data[2] << '\t' << data[3] << '\t' << data[4] << endl;
+                               out << setprecision(6) << data[0] << setprecision(globaldata->getIters().length())  << '\t' << data[1] << '\t' << data[2] << '\t' << data[3] << '\t' << data[4] << 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;
                        }
                }