]> git.donarmstrong.com Git - mothur.git/blobdiff - groupmap.cpp
added sorted parameter to get.oturep, added error checking to chimera classes in...
[mothur.git] / groupmap.cpp
index 38addc92f41487c3b715c7c7cbb7f03443dda24a..b627a6bda6e3fa63de073a4b3f6c20bee7a2a680 100644 (file)
@@ -29,8 +29,9 @@ void GroupMap::readMap() {
                        fileHandle >> seqGroup;                 //read from second column
                        
                        setNamesOfGroups(seqGroup);
-                                               
+                       
                        groupmap[seqName] = seqGroup;   //store data in map
+                       seqsPerGroup[seqGroup]++;  //increment number of seqs in that group
                
                        gobble(fileHandle);
                }
@@ -67,6 +68,7 @@ void GroupMap::setNamesOfGroups(string seqGroup) {
                        }
                        if (count == namesOfGroups.size()) {
                                namesOfGroups.push_back(seqGroup); //new group
+                               seqsPerGroup[seqGroup] = 0;
                                groupIndex[seqGroup] = index;
                                index++;
                        }
@@ -81,11 +83,45 @@ bool GroupMap::isValidGroup(string groupname) {
                return false;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GroupMap class Function isValidGroup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GroupMap", "isValidGroup");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GroupMap class function isValidGroup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+}
+/************************************************************/
+int GroupMap::getNumSeqs(string group) {
+       try {
+               
+               map<string, int>::iterator itNum;
+               
+               itNum = seqsPerGroup.find(group);
+               
+               if (itNum == seqsPerGroup.end()) { return 0; }
+               
+               return seqsPerGroup[group];
+               
+       }
+       catch(exception& e) {
+               errorOut(e, "GroupMap", "getNumSeqs");
                exit(1);
        }
 }
+
+/************************************************************/
+vector<string> GroupMap::getNamesSeqs(){
+       try {
+       
+               vector<string> names;
+               
+               for (it = groupmap.begin(); it != groupmap.end(); it++) {
+                       names.push_back(it->first);
+               }
+               
+               return names;
+       }
+       catch(exception& e) {
+               errorOut(e, "GroupMap", "getNamesSeqs");
+               exit(1);
+       }
+}
+/************************************************************/
+