5 // Created by Sarah Westcott on 6/26/12.
6 // Copyright (c) 2012 Schloss Lab. All rights reserved.
9 #include "counttable.h"
11 /************************************************************/
12 int CountTable::createTable(set<string>& n, map<string, string>& g, set<string>& gs) {
17 indexGroupMap.clear();
20 for (set<string>::iterator it = gs.begin(); it != gs.end(); it++) { groups.push_back(*it); hasGroups = true; }
21 numGroups = groups.size();
22 totalGroups.resize(numGroups, 0);
24 //sort groups to keep consistent with how we store the groups in groupmap
25 sort(groups.begin(), groups.end());
26 for (int i = 0; i < groups.size(); i++) { indexGroupMap[groups[i]] = i; }
27 m->setAllGroups(groups);
31 for (set<string>::iterator it = n.begin(); it != n.end(); it++) {
33 if (m->control_pressed) { break; }
37 vector<int> groupCounts; groupCounts.resize(numGroups, 0);
38 map<string, string>::iterator itGroup = g.find(seqName);
40 if (itGroup != g.end()) {
41 groupCounts[indexGroupMap[itGroup->second]] = 1;
42 totalGroups[indexGroupMap[itGroup->second]]++;
43 }else { m->mothurOut("[ERROR]: Your group file does not contain " + seqName + ". Please correct."); m->mothurOutEndLine(); }
45 map<string, int>::iterator it2 = indexNameMap.find(seqName);
46 if (it2 == indexNameMap.end()) {
47 if (hasGroups) { counts.push_back(groupCounts); }
48 indexNameMap[seqName] = uniques;
56 for (int i = 0; i < totalGroups.size(); i++) {
57 if (totalGroups[i] == 0) { m->mothurOut("\nRemoving group: " + groups[i] + " because all sequences have been removed.\n"); removeGroup(groups[i]); i--; }
64 m->errorOut(e, "CountTable", "createTable");
68 /************************************************************/
69 bool CountTable::testGroups(string file) {
71 m = MothurOut::getInstance(); hasGroups = false; total = 0;
73 m->openInputFile(file, in);
75 string headers = m->getline(in); m->gobble(in);
76 vector<string> columnHeaders = m->splitWhiteSpace(headers);
77 if (columnHeaders.size() > 2) { hasGroups = true; }
81 m->errorOut(e, "CountTable", "readTable");
85 /************************************************************/
86 int CountTable::createTable(string namefile, string groupfile, bool createGroup) {
89 if (namefile == "") { m->mothurOut("[ERROR]: namefile cannot be blank when creating a count table.\n"); m->control_pressed = true; }
95 indexGroupMap.clear();
98 map<int, string> originalGroupIndexes;
100 if (groupfile != "") {
102 groupMap = new GroupMap(groupfile); groupMap->readMap();
103 numGroups = groupMap->getNumGroups();
104 groups = groupMap->getNamesOfGroups();
105 totalGroups.resize(numGroups, 0);
106 }else if(createGroup) {
109 groups.push_back("Group1");
110 totalGroups.resize(numGroups, 0);
112 //sort groups to keep consistent with how we store the groups in groupmap
113 sort(groups.begin(), groups.end());
114 for (int i = 0; i < groups.size(); i++) { indexGroupMap[groups[i]] = i; }
115 m->setAllGroups(groups);
125 m->openInputFile(namefile, in);
129 if (m->control_pressed) { break; }
131 string firstCol, secondCol;
132 in >> firstCol; m->gobble(in); in >> secondCol; m->gobble(in);
134 m->checkName(firstCol);
135 m->checkName(secondCol);
137 vector<string> names;
138 m->splitAtChar(secondCol, names, ',');
140 map<string, int> groupCounts;
142 if (groupfile != "") {
144 for (int i = 0; i < groups.size(); i++) { groupCounts[groups[i]] = 0; }
146 //get counts for each of the users groups
147 for (int i = 0; i < names.size(); i++) {
148 string group = groupMap->getGroup(names[i]);
150 if (group == "not found") { m->mothurOut("[ERROR]: " + names[i] + " is not in your groupfile, please correct."); m->mothurOutEndLine(); error=true; }
152 map<string, int>::iterator it = groupCounts.find(group);
154 //if not found, then this sequence is not from a group we care about
155 if (it != groupCounts.end()) {
161 }else if (createGroup) {
162 groupCounts["Group1"]=0;
163 for (int i = 0; i < names.size(); i++) {
164 string group = "Group1";
165 groupCounts["Group1"]++; thisTotal++;
167 }else { thisTotal = names.size(); }
169 //if group info, then read it
170 vector<int> thisGroupsCount; thisGroupsCount.resize(numGroups, 0);
171 for (int i = 0; i < numGroups; i++) {
172 thisGroupsCount[i] = groupCounts[groups[i]];
173 totalGroups[i] += thisGroupsCount[i];
176 map<string, int>::iterator it = indexNameMap.find(firstCol);
177 if (it == indexNameMap.end()) {
178 if (hasGroups) { counts.push_back(thisGroupsCount); }
179 indexNameMap[firstCol] = uniques;
180 totals.push_back(thisTotal);
185 m->mothurOut("[ERROR]: Your count table contains more than 1 sequence named " + firstCol + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();
190 if (error) { m->control_pressed = true; }
191 else { //check for zero groups
193 for (int i = 0; i < totalGroups.size(); i++) {
194 if (totalGroups[i] == 0) { m->mothurOut("\nRemoving group: " + groups[i] + " because all sequences have been removed.\n"); removeGroup(groups[i]); i--; }
198 if (groupfile != "") { delete groupMap; }
202 catch(exception& e) {
203 m->errorOut(e, "CountTable", "createTable");
207 /************************************************************/
208 int CountTable::readTable(string file) {
212 m->openInputFile(filename, in);
214 string headers = m->getline(in); m->gobble(in);
215 vector<string> columnHeaders = m->splitWhiteSpace(headers);
220 indexGroupMap.clear();
221 indexNameMap.clear();
223 map<int, string> originalGroupIndexes;
224 if (columnHeaders.size() > 2) { hasGroups = true; numGroups = columnHeaders.size() - 2; }
225 for (int i = 2; i < columnHeaders.size(); i++) { groups.push_back(columnHeaders[i]); originalGroupIndexes[i-2] = columnHeaders[i]; totalGroups.push_back(0); }
226 //sort groups to keep consistent with how we store the groups in groupmap
227 sort(groups.begin(), groups.end());
228 for (int i = 0; i < groups.size(); i++) { indexGroupMap[groups[i]] = i; }
229 m->setAllGroups(groups);
238 if (m->control_pressed) { break; }
240 in >> name; m->gobble(in); in >> thisTotal; m->gobble(in);
241 if (m->debug) { m->mothurOut("[DEBUG]: " + name + '\t' + toString(thisTotal) + "\n"); }
243 //if group info, then read it
244 vector<int> groupCounts; groupCounts.resize(numGroups, 0);
245 for (int i = 0; i < numGroups; i++) { int thisIndex = indexGroupMap[originalGroupIndexes[i]]; in >> groupCounts[thisIndex]; m->gobble(in); totalGroups[thisIndex] += groupCounts[thisIndex]; }
247 map<string, int>::iterator it = indexNameMap.find(name);
248 if (it == indexNameMap.end()) {
249 if (hasGroups) { counts.push_back(groupCounts); }
250 indexNameMap[name] = uniques;
251 totals.push_back(thisTotal);
256 m->mothurOut("[ERROR]: Your count table contains more than 1 sequence named " + name + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();
261 if (error) { m->control_pressed = true; }
262 else { //check for zero groups
264 for (int i = 0; i < totalGroups.size(); i++) {
265 if (totalGroups[i] == 0) { m->mothurOut("\nRemoving group: " + groups[i] + " because all sequences have been removed.\n"); removeGroup(groups[i]); i--; }
272 catch(exception& e) {
273 m->errorOut(e, "CountTable", "readTable");
277 /************************************************************/
278 int CountTable::printTable(string file) {
281 m->openOutputFile(file, out);
282 out << "Representative_Sequence\ttotal\t";
283 for (int i = 0; i < groups.size(); i++) { out << groups[i] << '\t'; }
286 for (map<string, int>::iterator itNames = indexNameMap.begin(); itNames != indexNameMap.end(); itNames++) {
287 out << itNames->first << '\t' << totals[itNames->second] << '\t';
290 for (int i = 0; i < groups.size(); i++) {
291 out << counts[itNames->second][i] << '\t';
299 catch(exception& e) {
300 m->errorOut(e, "CountTable", "printTable");
304 /************************************************************/
305 int CountTable::printHeaders(ofstream& out) {
307 out << "Representative_Sequence\ttotal\t";
308 for (int i = 0; i < groups.size(); i++) { out << groups[i] << '\t'; }
312 catch(exception& e) {
313 m->errorOut(e, "CountTable", "printHeaders");
317 /************************************************************/
318 int CountTable::printSeq(ofstream& out, string seqName) {
320 map<string, int>::iterator it = indexNameMap.find(seqName);
321 if (it == indexNameMap.end()) {
322 m->mothurOut("[ERROR]: " + seqName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
324 out << it->first << '\t' << totals[it->second] << '\t';
326 for (int i = 0; i < groups.size(); i++) {
327 out << counts[it->second][i] << '\t';
334 catch(exception& e) {
335 m->errorOut(e, "CountTable", "printSeq");
339 /************************************************************/
340 //group counts for a seq
341 vector<int> CountTable::getGroupCounts(string seqName) {
345 map<string, int>::iterator it = indexNameMap.find(seqName);
346 if (it == indexNameMap.end()) {
347 m->mothurOut("[ERROR]: " + seqName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
349 temp = counts[it->second];
351 }else{ m->mothurOut("[ERROR]: Your count table does not have group info. Please correct.\n"); m->control_pressed = true; }
355 catch(exception& e) {
356 m->errorOut(e, "CountTable", "getGroupCounts");
360 /************************************************************/
361 //total number of sequences for the group
362 int CountTable::getGroupCount(string groupName) {
365 map<string, int>::iterator it = indexGroupMap.find(groupName);
366 if (it == indexGroupMap.end()) {
367 m->mothurOut("[ERROR]: " + groupName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
369 return totalGroups[it->second];
371 }else{ m->mothurOut("[ERROR]: Your count table does not have group info. Please correct.\n"); m->control_pressed = true; }
375 catch(exception& e) {
376 m->errorOut(e, "CountTable", "getGroupCount");
380 /************************************************************/
381 //total number of sequences for the seq for the group
382 int CountTable::getGroupCount(string seqName, string groupName) {
385 map<string, int>::iterator it = indexGroupMap.find(groupName);
386 if (it == indexGroupMap.end()) {
387 m->mothurOut("[ERROR]: " + groupName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
389 map<string, int>::iterator it2 = indexNameMap.find(seqName);
390 if (it2 == indexNameMap.end()) {
391 m->mothurOut("[ERROR]: " + seqName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
393 return counts[it2->second][it->second];
396 }else{ m->mothurOut("[ERROR]: Your count table does not have group info. Please correct.\n"); m->control_pressed = true; }
400 catch(exception& e) {
401 m->errorOut(e, "CountTable", "getGroupCount");
405 /************************************************************/
406 //set the number of sequences for the seq for the group
407 int CountTable::setAbund(string seqName, string groupName, int num) {
410 map<string, int>::iterator it = indexGroupMap.find(groupName);
411 if (it == indexGroupMap.end()) {
412 m->mothurOut("[ERROR]: " + groupName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
414 map<string, int>::iterator it2 = indexNameMap.find(seqName);
415 if (it2 == indexNameMap.end()) {
416 m->mothurOut("[ERROR]: " + seqName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
418 int oldCount = counts[it2->second][it->second];
419 counts[it2->second][it->second] = num;
420 totalGroups[it->second] += (num - oldCount);
421 total += (num - oldCount);
422 totals[it2->second] += (num - oldCount);
425 }else{ m->mothurOut("[ERROR]: Your count table does not have group info. Please correct.\n"); m->control_pressed = true; }
429 catch(exception& e) {
430 m->errorOut(e, "CountTable", "set");
434 /************************************************************/
436 int CountTable::addGroup(string groupName) {
438 bool sanity = m->inUsersGroups(groupName, groups);
439 if (sanity) { m->mothurOut("[ERROR]: " + groupName + " is already in the count table, cannot add again.\n"); m->control_pressed = true; return 0; }
441 groups.push_back(groupName);
442 if (!hasGroups) { counts.resize(uniques); }
444 for (int i = 0; i < counts.size(); i++) { counts[i].push_back(0); }
445 totalGroups.push_back(0);
446 indexGroupMap[groupName] = groups.size()-1;
447 map<string, int> originalGroupMap = indexGroupMap;
449 //important to play well with others, :)
450 sort(groups.begin(), groups.end());
452 //fix indexGroupMap && totalGroups
453 vector<int> newTotals; newTotals.resize(groups.size(), 0);
454 for (int i = 0; i < groups.size(); i++) {
455 indexGroupMap[groups[i]] = i;
456 //find original spot of group[i]
457 int index = originalGroupMap[groups[i]];
458 newTotals[i] = totalGroups[index];
460 totalGroups = newTotals;
463 for (int i = 0; i < counts.size(); i++) {
464 vector<int> newCounts; newCounts.resize(groups.size(), 0);
465 for (int j = 0; j < groups.size(); j++) {
466 //find original spot of group[i]
467 int index = originalGroupMap[groups[j]];
468 newCounts[j] = counts[i][index];
470 counts[i] = newCounts;
473 m->setAllGroups(groups);
477 catch(exception& e) {
478 m->errorOut(e, "CountTable", "addGroup");
482 /************************************************************/
484 int CountTable::removeGroup(string groupName) {
487 //save for later in case removing a group means we need to remove a seq.
488 map<int, string> reverse;
489 for (map<string, int>::iterator it = indexNameMap.begin(); it !=indexNameMap.end(); it++) { reverse[it->second] = it->first; }
491 map<string, int>::iterator it = indexGroupMap.find(groupName);
492 if (it == indexGroupMap.end()) {
493 m->mothurOut("[ERROR]: " + groupName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
495 int indexOfGroupToRemove = it->second;
496 map<string, int> currentGroupIndex = indexGroupMap;
497 vector<string> newGroups;
498 for (int i = 0; i < groups.size(); i++) {
499 if (groups[i] != groupName) {
500 newGroups.push_back(groups[i]);
501 indexGroupMap[groups[i]] = newGroups.size()-1;
504 indexGroupMap.erase(groupName);
506 totalGroups.erase(totalGroups.begin()+indexOfGroupToRemove);
509 map<string, int> newIndexNameMap;
510 for (int i = 0; i < counts.size(); i++) {
511 int num = counts[i][indexOfGroupToRemove];
512 counts[i].erase(counts[i].begin()+indexOfGroupToRemove);
515 if (totals[i] == 0) { //your sequences are only from the group we want to remove, then remove you.
516 counts.erase(counts.begin()+i);
517 totals.erase(totals.begin()+i);
521 newIndexNameMap[reverse[thisIndex]] = i;
524 indexNameMap = newIndexNameMap;
526 if (groups.size() == 0) { hasGroups = false; }
528 }else { m->mothurOut("[ERROR]: your count table does not contain group information, can not remove group " + groupName + ".\n"); m->control_pressed = true; }
532 catch(exception& e) {
533 m->errorOut(e, "CountTable", "removeGroup");
537 /************************************************************/
538 //vector of groups for the seq
539 vector<string> CountTable::getGroups(string seqName) {
541 vector<string> thisGroups;
543 vector<int> thisCounts = getGroupCounts(seqName);
544 for (int i = 0; i < thisCounts.size(); i++) {
545 if (thisCounts[i] != 0) { thisGroups.push_back(groups[i]); }
547 }else{ m->mothurOut("[ERROR]: Your count table does not have group info. Please correct.\n"); m->control_pressed = true; }
551 catch(exception& e) {
552 m->errorOut(e, "CountTable", "getGroups");
556 /************************************************************/
557 //total number of seqs represented by seq
558 int CountTable::renameSeq(string oldSeqName, string newSeqName) {
561 map<string, int>::iterator it = indexNameMap.find(oldSeqName);
562 if (it == indexNameMap.end()) {
563 m->mothurOut("[ERROR]: " + oldSeqName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
565 int index = it->second;
566 indexNameMap.erase(it);
567 indexNameMap[newSeqName] = index;
572 catch(exception& e) {
573 m->errorOut(e, "CountTable", "renameSeq");
578 /************************************************************/
579 //total number of seqs represented by seq
580 int CountTable::getNumSeqs(string seqName) {
583 map<string, int>::iterator it = indexNameMap.find(seqName);
584 if (it == indexNameMap.end()) {
585 m->mothurOut("[ERROR]: " + seqName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
587 return totals[it->second];
592 catch(exception& e) {
593 m->errorOut(e, "CountTable", "getNumSeqs");
597 /************************************************************/
598 //returns unique index for sequence like get in NameAssignment
599 int CountTable::get(string seqName) {
602 map<string, int>::iterator it = indexNameMap.find(seqName);
603 if (it == indexNameMap.end()) {
604 m->mothurOut("[ERROR]: " + seqName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
605 }else { return it->second; }
609 catch(exception& e) {
610 m->errorOut(e, "CountTable", "get");
614 /************************************************************/
615 //add seqeunce without group info
616 int CountTable::push_back(string seqName) {
618 map<string, int>::iterator it = indexNameMap.find(seqName);
619 if (it == indexNameMap.end()) {
620 if (hasGroups) { m->mothurOut("[ERROR]: Your count table has groups and I have no group information for " + seqName + "."); m->mothurOutEndLine(); m->control_pressed = true; }
621 indexNameMap[seqName] = uniques;
626 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;
631 catch(exception& e) {
632 m->errorOut(e, "CountTable", "push_back");
636 /************************************************************/
638 int CountTable::remove(string seqName) {
640 map<string, int>::iterator it = indexNameMap.find(seqName);
641 if (it != indexNameMap.end()) {
643 if (hasGroups){ //remove this sequences counts from group totals
644 for (int i = 0; i < totalGroups.size(); i++) { totalGroups[i] -= counts[it->second][i]; counts[it->second][i] = 0; }
646 int thisTotal = totals[it->second]; totals[it->second] = 0;
648 indexNameMap.erase(it);
650 m->mothurOut("[ERROR]: Your count table contains does not include " + seqName + ", cannot remove."); m->mothurOutEndLine(); m->control_pressed = true;
655 catch(exception& e) {
656 m->errorOut(e, "CountTable", "push_back");
660 /************************************************************/
661 //add seqeunce without group info
662 int CountTable::push_back(string seqName, int thisTotal) {
664 map<string, int>::iterator it = indexNameMap.find(seqName);
665 if (it == indexNameMap.end()) {
666 if (hasGroups) { m->mothurOut("[ERROR]: Your count table has groups and I have no group information for " + seqName + "."); m->mothurOutEndLine(); m->control_pressed = true; }
667 indexNameMap[seqName] = uniques;
668 totals.push_back(thisTotal);
672 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;
677 catch(exception& e) {
678 m->errorOut(e, "CountTable", "push_back");
682 /************************************************************/
683 //add sequence with group info
684 int CountTable::push_back(string seqName, vector<int> groupCounts) {
686 map<string, int>::iterator it = indexNameMap.find(seqName);
687 if (it == indexNameMap.end()) {
688 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; }
690 for (int i = 0; i < getNumGroups(); i++) { totalGroups[i] += groupCounts[i]; thisTotal += groupCounts[i]; }
691 if (hasGroups) { counts.push_back(groupCounts); }
692 indexNameMap[seqName] = uniques;
693 totals.push_back(thisTotal);
697 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;
702 catch(exception& e) {
703 m->errorOut(e, "CountTable", "push_back");
708 /************************************************************/
709 //create ListVector from uniques
710 ListVector CountTable::getListVector() {
712 ListVector list(indexNameMap.size());
713 for (map<string, int>::iterator it = indexNameMap.begin(); it != indexNameMap.end(); it++) {
714 if (m->control_pressed) { break; }
715 list.set(it->second, it->first);
719 catch(exception& e) {
720 m->errorOut(e, "CountTable", "getListVector");
725 /************************************************************/
726 //returns the names of all unique sequences in file
727 vector<string> CountTable::getNamesOfSeqs() {
729 vector<string> names;
730 for (map<string, int>::iterator it = indexNameMap.begin(); it != indexNameMap.end(); it++) {
731 names.push_back(it->first);
736 catch(exception& e) {
737 m->errorOut(e, "CountTable", "getNamesOfSeqs");
741 /************************************************************/
742 //returns the names of all unique sequences in file mapped to their seqCounts
743 map<string, int> CountTable::getNameMap() {
745 map<string, int> names;
746 for (map<string, int>::iterator it = indexNameMap.begin(); it != indexNameMap.end(); it++) {
747 names[it->first] = totals[it->second];
752 catch(exception& e) {
753 m->errorOut(e, "CountTable", "getNameMap");
757 /************************************************************/
758 //returns the names of all unique sequences in file
759 vector<string> CountTable::getNamesOfSeqs(string group) {
761 vector<string> names;
763 map<string, int>::iterator it = indexGroupMap.find(group);
764 if (it == indexGroupMap.end()) {
765 m->mothurOut("[ERROR]: " + group + " is not in your count table. Please correct.\n"); m->control_pressed = true;
767 for (map<string, int>::iterator it2 = indexNameMap.begin(); it2 != indexNameMap.end(); it2++) {
768 if (counts[it2->second][it->second] != 0) { names.push_back(it2->first); }
771 }else{ m->mothurOut("[ERROR]: Your count table does not have group info. Please correct.\n"); m->control_pressed = true; }
775 catch(exception& e) {
776 m->errorOut(e, "CountTable", "getNamesOfSeqs");
780 /************************************************************/
781 //merges counts of seq1 and seq2, saving in seq1
782 int CountTable::mergeCounts(string seq1, string seq2) {
784 map<string, int>::iterator it = indexNameMap.find(seq1);
785 if (it == indexNameMap.end()) {
786 m->mothurOut("[ERROR]: " + seq1 + " is not in your count table. Please correct.\n"); m->control_pressed = true;
788 map<string, int>::iterator it2 = indexNameMap.find(seq2);
789 if (it2 == indexNameMap.end()) {
790 m->mothurOut("[ERROR]: " + seq2 + " is not in your count table. Please correct.\n"); m->control_pressed = true;
793 for (int i = 0; i < groups.size(); i++) { counts[it->second][i] += counts[it2->second][i]; }
794 totals[it->second] += totals[it2->second];
796 indexNameMap.erase(it2);
801 catch(exception& e) {
802 m->errorOut(e, "CountTable", "getNamesOfSeqs");
806 /************************************************************/
807 int CountTable::copy(CountTable* ct) {
809 vector<string> thisGroups = ct->getNamesOfGroups();
810 for (int i = 0; i < thisGroups.size(); i++) { addGroup(thisGroups[i]); }
811 vector<string> names = ct->getNamesOfSeqs();
813 for (int i = 0; i < names.size(); i++) {
814 vector<int> thisCounts = ct->getGroupCounts(names[i]);
815 push_back(names[i], thisCounts);
820 catch(exception& e) {
821 m->errorOut(e, "CountTable", "copy");
826 /************************************************************/