]> git.donarmstrong.com Git - mothur.git/blobdiff - groupmap.cpp
added set.dir command and modified commands to redirect input and output, removed...
[mothur.git] / groupmap.cpp
index b627a6bda6e3fa63de073a4b3f6c20bee7a2a680..598e301648978ab642274edb69ffa41bbea6f205 100644 (file)
@@ -21,8 +21,9 @@
  GroupMap::~GroupMap(){}
 
 /************************************************************/
-void GroupMap::readMap() {
+int GroupMap::readMap() {
                string seqName, seqGroup;
+               int error = 0;
        
                while(fileHandle){
                        fileHandle >> seqName;                  //read from first column
@@ -30,12 +31,17 @@ void GroupMap::readMap() {
                        
                        setNamesOfGroups(seqGroup);
                        
-                       groupmap[seqName] = seqGroup;   //store data in map
-                       seqsPerGroup[seqGroup]++;  //increment number of seqs in that group
-               
+                       it = groupmap.find(seqName);
+                       
+                       if (it != groupmap.end()) { error = 1; mothurOut("Your groupfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); mothurOutEndLine();  }
+                       else {
+                               groupmap[seqName] = seqGroup;   //store data in map
+                               seqsPerGroup[seqGroup]++;  //increment number of seqs in that group
+                       }
                        gobble(fileHandle);
                }
                fileHandle.close();
+               return error;
 }
 /************************************************************/
 int GroupMap::getNumGroups() { return namesOfGroups.size();    }