]> git.donarmstrong.com Git - mothur.git/blobdiff - groupmap.cpp
fixed bug in libshuff
[mothur.git] / groupmap.cpp
index 6521128016900efe90b8f85b82a808f9f8791709..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++;
                        }
@@ -85,6 +87,24 @@ bool GroupMap::isValidGroup(string groupname) {
                exit(1);
        }
 }
+/************************************************************/
+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(){