2 * removegroupscommand.cpp
5 * Created by westcott on 11/10/10.
6 * Copyright 2010 Schloss Lab. All rights reserved.
10 #include "removegroupscommand.h"
11 #include "sequence.hpp"
12 #include "listvector.hpp"
13 #include "sharedutilities.h"
14 #include "inputdata.h"
16 //**********************************************************************************************************************
17 vector<string> RemoveGroupsCommand::setParameters(){
19 CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
20 CommandParameter pshared("shared", "InputTypes", "", "", "none", "FNGLT-sharedGroup", "none",false,false); parameters.push_back(pshared);
21 CommandParameter pname("name", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pname);
22 CommandParameter pgroup("group", "InputTypes", "", "", "none", "FNGLT-sharedGroup", "none",false,false); parameters.push_back(pgroup);
23 CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(plist);
24 CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(ptaxonomy);
25 CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
26 CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
27 CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
28 CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
30 vector<string> myArray;
31 for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
35 m->errorOut(e, "RemoveGroupsCommand", "setParameters");
39 //**********************************************************************************************************************
40 string RemoveGroupsCommand::getHelpString(){
42 string helpString = "";
43 helpString += "The remove.groups command removes sequences from a specfic group or set of groups from the following file types: fasta, name, group, list, taxonomy or sharedfile.\n";
44 helpString += "It outputs a file containing the sequences NOT in the those specified groups, or with a sharedfile eliminates the groups you selected.\n";
45 helpString += "The remove.groups command parameters are accnos, fasta, name, group, list, taxonomy, shared and groups. The group parameter is required, unless you have a current group file or are using a sharedfile.\n";
46 helpString += "You must also provide an accnos containing the list of groups to remove or set the groups parameter to the groups you wish to remove.\n";
47 helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like removed. You can separate group names with dashes.\n";
48 helpString += "The remove.groups command should be in the following format: remove.groups(accnos=yourAccnos, fasta=yourFasta, group=yourGroupFile).\n";
49 helpString += "Example remove.groups(accnos=amazon.accnos, fasta=amazon.fasta, group=amazon.groups).\n";
50 helpString += "or remove.groups(groups=pasture, fasta=amazon.fasta, amazon.groups).\n";
51 helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
55 m->errorOut(e, "RemoveGroupsCommand", "getHelpString");
60 //**********************************************************************************************************************
61 RemoveGroupsCommand::RemoveGroupsCommand(){
63 abort = true; calledHelp = true;
65 vector<string> tempOutNames;
66 outputTypes["fasta"] = tempOutNames;
67 outputTypes["taxonomy"] = tempOutNames;
68 outputTypes["name"] = tempOutNames;
69 outputTypes["group"] = tempOutNames;
70 outputTypes["list"] = tempOutNames;
71 outputTypes["shared"] = tempOutNames;
74 m->errorOut(e, "RemoveGroupsCommand", "RemoveGroupsCommand");
78 //**********************************************************************************************************************
79 RemoveGroupsCommand::RemoveGroupsCommand(string option) {
81 abort = false; calledHelp = false;
83 //allow user to run help
84 if(option == "help") { help(); abort = true; calledHelp = true; }
85 else if(option == "citation") { citation(); abort = true; calledHelp = true;}
88 vector<string> myArray = setParameters();
90 OptionParser parser(option);
91 map<string,string> parameters = parser.getParameters();
93 ValidParameters validParameter;
94 map<string,string>::iterator it;
96 //check to make sure all parameters are valid for command
97 for (it = parameters.begin(); it != parameters.end(); it++) {
98 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
101 //initialize outputTypes
102 vector<string> tempOutNames;
103 outputTypes["fasta"] = tempOutNames;
104 outputTypes["taxonomy"] = tempOutNames;
105 outputTypes["name"] = tempOutNames;
106 outputTypes["group"] = tempOutNames;
107 outputTypes["list"] = tempOutNames;
108 outputTypes["shared"] = tempOutNames;
111 //if the user changes the output directory command factory will send this info to us in the output parameter
112 outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; }
114 //if the user changes the input directory command factory will send this info to us in the output parameter
115 string inputDir = validParameter.validFile(parameters, "inputdir", false);
116 if (inputDir == "not found"){ inputDir = ""; }
119 it = parameters.find("fasta");
120 //user has given a template file
121 if(it != parameters.end()){
122 path = m->hasPath(it->second);
123 //if the user has not given a path then, add inputdir. else leave path alone.
124 if (path == "") { parameters["fasta"] = inputDir + it->second; }
127 it = parameters.find("accnos");
128 //user has given a template file
129 if(it != parameters.end()){
130 path = m->hasPath(it->second);
131 //if the user has not given a path then, add inputdir. else leave path alone.
132 if (path == "") { parameters["accnos"] = inputDir + it->second; }
135 it = parameters.find("list");
136 //user has given a template file
137 if(it != parameters.end()){
138 path = m->hasPath(it->second);
139 //if the user has not given a path then, add inputdir. else leave path alone.
140 if (path == "") { parameters["list"] = inputDir + it->second; }
143 it = parameters.find("name");
144 //user has given a template file
145 if(it != parameters.end()){
146 path = m->hasPath(it->second);
147 //if the user has not given a path then, add inputdir. else leave path alone.
148 if (path == "") { parameters["name"] = inputDir + it->second; }
151 it = parameters.find("group");
152 //user has given a template file
153 if(it != parameters.end()){
154 path = m->hasPath(it->second);
155 //if the user has not given a path then, add inputdir. else leave path alone.
156 if (path == "") { parameters["group"] = inputDir + it->second; }
159 it = parameters.find("taxonomy");
160 //user has given a template file
161 if(it != parameters.end()){
162 path = m->hasPath(it->second);
163 //if the user has not given a path then, add inputdir. else leave path alone.
164 if (path == "") { parameters["taxonomy"] = inputDir + it->second; }
167 it = parameters.find("shared");
168 //user has given a template file
169 if(it != parameters.end()){
170 path = m->hasPath(it->second);
171 //if the user has not given a path then, add inputdir. else leave path alone.
172 if (path == "") { parameters["shared"] = inputDir + it->second; }
177 //check for required parameters
178 accnosfile = validParameter.validFile(parameters, "accnos", true);
179 if (accnosfile == "not open") { accnosfile = ""; abort = true; }
180 else if (accnosfile == "not found") { accnosfile = ""; }
181 else { m->setAccnosFile(accnosfile); }
183 fastafile = validParameter.validFile(parameters, "fasta", true);
184 if (fastafile == "not open") { fastafile = ""; abort = true; }
185 else if (fastafile == "not found") { fastafile = ""; }
186 else { m->setFastaFile(fastafile); }
188 namefile = validParameter.validFile(parameters, "name", true);
189 if (namefile == "not open") { namefile = ""; abort = true; }
190 else if (namefile == "not found") { namefile = ""; }
191 else { m->setNameFile(namefile); }
193 listfile = validParameter.validFile(parameters, "list", true);
194 if (listfile == "not open") { listfile = ""; abort = true; }
195 else if (listfile == "not found") { listfile = ""; }
196 else { m->setListFile(listfile); }
198 taxfile = validParameter.validFile(parameters, "taxonomy", true);
199 if (taxfile == "not open") { taxfile = ""; abort = true; }
200 else if (taxfile == "not found") { taxfile = ""; }
201 else { m->setTaxonomyFile(taxfile); }
203 groups = validParameter.validFile(parameters, "groups", false);
204 if (groups == "not found") { groups = ""; }
206 m->splitAtDash(groups, Groups);
210 sharedfile = validParameter.validFile(parameters, "shared", true);
211 if (sharedfile == "not open") { sharedfile = ""; abort = true; }
212 else if (sharedfile == "not found") { sharedfile = ""; }
213 else { m->setSharedFile(sharedfile); }
215 groupfile = validParameter.validFile(parameters, "group", true);
216 if (groupfile == "not open") { groupfile = ""; abort = true; }
217 else if (groupfile == "not found") { groupfile = ""; }
218 else { m->setGroupFile(groupfile); }
220 if ((sharedfile == "") && (groupfile == "")) {
221 //is there are current file available for any of these?
222 if ((namefile != "") || (fastafile != "") || (listfile != "") || (taxfile != "")) {
223 //give priority to group, then shared
224 groupfile = m->getGroupFile();
225 if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
227 sharedfile = m->getSharedFile();
228 if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
230 m->mothurOut("You have no current groupfile or sharedfile and one is required."); m->mothurOutEndLine(); abort = true;
234 //give priority to shared, then group
235 sharedfile = m->getSharedFile();
236 if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
238 groupfile = m->getGroupFile();
239 if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
241 m->mothurOut("You have no current groupfile or sharedfile and one is required."); m->mothurOutEndLine(); abort = true;
247 if ((accnosfile == "") && (Groups.size() == 0)) { m->mothurOut("You must provide an accnos file containing group names or specify groups using the groups parameter."); m->mothurOutEndLine(); abort = true; }
249 if ((fastafile == "") && (namefile == "") && (groupfile == "") && (sharedfile == "") && (listfile == "") && (taxfile == "")) { m->mothurOut("You must provide at least one of the following: fasta, name, taxonomy, group, shared or list."); m->mothurOutEndLine(); abort = true; }
250 if ((groupfile == "") && ((namefile != "") || (fastafile != "") || (listfile != "") || (taxfile != ""))) { m->mothurOut("If using a fasta, name, taxonomy, group or list, then you must provide a group file."); m->mothurOutEndLine(); abort = true; }
254 catch(exception& e) {
255 m->errorOut(e, "RemoveGroupsCommand", "RemoveGroupsCommand");
259 //**********************************************************************************************************************
261 int RemoveGroupsCommand::execute(){
264 if (abort == true) { if (calledHelp) { return 0; } return 2; }
266 //get groups you want to remove
267 if (accnosfile != "") { readAccnos(); }
269 if (groupfile != "") {
270 groupMap = new GroupMap(groupfile);
273 //make sure groups are valid
274 //takes care of user setting groupNames that are invalid or setting groups=all
275 SharedUtil* util = new SharedUtil();
276 util->setGroups(Groups, groupMap->namesOfGroups);
279 //fill names with names of sequences that are from the groups we want to remove
285 if (m->control_pressed) { return 0; }
287 //read through the correct file and output lines you want to keep
288 if (namefile != "") { readName(); }
289 if (fastafile != "") { readFasta(); }
290 if (groupfile != "") { readGroup(); }
291 if (listfile != "") { readList(); }
292 if (taxfile != "") { readTax(); }
293 if (sharedfile != "") { readShared(); }
295 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
297 if (outputNames.size() != 0) {
298 m->mothurOutEndLine();
299 m->mothurOut("Output File names: "); m->mothurOutEndLine();
300 for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
301 m->mothurOutEndLine();
303 //set fasta file as new current fastafile
305 itTypes = outputTypes.find("fasta");
306 if (itTypes != outputTypes.end()) {
307 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
310 itTypes = outputTypes.find("name");
311 if (itTypes != outputTypes.end()) {
312 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
315 itTypes = outputTypes.find("group");
316 if (itTypes != outputTypes.end()) {
317 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
320 itTypes = outputTypes.find("list");
321 if (itTypes != outputTypes.end()) {
322 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
325 itTypes = outputTypes.find("taxonomy");
326 if (itTypes != outputTypes.end()) {
327 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
330 itTypes = outputTypes.find("shared");
331 if (itTypes != outputTypes.end()) {
332 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); }
339 catch(exception& e) {
340 m->errorOut(e, "RemoveGroupsCommand", "execute");
345 //**********************************************************************************************************************
346 int RemoveGroupsCommand::readFasta(){
348 string thisOutputDir = outputDir;
349 if (outputDir == "") { thisOutputDir += m->hasPath(fastafile); }
350 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
353 m->openOutputFile(outputFileName, out);
356 m->openInputFile(fastafile, in);
359 bool wroteSomething = false;
360 int removedCount = 0;
363 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
365 Sequence currSeq(in);
366 name = currSeq.getName();
369 //if this name is in the accnos file
370 if (names.count(name) == 0) {
371 wroteSomething = true;
373 currSeq.printSequence(out);
374 }else { removedCount++; }
381 if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine(); }
382 outputTypes["fasta"].push_back(outputFileName); outputNames.push_back(outputFileName);
384 m->mothurOut("Removed " + toString(removedCount) + " sequences from your fasta file."); m->mothurOutEndLine();
389 catch(exception& e) {
390 m->errorOut(e, "RemoveGroupsCommand", "readFasta");
394 //**********************************************************************************************************************
395 int RemoveGroupsCommand::readShared(){
397 string thisOutputDir = outputDir;
398 if (outputDir == "") { thisOutputDir += m->hasPath(sharedfile); }
400 //get group names from sharedfile so we can set Groups to the groupNames we want to keep
401 //that way we can take advantage of the reads in inputdata and sharedRabundVector
402 InputData* tempInput = new InputData(sharedfile, "sharedfile");
403 vector<SharedRAbundVector*> lookup = tempInput->getSharedRAbundVectors();
406 vector<string> allGroupsNames = m->namesOfGroups;
407 vector<string> mothurOutGroups = m->Groups;
409 vector<string> groupsToKeep;
410 for (int i = 0; i < allGroupsNames.size(); i++) {
411 if (!m->inUsersGroups(allGroupsNames[i], m->Groups)) {
412 groupsToKeep.push_back(allGroupsNames[i]);
416 if (allGroupsNames.size() == groupsToKeep.size()) { m->mothurOut("Your file does not contain any groups you wish to remove."); m->mothurOutEndLine(); m->Groups = mothurOutGroups; delete tempInput; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } return 0; }
419 for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
421 m->Groups = groupsToKeep;
422 m->namesOfGroups.clear();
424 m->saveNextLabel = "";
425 m->printedHeaders = false;
426 m->currentBinLabels.clear();
427 m->binLabelsInFile.clear();
429 InputData input(sharedfile, "sharedfile");
430 lookup = input.getSharedRAbundVectors();
432 bool wroteSomething = false;
434 while(lookup[0] != NULL) {
436 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + lookup[0]->getLabel() + ".pick" + m->getExtension(sharedfile);
438 m->openOutputFile(outputFileName, out);
439 outputTypes["shared"].push_back(outputFileName); outputNames.push_back(outputFileName);
441 if (m->control_pressed) { out.close(); m->mothurRemove(outputFileName); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } return 0; }
443 lookup[0]->printHeaders(out);
445 for (int i = 0; i < lookup.size(); i++) {
446 out << lookup[i]->getLabel() << '\t' << lookup[i]->getGroup() << '\t';
447 lookup[i]->print(out);
448 wroteSomething = true;
452 //get next line to process
453 //prevent memory leak
454 for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
455 lookup = input.getSharedRAbundVectors();
461 m->Groups = mothurOutGroups;
463 if (wroteSomething == false) { m->mothurOut("Your file contains only the groups you wish to remove."); m->mothurOutEndLine(); }
465 string groupsString = "";
466 for (int i = 0; i < Groups.size()-1; i++) { groupsString += Groups[i] + ", "; }
467 groupsString += Groups[Groups.size()-1];
469 m->mothurOut("Removed groups: " + groupsString + " from your shared file."); m->mothurOutEndLine();
474 catch(exception& e) {
475 m->errorOut(e, "RemoveGroupsCommand", "readShared");
479 //**********************************************************************************************************************
480 int RemoveGroupsCommand::readList(){
482 string thisOutputDir = outputDir;
483 if (outputDir == "") { thisOutputDir += m->hasPath(listfile); }
484 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" + m->getExtension(listfile);
487 m->openOutputFile(outputFileName, out);
490 m->openInputFile(listfile, in);
492 bool wroteSomething = false;
493 int removedCount = 0;
499 //read in list vector
502 //make a new list vector
504 newList.setLabel(list.getLabel());
507 for (int i = 0; i < list.getNumBins(); i++) {
508 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
510 //parse out names that are in accnos file
511 string binnames = list.get(i);
513 string newNames = "";
514 while (binnames.find_first_of(',') != -1) {
515 string name = binnames.substr(0,binnames.find_first_of(','));
516 binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
518 //if that name is in the .accnos file, add it
519 if (names.count(name) == 0) { newNames += name + ","; }
520 else { removedCount++; }
524 if (names.count(binnames) == 0) { newNames += binnames + ","; }
525 else { removedCount++; }
527 //if there are names in this bin add to new list
528 if (newNames != "") {
529 newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
530 newList.push_back(newNames);
534 //print new listvector
535 if (newList.getNumBins() != 0) {
536 wroteSomething = true;
545 if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine(); }
546 outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName);
548 m->mothurOut("Removed " + toString(removedCount) + " sequences from your list file."); m->mothurOutEndLine();
553 catch(exception& e) {
554 m->errorOut(e, "RemoveGroupsCommand", "readList");
558 //**********************************************************************************************************************
559 int RemoveGroupsCommand::readName(){
561 string thisOutputDir = outputDir;
562 if (outputDir == "") { thisOutputDir += m->hasPath(namefile); }
563 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
566 m->openOutputFile(outputFileName, out);
569 m->openInputFile(namefile, in);
570 string name, firstCol, secondCol;
572 bool wroteSomething = false;
573 int removedCount = 0;
576 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
578 in >> firstCol; m->gobble(in);
581 vector<string> parsedNames;
582 m->splitAtComma(secondCol, parsedNames);
584 vector<string> validSecond; validSecond.clear();
585 for (int i = 0; i < parsedNames.size(); i++) {
586 if (names.count(parsedNames[i]) == 0) {
587 validSecond.push_back(parsedNames[i]);
591 removedCount += parsedNames.size()-validSecond.size();
593 //if the name in the first column is in the set then print it and any other names in second column also in set
594 if (names.count(firstCol) == 0) {
596 wroteSomething = true;
598 out << firstCol << '\t';
600 //you know you have at least one valid second since first column is valid
601 for (int i = 0; i < validSecond.size()-1; i++) { out << validSecond[i] << ','; }
602 out << validSecond[validSecond.size()-1] << endl;
604 //make first name in set you come to first column and then add the remaining names to second column
607 //you want part of this row
608 if (validSecond.size() != 0) {
610 wroteSomething = true;
612 out << validSecond[0] << '\t';
614 //you know you have at least one valid second since first column is valid
615 for (int i = 0; i < validSecond.size()-1; i++) { out << validSecond[i] << ','; }
616 out << validSecond[validSecond.size()-1] << endl;
625 if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine(); }
626 outputTypes["name"].push_back(outputFileName); outputNames.push_back(outputFileName);
628 m->mothurOut("Removed " + toString(removedCount) + " sequences from your name file."); m->mothurOutEndLine();
632 catch(exception& e) {
633 m->errorOut(e, "RemoveGroupsCommand", "readName");
638 //**********************************************************************************************************************
639 int RemoveGroupsCommand::readGroup(){
641 string thisOutputDir = outputDir;
642 if (outputDir == "") { thisOutputDir += m->hasPath(groupfile); }
643 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
646 m->openOutputFile(outputFileName, out);
649 m->openInputFile(groupfile, in);
652 bool wroteSomething = false;
653 int removedCount = 0;
656 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
658 in >> name; //read from first column
659 in >> group; //read from second column
661 //if this name is in the accnos file
662 if (names.count(name) == 0) {
663 wroteSomething = true;
664 out << name << '\t' << group << endl;
665 }else { removedCount++; }
672 if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine(); }
673 outputTypes["group"].push_back(outputFileName); outputNames.push_back(outputFileName);
675 m->mothurOut("Removed " + toString(removedCount) + " sequences from your group file."); m->mothurOutEndLine();
680 catch(exception& e) {
681 m->errorOut(e, "RemoveGroupsCommand", "readGroup");
685 //**********************************************************************************************************************
686 int RemoveGroupsCommand::readTax(){
688 string thisOutputDir = outputDir;
689 if (outputDir == "") { thisOutputDir += m->hasPath(taxfile); }
690 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
692 m->openOutputFile(outputFileName, out);
695 m->openInputFile(taxfile, in);
698 bool wroteSomething = false;
699 int removedCount = 0;
702 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
704 in >> name; //read from first column
705 in >> tax; //read from second column
707 //if this name is in the accnos file
708 if (names.count(name) == 0) {
709 wroteSomething = true;
710 out << name << '\t' << tax << endl;
711 }else { removedCount++; }
718 if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine(); }
719 outputTypes["taxonomy"].push_back(outputFileName); outputNames.push_back(outputFileName);
721 m->mothurOut("Removed " + toString(removedCount) + " sequences from your taxonomy file."); m->mothurOutEndLine();
725 catch(exception& e) {
726 m->errorOut(e, "RemoveGroupsCommand", "readTax");
730 //**********************************************************************************************************************
731 void RemoveGroupsCommand::readAccnos(){
736 m->openInputFile(accnosfile, in);
742 Groups.push_back(name);
751 catch(exception& e) {
752 m->errorOut(e, "RemoveGroupsCommand", "readAccnos");
756 //**********************************************************************************************************************
757 int RemoveGroupsCommand::fillNames(){
759 vector<string> seqs = groupMap->getNamesSeqs();
761 for (int i = 0; i < seqs.size(); i++) {
763 if (m->control_pressed) { return 0; }
765 string group = groupMap->getGroup(seqs[i]);
767 if (m->inUsersGroups(group, Groups)) {
768 names.insert(seqs[i]);
774 catch(exception& e) {
775 m->errorOut(e, "RemoveGroupsCommand", "fillNames");
780 //**********************************************************************************************************************