]> git.donarmstrong.com Git - mothur.git/blobdiff - groupmap.cpp
added rename.seqs command.
[mothur.git] / groupmap.cpp
index 9d2736405f8e306dc8e5238f8bad1a26b92b88bb..9b8aa3f8abc87ef9ff93520a80b3da9169d406f4 100644 (file)
@@ -405,7 +405,66 @@ int GroupMap::getNumSeqs(string group) {
                exit(1);
        }
 }
                exit(1);
        }
 }
-
+/************************************************************/
+int GroupMap::renameSeq(string oldName, string newName) {
+       try {
+               
+               map<string, string>::iterator itName;
+               
+               itName = groupmap.find(oldName);
+               
+               if (itName == groupmap.end()) {
+            m->mothurOut("[ERROR]: cannot find " + toString(oldName) + " in group file");
+            m->control_pressed = true;
+            return 0;
+        }else {
+            string group = itName->second;
+            groupmap.erase(itName);
+            groupmap[newName] = group;
+        }
+        
+        return 0;
+               
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GroupMap", "renameSeq");
+               exit(1);
+       }
+}
+/************************************************************/
+int GroupMap::print(ofstream& out) {
+       try {
+               
+               for (map<string, string>::iterator itName = groupmap.begin(); itName != groupmap.end(); itName++) {
+            out << itName->first << '\t' << itName->second << endl;
+        }
+             
+        return 0;
+               
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GroupMap", "print");
+               exit(1);
+       }
+}
+/************************************************************/
+int GroupMap::print(ofstream& out, vector<string> userGroups) {
+       try {
+               
+               for (map<string, string>::iterator itName = groupmap.begin(); itName != groupmap.end(); itName++) {
+            if (m->inUsersGroups(itName->second, userGroups)) {
+                out << itName->first << '\t' << itName->second << endl;
+            }
+        }
+        
+        return 0;
+               
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GroupMap", "print");
+               exit(1);
+       }
+}
 /************************************************************/
 vector<string> GroupMap::getNamesSeqs(){
        try {
 /************************************************************/
 vector<string> GroupMap::getNamesSeqs(){
        try {