X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedlistvector.cpp;h=6dfcb97f0aff013d15c1c641e93a24b0d7b229a3;hb=49d2b7459c5027557564b21e9487dadafbbbdc96;hp=cc3cd8df4205e2f37182a8a80037bc02bb37ca45;hpb=74844a60d80c6dd06e3fb02ee9b928424f9019b0;p=mothur.git diff --git a/sharedlistvector.cpp b/sharedlistvector.cpp index cc3cd8d..6dfcb97 100644 --- a/sharedlistvector.cpp +++ b/sharedlistvector.cpp @@ -16,32 +16,30 @@ /***********************************************************************/ -SharedListVector::SharedListVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){globaldata = GlobalData::getInstance(); groupmap = NULL; } +SharedListVector::SharedListVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){ groupmap = NULL; } /***********************************************************************/ -SharedListVector::SharedListVector(int n): DataVector(), data(n, "") , maxRank(0), numBins(0), numSeqs(0){globaldata = GlobalData::getInstance(); groupmap = NULL; } +SharedListVector::SharedListVector(int n): DataVector(), data(n, "") , maxRank(0), numBins(0), numSeqs(0){ groupmap = NULL; } /***********************************************************************/ SharedListVector::SharedListVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) { try { - globaldata = GlobalData::getInstance(); - //set up groupmap for later. - groupmap = new GroupMap(globaldata->getGroupFile()); - groupmap->readMap(); + groupmap = new GroupMap(m->getGroupFile()); + groupmap->readMap(); int hold; string inputData; f >> label >> hold; data.assign(hold, ""); - + for(int i=0;i> inputData; set(i, inputData); } - + } catch(exception& e) { m->errorOut(e, "SharedListVector", "SharedListVector"); @@ -52,15 +50,17 @@ SharedListVector::SharedListVector(ifstream& f) : DataVector(), maxRank(0), numB /***********************************************************************/ void SharedListVector::set(int binNumber, string seqNames){ try { - int nNames_old = getNumNames(data[binNumber]); + int nNames_old = m->getNumNames(data[binNumber]); data[binNumber] = seqNames; - int nNames_new = getNumNames(seqNames); + int nNames_new = m->getNumNames(seqNames); if(nNames_old == 0) { numBins++; } if(nNames_new == 0) { numBins--; } if(nNames_new > maxRank) { maxRank = nNames_new; } numSeqs += (nNames_new - nNames_old); + + } catch(exception& e) { m->errorOut(e, "SharedListVector", "set"); @@ -79,7 +79,7 @@ string SharedListVector::get(int index){ void SharedListVector::push_back(string seqNames){ try { data.push_back(seqNames); - int nNames = getNumNames(seqNames); + int nNames = m->getNumNames(seqNames); numBins++; @@ -141,7 +141,7 @@ RAbundVector SharedListVector::getRAbundVector(){ RAbundVector rav; for(int i=0;igetNumNames(data[i]); rav.push_back(binSize); } @@ -171,7 +171,7 @@ SAbundVector SharedListVector::getSAbundVector(){ SAbundVector sav(maxRank+1); for(int i=0;igetNumNames(data[i]); sav.set(binSize, sav.get(binSize) + 1); } sav.set(0, 0); @@ -194,7 +194,7 @@ SharedOrderVector* SharedListVector::getSharedOrderVector(){ order->setLabel(label); for(int i=0;igetNumNames(get(i)); //find number of individual in given bin names = get(i); while (names.find_first_of(',') != -1) { name = names.substr(0,names.find_first_of(',')); @@ -266,38 +266,62 @@ vector SharedListVector::getSharedRAbundVector() { vector lookup; //contains just the groups the user selected map finder; //contains all groups in groupmap string group, names, name; - - util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups); + + vector Groups = m->getGroups(); + vector allGroups = groupmap->getNamesOfGroups(); + util->setGroups(Groups, allGroups); + m->setGroups(Groups); delete util; - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { + for (int i = 0; i < allGroups.size(); i++) { SharedRAbundVector* temp = new SharedRAbundVector(data.size()); - finder[globaldata->gGroupmap->namesOfGroups[i]] = temp; - finder[globaldata->gGroupmap->namesOfGroups[i]]->setLabel(label); - finder[globaldata->gGroupmap->namesOfGroups[i]]->setGroup(globaldata->gGroupmap->namesOfGroups[i]); - if (inVector(globaldata->gGroupmap->namesOfGroups[i], globaldata->Groups)) { //if this group is in user groups - lookup.push_back(finder[globaldata->gGroupmap->namesOfGroups[i]]); + finder[allGroups[i]] = temp; + finder[allGroups[i]]->setLabel(label); + finder[allGroups[i]]->setGroup(allGroups[i]); + if (m->inUsersGroups(allGroups[i], m->getGroups())) { //if this group is in user groups + lookup.push_back(finder[allGroups[i]]); } } //fill vectors for(int i=0;igetGroup(name); - if(group == "not found") { m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); } - finder[group]->set(i, finder[group]->getAbundance(i) + 1, group); //i represents what bin you are in + int nameLength = names.size(); + string seqName = ""; + + for(int j=0;jgetGroup(seqName); + if(group == "not found") { m->mothurOut("Error: Sequence '" + seqName + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); } + finder[group]->set(i, finder[group]->getAbundance(i) + 1, group); //i represents what bin you are in + + seqName = ""; + } + else{ + seqName += names[j]; + } } + group = groupmap->getGroup(seqName); + if(group == "not found") { m->mothurOut("Error: Sequence '" + seqName + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); } + finder[group]->set(i, finder[group]->getAbundance(i) + 1, group); //i represents what bin you are in + + + +// while (names.find_first_of(',') != -1) { +// name = names.substr(0,names.find_first_of(',')); +// names = names.substr(names.find_first_of(',')+1, names.length()); +// group = groupmap->getGroup(name); +// if(group == "not found") { m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->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); - if(group == "not found") { m->mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); } - finder[group]->set(i, finder[group]->getAbundance(i) + 1, group); //i represents what bin you are in +// group = groupmap->getGroup(names); +// if(group == "not found") { m->mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); } +// finder[group]->set(i, finder[group]->getAbundance(i) + 1, group); //i represents what bin you are in } - + return lookup; } catch(exception& e) { @@ -331,7 +355,7 @@ OrderVector SharedListVector::getOrderVector(map* orderMap = NULL){ OrderVector ov; for(int i=0;igetNumNames(data[i]); for(int j=0;j