X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=counttable.cpp;h=005ab8a2846bcd95dc40d1bf1d9b86325deb5e85;hb=c7e8c2d15bd7cedcfdf18675cb0ea1a0dcd0e3c0;hp=a664228b17c35fff4ce48ca0ea5255b5b99bb1f3;hpb=28bcfc4a41b8b82f66636587e0d4d355d07cbdd1;p=mothur.git diff --git a/counttable.cpp b/counttable.cpp index a664228..005ab8a 100644 --- a/counttable.cpp +++ b/counttable.cpp @@ -174,6 +174,75 @@ int CountTable::get(string seqName) { exit(1); } } +/************************************************************/ +//add seqeunce without group info +int CountTable::push_back(string seqName) { + try { + map::iterator it = indexNameMap.find(seqName); + if (it == indexNameMap.end()) { + if (hasGroups) { m->mothurOut("[ERROR]: Your count table has groups and I have no group information for " + seqName + "."); m->mothurOutEndLine(); m->control_pressed = true; } + indexNameMap[seqName] = uniques; + totals.push_back(1); + total++; + uniques++; + }else { + m->mothurOut("[ERROR]: Your count table contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine(); m->control_pressed = true; + } + + return 0; + } + catch(exception& e) { + m->errorOut(e, "CountTable", "push_back"); + exit(1); + } +} +/************************************************************/ +//add seqeunce without group info +int CountTable::push_back(string seqName, int thisTotal) { + try { + map::iterator it = indexNameMap.find(seqName); + if (it == indexNameMap.end()) { + if (hasGroups) { m->mothurOut("[ERROR]: Your count table has groups and I have no group information for " + seqName + "."); m->mothurOutEndLine(); m->control_pressed = true; } + indexNameMap[seqName] = uniques; + totals.push_back(thisTotal); + total+=thisTotal; + uniques++; + }else { + m->mothurOut("[ERROR]: Your count table contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine(); m->control_pressed = true; + } + + return 0; + } + catch(exception& e) { + m->errorOut(e, "CountTable", "push_back"); + exit(1); + } +} +/************************************************************/ +//add sequence with group info +int CountTable::push_back(string seqName, vector groupCounts) { + try { + map::iterator it = indexNameMap.find(seqName); + if (it == indexNameMap.end()) { + if ((hasGroups) && (groupCounts.size() != getNumGroups())) { m->mothurOut("[ERROR]: Your count table has a " + toString(getNumGroups()) + " groups and " + seqName + " has " + toString(groupCounts.size()) + ", please correct."); m->mothurOutEndLine(); m->control_pressed = true; } + int thisTotal = 0; + for (int i = 0; i < getNumGroups(); i++) { totalGroups[i] += groupCounts[i]; thisTotal += groupCounts[i]; } + indexNameMap[seqName] = uniques; + totals.push_back(thisTotal); + total+= thisTotal; + uniques++; + }else { + m->mothurOut("[ERROR]: Your count table contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine(); m->control_pressed = true; + } + + return 0; + } + catch(exception& e) { + m->errorOut(e, "CountTable", "push_back"); + exit(1); + } +} + /************************************************************/ //create ListVector from uniques ListVector CountTable::getListVector() {