]> git.donarmstrong.com Git - mothur.git/blobdiff - groupmap.cpp
added otu.association command. added calcSpearman, calcKendall and calcPearson functi...
[mothur.git] / groupmap.cpp
index f6705e53db2048691b95050f3005bdccecf21347..481fd1decfc4516eb5e1cf618c6b4d40cffbc8a9 100644 (file)
@@ -44,6 +44,7 @@ int GroupMap::readMap() {
                        m->gobble(fileHandle);
                }
                fileHandle.close();
+               m->setAllGroups(namesOfGroups);
                return error;
 }
 /************************************************************/
@@ -69,6 +70,7 @@ int GroupMap::readDesignMap() {
                        m->gobble(fileHandle);
                }
                fileHandle.close();
+               m->setAllGroups(namesOfGroups);
                return error;
 }
 
@@ -89,7 +91,15 @@ string GroupMap::getGroup(string sequenceName) {
 /************************************************************/
 
 void GroupMap::setGroup(string sequenceName, string groupN) {
-       groupmap[sequenceName] = groupN;
+       setNamesOfGroups(groupN);
+       
+       it = groupmap.find(sequenceName);
+       
+       if (it != groupmap.end()) {  m->mothurOut("Your groupfile contains more than 1 sequence named " + sequenceName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
+       else {
+               groupmap[sequenceName] = groupN;        //store data in map
+               seqsPerGroup[groupN]++;  //increment number of seqs in that group
+       }
 }
 
 /************************************************************/
@@ -161,4 +171,25 @@ vector<string> GroupMap::getNamesSeqs(){
        }
 }
 /************************************************************/
+vector<string> GroupMap::getNamesSeqs(vector<string> picked){
+       try {
+               
+               vector<string> names;
+               
+               for (it = groupmap.begin(); it != groupmap.end(); it++) {
+                       //if you are belong to one the the groups in the picked vector add you
+                       if (m->inUsersGroups(it->second, picked)) {
+                               names.push_back(it->first);
+                       }
+               }
+               
+               return names;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GroupMap", "getNamesSeqs");
+               exit(1);
+       }
+}
+
+/************************************************************/