]> git.donarmstrong.com Git - mothur.git/blobdiff - removegroupscommand.cpp
added set.current and get.current commands and modified existing commands to update...
[mothur.git] / removegroupscommand.cpp
index 93646bcf8ad225a3db162dc2cb582cf2f164e481..34a072b30a0b563fd22ddef60099224bdc6bf9f0 100644 (file)
@@ -27,8 +27,7 @@ vector<string> RemoveGroupsCommand::getValidParameters(){
 //**********************************************************************************************************************
 RemoveGroupsCommand::RemoveGroupsCommand(){    
        try {
-               abort = true;
-               //initialize outputTypes
+               abort = true; calledHelp = true; 
                vector<string> tempOutNames;
                outputTypes["fasta"] = tempOutNames;
                outputTypes["taxonomy"] = tempOutNames;
@@ -67,10 +66,10 @@ vector<string> 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();
@@ -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");