From 8977d23b7f18d981b14e59c210c97198541ca7b0 Mon Sep 17 00:00:00 2001 From: westcott Date: Tue, 4 Oct 2011 19:24:17 +0000 Subject: [PATCH] fixed minor issue with sub.sample command. --- countgroupscommand.cpp | 2 +- getgroupscommand.cpp | 9 +++++++++ removegroupscommand.cpp | 9 +++++++++ seqerrorcommand.cpp | 6 +++++- subsamplecommand.cpp | 12 ++++++++++-- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/countgroupscommand.cpp b/countgroupscommand.cpp index 24b4214..0c03882 100644 --- a/countgroupscommand.cpp +++ b/countgroupscommand.cpp @@ -34,7 +34,7 @@ vector CountGroupsCommand::setParameters(){ 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"; diff --git a/getgroupscommand.cpp b/getgroupscommand.cpp index 5021f40..e8f42dd 100644 --- a/getgroupscommand.cpp +++ b/getgroupscommand.cpp @@ -189,6 +189,15 @@ GetGroupsCommand::GetGroupsCommand(string option) { 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 = ""; } diff --git a/removegroupscommand.cpp b/removegroupscommand.cpp index 81722dd..725efaf 100644 --- a/removegroupscommand.cpp +++ b/removegroupscommand.cpp @@ -190,6 +190,15 @@ RemoveGroupsCommand::RemoveGroupsCommand(string option) { 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 = ""; } diff --git a/seqerrorcommand.cpp b/seqerrorcommand.cpp index d3f6282..253e03e 100644 --- a/seqerrorcommand.cpp +++ b/seqerrorcommand.cpp @@ -178,7 +178,11 @@ SeqErrorCommand::SeqErrorCommand(string option) { } 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 = ""; } diff --git a/subsamplecommand.cpp b/subsamplecommand.cpp index 49a8210..24c83fd 100644 --- a/subsamplecommand.cpp +++ b/subsamplecommand.cpp @@ -426,6 +426,7 @@ int SubSampleCommand::getSubSampleFasta() { if (persample) { //initialize counts map groupCounts; + map::iterator itGroupCounts; for (int i = 0; i < Groups.size(); i++) { groupCounts[Groups[i]] = 0; } for (int j = 0; j < names.size(); j++) { @@ -435,7 +436,10 @@ int SubSampleCommand::getSubSampleFasta() { 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 { @@ -1025,6 +1029,7 @@ int SubSampleCommand::getSubSampleList() { if (persample) { //initialize counts map groupCounts; + map::iterator itGroupCounts; for (int i = 0; i < Groups.size(); i++) { groupCounts[Groups[i]] = 0; } for (int j = 0; j < names.size(); j++) { @@ -1034,7 +1039,10 @@ int SubSampleCommand::getSubSampleList() { 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{ -- 2.39.2