X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=collect.cpp;h=1c8128aef4ba42ec11fc2a7edbaa8cd42aa97ced;hb=addc715b6d7ea52440751cec10edad03e1a19b37;hp=2ed5ca7f10eeefdb860ae9fc7b5859b5eb239c0e;hpb=70ac1dc59244e259b1a972385d490d2ac7f511c0;p=mothur.git diff --git a/collect.cpp b/collect.cpp index 2ed5ca7..1c8128a 100644 --- a/collect.cpp +++ b/collect.cpp @@ -64,7 +64,8 @@ void Collect::getSharedCurve(int increment = 1){ try { globaldata = GlobalData::getInstance(); vector lookup; - + vector chosenGroups = globaldata->sharedGroups; + //create and initialize vector of sharedvectors, one for each group for (int i = 0; i < globaldata->gGroupmap->getNumGroups(); i++) { SharedRAbundVector* temp = new SharedRAbundVector(sharedorder->getNumBins()); @@ -78,7 +79,7 @@ try { //initialize labels for output //makes 'uniqueAB uniqueAC uniqueBC' if your groups are A, B, C - getGroupComb(); + getGroupComb(chosenGroups); groupLabel = ""; for (int s = 0; s < groupComb.size(); s++) { groupLabel = groupLabel + label + groupComb[s] + "\t"; @@ -94,7 +95,6 @@ try { //get first sample individual chosen = sharedorder->get(i); int abundance; - //set info for sharedvector in chosens group for (int j = 0; j < lookup.size(); j++) { if (chosen.group == lookup[j]->getGroup()) { @@ -103,7 +103,7 @@ try { break; } } - + //calculate at 0 and the given increment if((i == 0) || (i+1) % increment == 0){ //randomize group order @@ -116,8 +116,8 @@ try { } n++; } - } totalNumSeq = i+1; + } } //calculate last line if you haven't already @@ -150,7 +150,7 @@ try { /**************************************************************************************/ -void Collect::getGroupComb() { +void Collect::getGroupComb(vector chosen) { string group; numGroupComb = 0; @@ -158,13 +158,28 @@ void Collect::getGroupComb() { int n = 1; for (int i = 0; i < (globaldata->gGroupmap->getNumGroups() - 1); i++) { for (int l = n; l < globaldata->gGroupmap->getNumGroups(); l++) { - group = globaldata->gGroupmap->namesOfGroups[i] + globaldata->gGroupmap->namesOfGroups[l]; - groupComb.push_back(group); - numGroupComb++; + string g1 = globaldata->gGroupmap->namesOfGroups[i]; + string g2 = globaldata->gGroupmap->namesOfGroups[l]; + if(validGroup(chosen, g1) && validGroup(chosen, g2)) { + group = g1 + g2; + groupComb.push_back(group); + numGroupComb++; + } } n++; } - } /**************************************************************************************/ + +bool Collect::validGroup(vector chosen, string group) { + if(chosen.size() == 0) + return true; + for(int i = 0; i < chosen.size(); i++) + if(chosen.at(i).compare(group) == 0) + return true; + return false; +} + + +