/***********************************************************************/
-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<hold;i++){
f >> inputData;
set(i, inputData);
}
-
+
}
catch(exception& e) {
m->errorOut(e, "SharedListVector", "SharedListVector");
if(nNames_new > maxRank) { maxRank = nNames_new; }
numSeqs += (nNames_new - nNames_old);
+
+
}
catch(exception& e) {
m->errorOut(e, "SharedListVector", "set");
vector<SharedRAbundVector*> lookup; //contains just the groups the user selected
map<string, SharedRAbundVector*> finder; //contains all groups in groupmap
string group, names, name;
-
- util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups);
+
+ vector<string> Groups = m->getGroups();
+ vector<string> 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 (m->inUsersGroups(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;i<numBins;i++){
names = get(i);
- 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
+ int nameLength = names.size();
+ string seqName = "";
+
+ for(int j=0;j<nameLength;j++){
+ if(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
+
+ 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) {