]> git.donarmstrong.com Git - mothur.git/blobdiff - counttable.cpp
changes while testing 1.26
[mothur.git] / counttable.cpp
index c4e2732e8554cd81a934af7f2ee3bfcff7705db6..7f08509897f0765823b4e2e7b65f837809821c45 100644 (file)
@@ -173,5 +173,37 @@ vector<string> CountTable::getNamesOfSeqs() {
        }
 }
 /************************************************************/
+//returns names of seqs
+int CountTable::mergeCounts(string seq1, string seq2) {
+    try {
+        map<string, int>::iterator it = indexNameMap.find(seq1);
+        if (it == indexNameMap.end()) {
+            m->mothurOut("[ERROR]: " + seq1 + " is not in your count table. Please correct.\n"); m->control_pressed = true;
+        }else { 
+            map<string, int>::iterator it2 = indexNameMap.find(seq2);
+            if (it2 == indexNameMap.end()) {
+                m->mothurOut("[ERROR]: " + seq2 + " is not in your count table. Please correct.\n"); m->control_pressed = true;
+            }else { 
+                //merge data
+                for (int i = 0; i < groups.size(); i++) {
+                    counts[it->second][i] += counts[it2->second][i];
+                    counts[it2->second][i] = 0;
+                }
+                totals[it->second] += totals[it2->second];
+                totals[it2->second] = 0;
+                uniques--;
+                indexNameMap.erase(it2); 
+            }
+        }
+        
+        return 0;
+    }
+       catch(exception& e) {
+               m->errorOut(e, "CountTable", "getNamesOfSeqs");
+               exit(1);
+       }
+}
+
+/************************************************************/