]> git.donarmstrong.com Git - mothur.git/blobdiff - groupmap.cpp
fixed bug with realigner for chimera slayer
[mothur.git] / groupmap.cpp
index 0e0be0e8cf2799527e2664bb79b1cdded09e215c..58e04c5db858791f28a99a5cb50795a570da0690 100644 (file)
@@ -44,8 +44,36 @@ int GroupMap::readMap() {
                        m->gobble(fileHandle);
                }
                fileHandle.close();
+               m->namesOfGroups = namesOfGroups;
                return error;
 }
+/************************************************************/
+int GroupMap::readDesignMap() {
+               string seqName, seqGroup;
+               int error = 0;
+
+               while(fileHandle){
+                       fileHandle >> seqName;  m->gobble(fileHandle);          //read from first column
+                       fileHandle >> seqGroup;                 //read from second column
+                       
+                       if (m->control_pressed) {  fileHandle.close();  return 1; }
+       
+                       setNamesOfGroups(seqGroup);
+                       
+                       it = groupmap.find(seqName);
+                       
+                       if (it != groupmap.end()) { error = 1; m->mothurOut("Your designfile contains more than 1 group named " + seqName + ", group names must be unique. Please correct."); m->mothurOutEndLine();  }
+                       else {
+                               groupmap[seqName] = seqGroup;   //store data in map
+                               seqsPerGroup[seqGroup]++;  //increment number of seqs in that group
+                       }
+                       m->gobble(fileHandle);
+               }
+               fileHandle.close();
+               m->namesOfGroups = namesOfGroups;
+               return error;
+}
+
 /************************************************************/
 int GroupMap::getNumGroups() { return namesOfGroups.size();    }
 /************************************************************/
@@ -135,4 +163,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);
+       }
+}
+
+/************************************************************/