X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedutilities.cpp;h=71d7782cad87c7914c2d14071ec1cc657b2803d1;hb=e10c72304ee071c0c40e0218a06d89dc4731cbc2;hp=6dffee95e1c9a2e17bbda649424d0cb53402e513;hpb=257808d42702d889a85d0132abc6b8776fc57418;p=mothur.git diff --git a/sharedutilities.cpp b/sharedutilities.cpp index 6dffee9..71d7782 100644 --- a/sharedutilities.cpp +++ b/sharedutilities.cpp @@ -102,6 +102,10 @@ void SharedUtil::getSharedVectorswithReplacement(vector Groups, vector& userGroups, vector& allGroups) { try { + + sort(userGroups.begin(), userGroups.end()); + sort(allGroups.begin(), allGroups.end()); + if (userGroups.size() != 0) { if (userGroups[0] != "all") { //check that groups are valid @@ -116,7 +120,7 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups //if the user only entered invalid groups if (userGroups.size() == 0) { - m->mothurOut("You provided no valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine(); + m->mothurOut("You provided no valid groups. I will run the command using all the groups in your file."); m->mothurOutEndLine(); for (int i = 0; i < allGroups.size(); i++) { userGroups.push_back(allGroups[i]); } @@ -144,6 +148,10 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups //need to have mode because different commands require different number of valid groups void SharedUtil::setGroups(vector& userGroups, vector& allGroups, string mode) { try { + + sort(userGroups.begin(), userGroups.end()); + sort(allGroups.begin(), allGroups.end()); + if (userGroups.size() != 0) { if (userGroups[0] != "all") { //check that groups are valid @@ -190,6 +198,9 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups //for parsimony and unifrac commands you set pairwise groups as well as an allgroups in calc void SharedUtil::setGroups(vector& userGroups, vector& allGroups, string& label, int& numGroups, string mode){ //globaldata->Groups, your tree or group map, allgroups, mode try { + sort(userGroups.begin(), userGroups.end()); + sort(allGroups.begin(), allGroups.end()); + numGroups = 0; label = ""; @@ -271,13 +282,18 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups /**************************************************************************************/ void SharedUtil::getCombos(vector& groupComb, vector userGroups, int& numComp) { //groupcomb, globaldata->Groups, numcomb try { + sort(userGroups.begin(), userGroups.end()); //calculate number of comparisons i.e. with groups A,B,C = AB, AC, BC = 3; numComp = 0; for (int i=0; i< userGroups.size(); i++) { numComp += i; - for (int l = i+1; l < userGroups.size(); l++) { - //set group comparison labels - groupComb.push_back(userGroups[i] + "-" + userGroups[l]); + for (int l = 0; l < i; l++) { + if (userGroups[i] > userGroups[l]) { + //set group comparison labels + groupComb.push_back(userGroups[l] + "-" + userGroups[i]); + }else{ + groupComb.push_back(userGroups[i] + "-" + userGroups[l]); + } } } } @@ -314,3 +330,6 @@ void SharedUtil::updateGroupIndex(vector& userGroups, map& exit(1); } } +/**************************************************************************************/ + +