X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=counttable.cpp;fp=counttable.cpp;h=7f08509897f0765823b4e2e7b65f837809821c45;hb=1f3d51cfdbe3e28c780501b7ed82d64fe27dba98;hp=c4e2732e8554cd81a934af7f2ee3bfcff7705db6;hpb=fdfbfe59134dd7dd3e49d90609d129128ba2d370;p=mothur.git diff --git a/counttable.cpp b/counttable.cpp index c4e2732..7f08509 100644 --- a/counttable.cpp +++ b/counttable.cpp @@ -173,5 +173,37 @@ vector CountTable::getNamesOfSeqs() { } } /************************************************************/ +//returns names of seqs +int CountTable::mergeCounts(string seq1, string seq2) { + try { + map::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::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); + } +} + +/************************************************************/