X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getgroupscommand.cpp;h=84b168a4c75164b339b7ed2b6f350d13021da5e4;hb=9bc68cbe7fd7c5cf00b66d73d60624de80fb7933;hp=1832f96aed8122020b5ddf0ad5881275e3cc6481;hpb=5694c92fbf646fe01abc87bde2af59e14a9a56b6;p=mothur.git diff --git a/getgroupscommand.cpp b/getgroupscommand.cpp index 1832f96..84b168a 100644 --- a/getgroupscommand.cpp +++ b/getgroupscommand.cpp @@ -27,8 +27,7 @@ vector GetGroupsCommand::getValidParameters(){ //********************************************************************************************************************** GetGroupsCommand::GetGroupsCommand(){ try { - abort = true; - //initialize outputTypes + abort = true; calledHelp = true; vector tempOutNames; outputTypes["fasta"] = tempOutNames; outputTypes["taxonomy"] = tempOutNames; @@ -67,10 +66,10 @@ vector GetGroupsCommand::getRequiredFiles(){ //********************************************************************************************************************** GetGroupsCommand::GetGroupsCommand(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 @@ -207,8 +206,8 @@ void GetGroupsCommand::help(){ m->mothurOut("You must also provide an accnos containing the list of groups to get or set the groups parameter to the groups you wish to select.\n"); m->mothurOut("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"); m->mothurOut("The get.groups command should be in the following format: get.groups(accnos=yourAccnos, fasta=yourFasta, group=yourGroupFile).\n"); - m->mothurOut("Example get.seqs(accnos=amazon.accnos, fasta=amazon.fasta, group=amazon.groups).\n"); - m->mothurOut("or get.seqs(groups=pasture, fasta=amazon.fasta, amazon.groups).\n"); + m->mothurOut("Example get.groups(accnos=amazon.accnos, fasta=amazon.fasta, group=amazon.groups).\n"); + m->mothurOut("or get.groups(groups=pasture, fasta=amazon.fasta, group=amazon.groups).\n"); m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n"); } catch(exception& e) { @@ -222,7 +221,7 @@ void GetGroupsCommand::help(){ int GetGroupsCommand::execute(){ try { - if (abort == true) { return 0; } + if (abort == true) { if (calledHelp) { return 0; } return 2; } groupMap = new GroupMap(groupfile); groupMap->readMap(); @@ -251,14 +250,43 @@ int GetGroupsCommand::execute(){ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } m->mothurOut("Selected " + 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) { m->mothurOutEndLine(); 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;