X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=removegroupscommand.cpp;h=b70b679b6690b54f8b54ee7c147af71d139735f3;hb=9bc68cbe7fd7c5cf00b66d73d60624de80fb7933;hp=93646bcf8ad225a3db162dc2cb582cf2f164e481;hpb=e3e0858c684c4608d679840024e5095ddc8e2719;p=mothur.git diff --git a/removegroupscommand.cpp b/removegroupscommand.cpp index 93646bc..b70b679 100644 --- a/removegroupscommand.cpp +++ b/removegroupscommand.cpp @@ -27,8 +27,7 @@ vector RemoveGroupsCommand::getValidParameters(){ //********************************************************************************************************************** RemoveGroupsCommand::RemoveGroupsCommand(){ try { - abort = true; - //initialize outputTypes + abort = true; calledHelp = true; vector tempOutNames; outputTypes["fasta"] = tempOutNames; outputTypes["taxonomy"] = tempOutNames; @@ -67,10 +66,10 @@ vector RemoveGroupsCommand::getRequiredFiles(){ //********************************************************************************************************************** RemoveGroupsCommand::RemoveGroupsCommand(string option) { try { - abort = false; + abort = false; calledHelp = false; //allow user to run help - if(option == "help") { help(); abort = true; } + if(option == "help") { help(); abort = true; calledHelp = true; } else { //valid paramters for this command @@ -222,7 +221,7 @@ void RemoveGroupsCommand::help(){ int RemoveGroupsCommand::execute(){ try { - if (abort == true) { return 0; } + if (abort == true) { if (calledHelp) { return 0; } return 2; } groupMap = new GroupMap(groupfile); groupMap->readMap(); @@ -251,7 +250,7 @@ int RemoveGroupsCommand::execute(){ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } m->mothurOut("Removed " + toString(names.size()) + " sequences. From the groups: "); m->mothurOutEndLine(); - for (int i = 0; i < Groups.size(); i++) { m->mothurOut(Groups[i]); m->mothurOutEndLine(); } + for (int i = 0; i < Groups.size(); i++) { m->mothurOut(Groups[i]); m->mothurOut(" contains " + toString(groupMap->getNumSeqs(Groups[i])) + " sequences."); m->mothurOutEndLine(); } m->mothurOutEndLine(); if (outputNames.size() != 0) { @@ -259,6 +258,33 @@ int RemoveGroupsCommand::execute(){ m->mothurOut("Output File names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); + + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } + + itTypes = outputTypes.find("group"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } + } + + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + itTypes = outputTypes.find("taxonomy"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); } + } } return 0; @@ -420,6 +446,7 @@ int RemoveGroupsCommand::readName(){ } } + //if the name in the first column is in the set then print it and any other names in second column also in set if (names.count(firstCol) == 0) { @@ -587,6 +614,8 @@ int RemoveGroupsCommand::fillNames(){ names.insert(seqs[i]); } } + + return 0; } catch(exception& e) { m->errorOut(e, "RemoveGroupsCommand", "fillNames");