string CountGroupsCommand::getHelpString(){
try {
string helpString = "";
- helpString += "The count.groups command counts sequences from a specfic group or set of groups from the following file types: group or shared file.\n";
+ helpString += "The count.groups command counts sequences from a specific group or set of groups from the following file types: group or shared file.\n";
helpString += "The count.groups command parameters are accnos, group, shared and groups. You must provide a group or shared file.\n";
helpString += "The accnos parameter allows you to provide a file containing the list of groups.\n";
helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like. You can separate group names with dashes.\n";
else if (namefile == "not found") { namefile = ""; }
else { m->setNameFile(namefile); }
+ groupfile = validParameter.validFile(parameters, "group", true);
+ if (groupfile == "not open") { abort = true; }
+ else if (groupfile == "not found") {
+ //if there is a current group file, use it
+ groupfile = m->getGroupFile();
+ if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
+ else { m->mothurOut("You have no current groupfile and the group parameter is required."); m->mothurOutEndLine(); abort = true; }
+ }else { m->setGroupFile(groupfile); }
+
listfile = validParameter.validFile(parameters, "list", true);
if (listfile == "not open") { abort = true; }
else if (listfile == "not found") { listfile = ""; }
else if (namefile == "not found") { namefile = ""; }
else { m->setNameFile(namefile); }
+ groupfile = validParameter.validFile(parameters, "group", true);
+ if (groupfile == "not open") { abort = true; }
+ else if (groupfile == "not found") {
+ //if there is a current group file, use it
+ groupfile = m->getGroupFile();
+ if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
+ else { m->mothurOut("You have no current groupfile and the group parameter is required."); m->mothurOutEndLine(); abort = true; }
+ }else { m->setGroupFile(groupfile); }
+
listfile = validParameter.validFile(parameters, "list", true);
if (listfile == "not open") { listfile = ""; abort = true; }
else if (listfile == "not found") { listfile = ""; }
}
else if (queryFileName == "not open") { abort = true; }
else { m->setFastaFile(queryFileName); }
-
+
+ referenceFileName = validParameter.validFile(parameters, "reference", true);
+ if (referenceFileName == "not found") { m->mothurOut("reference is a required parameter for the seq.error command."); m->mothurOutEndLine(); abort = true; }
+ else if (referenceFileName == "not open") { abort = true; }
+
//check for optional parameters
namesFileName = validParameter.validFile(parameters, "name", true);
if(namesFileName == "not found"){ namesFileName = ""; }
if (persample) {
//initialize counts
map<string, int> groupCounts;
+ map<string, int>::iterator itGroupCounts;
for (int i = 0; i < Groups.size(); i++) { groupCounts[Groups[i]] = 0; }
for (int j = 0; j < names.size(); j++) {
string group = groupMap->getGroup(names[j]);
if (group == "not found") { m->mothurOut("[ERROR]: " + names[j] + " is not in your groupfile. please correct."); m->mothurOutEndLine(); group = "NOTFOUND"; }
else{
- if (groupCounts[group] < size) { subset.insert(names[j]); }
+ itGroupCounts = groupCounts.find(group);
+ if (itGroupCounts != groupCounts.end()) {
+ if (groupCounts[group] < size) { subset.insert(names[j]); groupCounts[group]++; }
+ }
}
}
}else {
if (persample) {
//initialize counts
map<string, int> groupCounts;
+ map<string, int>::iterator itGroupCounts;
for (int i = 0; i < Groups.size(); i++) { groupCounts[Groups[i]] = 0; }
for (int j = 0; j < names.size(); j++) {
string group = groupMap->getGroup(names[j]);
if (group == "not found") { m->mothurOut("[ERROR]: " + names[j] + " is not in your groupfile. please correct."); m->mothurOutEndLine(); group = "NOTFOUND"; }
else{
- if (groupCounts[group] < size) { subset.insert(names[j]); }
+ itGroupCounts = groupCounts.find(group);
+ if (itGroupCounts != groupCounts.end()) {
+ if (groupCounts[group] < size) { subset.insert(names[j]); groupCounts[group]++; }
+ }
}
}
}else{