X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedlistvector.cpp;fp=sharedlistvector.cpp;h=6cac9b1d9512a16d15eef553d351de0b16771b6e;hb=f5023c911c377e5320c5110c78af98dd8841ef58;hp=a113ebe7e82e93f135541b0bfa0ffc7a3b1d33b1;hpb=3c856e629e20261496b0433c2587f27b2c8ba3f6;p=mothur.git diff --git a/sharedlistvector.cpp b/sharedlistvector.cpp index a113ebe..6cac9b1 100644 --- a/sharedlistvector.cpp +++ b/sharedlistvector.cpp @@ -264,22 +264,23 @@ vector SharedListVector::getSharedRAbundVector() { SharedUtil* util; util = new SharedUtil(); vector lookup; + vector lookup2; map finder; + map::iterator it; string group, names, name; - + util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups); - delete util; - for (int i = 0; i < globaldata->Groups.size(); i++) { + for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { SharedRAbundVector* temp = new SharedRAbundVector(data.size()); - finder[globaldata->Groups[i]] = temp; - finder[globaldata->Groups[i]]->setLabel(label); - finder[globaldata->Groups[i]]->setGroup(globaldata->Groups[i]); + finder[globaldata->gGroupmap->namesOfGroups[i]] = temp; + finder[globaldata->gGroupmap->namesOfGroups[i]]->setLabel(label); + finder[globaldata->gGroupmap->namesOfGroups[i]]->setGroup(globaldata->gGroupmap->namesOfGroups[i]); //*temp = getSharedRAbundVector(globaldata->Groups[i]); - lookup.push_back(finder[globaldata->Groups[i]]); + lookup.push_back(finder[globaldata->gGroupmap->namesOfGroups[i]]); } - +//cout << "after blanks" << endl; //fill vectors for(int i=0;i SharedListVector::getSharedRAbundVector() { name = names.substr(0,names.find_first_of(',')); names = names.substr(names.find_first_of(',')+1, names.length()); group = groupmap->getGroup(name); +//cout << i << '\t' << name << '\t' << group << endl; if(group == "not found") { mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); mothurOutEndLine(); exit(1); } finder[group]->set(i, finder[group]->getAbundance(i) + 1, group); //i represents what bin you are in } //get last name group = groupmap->getGroup(names); +//cout << i << '\t' << names << '\t' << group << endl; if(group == "not found") { mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); mothurOutEndLine(); exit(1); } finder[group]->set(i, finder[group]->getAbundance(i) + 1, group); //i represents what bin you are in } - return lookup; + if (globaldata->Groups.size() == globaldata->gGroupmap->namesOfGroups.size()) { //no groups specified + lookup2 = lookup; + }else{ //delete unwanted groups + for (int i = 0; i < globaldata->Groups.size(); i++) { + SharedRAbundVector* temp = new SharedRAbundVector(*finder[globaldata->Groups[i]]); + lookup2.push_back(temp); + delete finder[globaldata->Groups[i]]; //so we don't get dup memory + } + } + + return lookup2; } catch(exception& e) { errorOut(e, "SharedListVector", "getSharedRAbundVector");