]> git.donarmstrong.com Git - mothur.git/blobdiff - parsimonycommand.cpp
fixed valid parameters to include shared parameter for read.shared command.
[mothur.git] / parsimonycommand.cpp
index 4529f777358ece0b03a6f53d522a54bd7698ac87..c7340c7b1704c585b70e2677c0701aaf7edb4e33 100644 (file)
@@ -28,8 +28,8 @@ ParsimonyCommand::ParsimonyCommand() {
                }else { //user wants random distribution
                        savetmap = globaldata->gTreemap;
                        getUserInput();
-                       parsFile = randomtree + ".rd_parsimony";
-                       openOutputFile(parsFile, out);
+                       parsFile = randomtree;
+                       parsFileout = globaldata->getTreeFile() + "temp";
                }
                
                //set users groups to analyze
@@ -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
@@ -227,7 +226,8 @@ void ParsimonyCommand::printParsimonyFile() {
 void ParsimonyCommand::printUSummaryFile() {
        try {
                //column headers
-               outSum << "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);
@@ -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(6) << i+1 << '\t' << groupComb[a] << '\t' << '\t' << userTreeScores[a][i] << '\t' << UScoreSig[a][i] << endl;
-                               cout << setprecision(6) << i+1 << '\t' << groupComb[a] << '\t' << '\t' << userTreeScores[a][i] << '\t' << UScoreSig[a][i] << endl;
+                               if (UScoreSig[a][i] > (1/(float)iters)) {
+                                       outSum << setprecision(6) << i+1 << '\t' << groupComb[a] << '\t' << '\t' << userTreeScores[a][i] << setprecision(globaldata->getIters().length()) << '\t' << UScoreSig[a][i] << endl;
+                                       cout << setprecision(6) << i+1 << '\t' << groupComb[a] << '\t' << '\t' << userTreeScores[a][i] << setprecision(globaldata->getIters().length()) << '\t' << UScoreSig[a][i] << endl;
+                               }else {
+                                       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;
+                               }
                        }
                }
                
@@ -324,26 +329,31 @@ 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
+                               globaldata->Groups.clear();
                                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 +361,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++;
                        }
                }
@@ -387,7 +397,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);
@@ -395,7 +405,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;
                        }
                }
 
@@ -421,16 +431,16 @@ void ParsimonyCommand::output(vector<double> data){
                        getline(inFile, inputBuffer);
                
                        if (randomtree == "") {
-                               out << inputBuffer << '\t' << setprecision(6) << 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(6) << 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(6) << 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(6) << 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;
                        }
                }