X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=subsamplecommand.cpp;h=c352feb099a83879bae9e1aca0f35d5bfe56e691;hb=8dd3c225255d7084e3aff8740aa4f1f1cabb367a;hp=49a821045e122b5097fde092a5845378e21afc60;hpb=65e21482d022d12f7a78a8d436fb51f322603e41;p=mothur.git diff --git a/subsamplecommand.cpp b/subsamplecommand.cpp index 49a8210..c352feb 100644 --- a/subsamplecommand.cpp +++ b/subsamplecommand.cpp @@ -234,7 +234,7 @@ SubSampleCommand::SubSampleCommand(string option) { } string temp = validParameter.validFile(parameters, "size", false); if (temp == "not found"){ temp = "0"; } - convert(temp, size); + m->mothurConvert(temp, size); temp = validParameter.validFile(parameters, "persample", false); if (temp == "not found"){ temp = "f"; } persample = m->isTrue(temp); @@ -255,6 +255,10 @@ SubSampleCommand::SubSampleCommand(string option) { if ((groupfile != "") && ((fastafile != "") && (listfile != ""))) { m->mothurOut("A new group file can only be made from the subsample of a listfile or fastafile, not both. Please correct."); m->mothurOutEndLine(); abort = true; } + if ((fastafile != "") && (namefile == "")) { + vector files; files.push_back(fastafile); + parser.getNameFile(files); + } } } @@ -426,6 +430,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 +440,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 +1033,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 +1043,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{