//**********************************************************************************************************************
vector<string> RemoveGroupsCommand::setParameters(){
try {
- CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
- CommandParameter pshared("shared", "InputTypes", "", "", "none", "FNGLT-sharedGroup", "none",false,false); parameters.push_back(pshared);
- CommandParameter pname("name", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pname);
- CommandParameter pgroup("group", "InputTypes", "", "", "none", "FNGLT-sharedGroup", "none",false,false); parameters.push_back(pgroup);
- CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(plist);
- CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(ptaxonomy);
+ CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "FNGLT",false,false); parameters.push_back(pfasta);
+ CommandParameter pshared("shared", "InputTypes", "", "", "none", "sharedGroup", "none",false,false); parameters.push_back(pshared);
+ CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
+ CommandParameter pgroup("group", "InputTypes", "", "", "none", "sharedGroup", "FNGLT",false,false); parameters.push_back(pgroup);
+ CommandParameter plist("list", "InputTypes", "", "", "none", "none", "FNGLT",false,false); parameters.push_back(plist);
+ CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "FNGLT",false,false); parameters.push_back(ptaxonomy);
CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
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 ((fastafile == "") && (namefile == "") && (groupfile == "") && (sharedfile == "") && (listfile == "") && (taxfile == "")) { m->mothurOut("You must provide at least one of the following: fasta, name, taxonomy, group, shared or list."); m->mothurOutEndLine(); abort = true; }
if ((groupfile == "") && ((namefile != "") || (fastafile != "") || (listfile != "") || (taxfile != ""))) { m->mothurOut("If using a fasta, name, taxonomy, group or list, then you must provide a group file."); m->mothurOutEndLine(); abort = true; }
+
+ if ((namefile == "") && ((fastafile != "") || (taxfile != ""))){
+ vector<string> files; files.push_back(fastafile); files.push_back(taxfile);
+ parser.getNameFile(files);
+ }
+
}
}
//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);
}
//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);
}