else if (namefile == "not found") { namefile = ""; }
else { m->setNameFile(namefile); }
+ groupfile = validParameter.validFile(parameters, "group", true);
+ if (groupfile == "not open") { groupfile = ""; abort = true; }
+ else if (groupfile == "not found") { groupfile = ""; }
+ else { m->setGroupFile(groupfile); }
+
listfile = validParameter.validFile(parameters, "list", true);
if (listfile == "not open") { listfile = ""; abort = true; }
else if (listfile == "not found") { listfile = ""; }
if (groups == "not found") { groups = ""; }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
sharedfile = validParameter.validFile(parameters, "shared", true);
//make sure groups are valid
//takes care of user setting groupNames that are invalid or setting groups=all
SharedUtil* util = new SharedUtil();
- util->setGroups(Groups, groupMap->namesOfGroups);
+ vector<string> namesGroups = groupMap->getNamesOfGroups();
+ util->setGroups(Groups, namesGroups);
delete util;
//fill names with names of sequences that are from the groups we want to remove
//if this name is in the accnos file
if (names.count(name) == 0) {
wroteSomething = true;
-
- currSeq.printSequence(out);
- }else { removedCount++; }
+ currSeq.printSequence(out);
+ }else {
+ //if you are not in the accnos file check if you are a name that needs to be changed
+ map<string, string>::iterator it = uniqueToRedundant.find(name);
+ if (it != uniqueToRedundant.end()) {
+ wroteSomething = true;
+ currSeq.setName(it->second);
+ currSeq.printSequence(out);
+ }else { removedCount++; }
+ }
}
m->gobble(in);
}
vector<SharedRAbundVector*> lookup = tempInput->getSharedRAbundVectors();
//save m->Groups
- vector<string> allGroupsNames = m->namesOfGroups;
- vector<string> mothurOutGroups = m->Groups;
+ vector<string> allGroupsNames = m->getAllGroups();
+ vector<string> mothurOutGroups = m->getGroups();
vector<string> groupsToKeep;
for (int i = 0; i < allGroupsNames.size(); i++) {
- if (!m->inUsersGroups(allGroupsNames[i], m->Groups)) {
+ if (!m->inUsersGroups(allGroupsNames[i], m->getGroups())) {
groupsToKeep.push_back(allGroupsNames[i]);
}
}
- if (allGroupsNames.size() == groupsToKeep.size()) { m->mothurOut("Your file does not contain any groups you wish to remove."); m->mothurOutEndLine(); m->Groups = mothurOutGroups; delete tempInput; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } return 0; }
+ if (allGroupsNames.size() == groupsToKeep.size()) { m->mothurOut("Your file does not contain any groups you wish to remove."); m->mothurOutEndLine(); m->setGroups(mothurOutGroups); delete tempInput; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } return 0; }
//reset read
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
delete tempInput;
- m->Groups = groupsToKeep;
- m->namesOfGroups.clear();
+ m->setGroups(groupsToKeep);
+ m->clearAllGroups();
m->names.clear();
m->saveNextLabel = "";
m->printedHeaders = false;
}
- m->Groups = mothurOutGroups;
+ m->setGroups(mothurOutGroups);
if (wroteSomething == false) { m->mothurOut("Your file contains only the groups you wish to remove."); m->mothurOutEndLine(); }
//if that name is in the .accnos file, add it
if (names.count(name) == 0) { newNames += name + ","; }
- else { removedCount++; }
+ else {
+ //if you are not in the accnos file check if you are a name that needs to be changed
+ map<string, string>::iterator it = uniqueToRedundant.find(name);
+ if (it != uniqueToRedundant.end()) {
+ newNames += it->second + ",";
+ }else { removedCount++; }
+ }
}
//get last name
if (names.count(binnames) == 0) { newNames += binnames + ","; }
- else { removedCount++; }
+ else { //if you are not in the accnos file check if you are a name that needs to be changed
+ map<string, string>::iterator it = uniqueToRedundant.find(binnames);
+ if (it != uniqueToRedundant.end()) {
+ newNames += it->second + ",";
+ }else { removedCount++; }
+ }
//if there are names in this bin add to new list
if (newNames != "") {
//you know you have at least one valid second since first column is valid
for (int i = 0; i < validSecond.size()-1; i++) { out << validSecond[i] << ','; }
out << validSecond[validSecond.size()-1] << endl;
+ uniqueToRedundant[firstCol] = validSecond[0];
}
}
if (names.count(name) == 0) {
wroteSomething = true;
out << name << '\t' << tax << endl;
- }else { removedCount++; }
+ }else { //if you are not in the accnos file check if you are a name that needs to be changed
+ map<string, string>::iterator it = uniqueToRedundant.find(name);
+ if (it != uniqueToRedundant.end()) {
+ wroteSomething = true;
+ out << it->second << '\t' << tax << endl;
+ }else { removedCount++; } }
m->gobble(in);
}
}
in.close();
- m->Groups = Groups;
+ m->setGroups(Groups);
}
catch(exception& e) {