]> git.donarmstrong.com Git - mothur.git/blobdiff - removegroupscommand.cpp
adding labels to list file.
[mothur.git] / removegroupscommand.cpp
index 4f4b1580582b953c3b8318acc68345cc8d45ae48..9db35cb4bcb1fb78daa9545ecf4464b29c09d2e2 100644 (file)
@@ -355,11 +355,19 @@ int RemoveGroupsCommand::execute(){
                        
                        //make sure groups are valid
                        //takes care of user setting groupNames that are invalid or setting groups=all
-                       SharedUtil* util = new SharedUtil();
                        vector<string> namesGroups = groupMap->getNamesOfGroups();
-                       util->setGroups(Groups, namesGroups);
-                       delete util;
-                       
+                       vector<string> checkedGroups;
+            for (int i = 0; i < Groups.size(); i++) {
+                if (m->inUsersGroups(Groups[i], namesGroups)) { checkedGroups.push_back(Groups[i]); }
+                else {  m->mothurOut("[WARNING]: " + Groups[i] + " is not a valid group in your groupfile, ignoring.\n"); }
+            }
+            
+            if (checkedGroups.size() == 0) { m->mothurOut("[ERROR]: no valid groups, aborting.\n"); delete groupMap; return 0; }
+                       else {
+                Groups = checkedGroups;
+                m->setGroups(Groups);
+            }
+            
                        //fill names with names of sequences that are from the groups we want to remove 
                        fillNames();
                        
@@ -369,7 +377,7 @@ int RemoveGroupsCommand::execute(){
                 m->mothurOut("\n[NOTE]: The count file should contain only unique names, so mothur assumes your fasta, list and taxonomy files also contain only uniques.\n\n");
             }
             CountTable ct;
-            ct.readTable(countfile);
+            ct.readTable(countfile, true, false);
             if (!ct.hasGroupInfo()) { m->mothurOut("[ERROR]: your count file does not contain group info, aborting.\n"); return 0; }
             
             vector<string> gNamesOfGroups = ct.getNamesOfGroups();
@@ -552,9 +560,9 @@ int RemoveGroupsCommand::readShared(){
                m->setGroups(groupsToKeep);
                m->clearAllGroups();
                m->saveNextLabel = "";
-               m->printedHeaders = false;
-               m->currentBinLabels.clear();
-               m->binLabelsInFile.clear();
+               m->printedSharedHeaders = false;
+               m->currentSharedBinLabels.clear();
+               m->sharedBinLabelsInFile.clear();
                
                InputData input(sharedfile, "sharedfile");
                lookup = input.getSharedRAbundVectors();