X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=counttable.cpp;h=6eca8ee2a4b5354da54412b9eb6986b6ba244657;hp=48b52d98e76e6da585c862682c3906bdf4ad0f67;hb=df7e3ff9f68ef157b0328a2d353c3258c5d45d89;hpb=79ca496859f48f1c38803c0f7c603faac348fe4c diff --git a/counttable.cpp b/counttable.cpp index 48b52d9..6eca8ee 100644 --- a/counttable.cpp +++ b/counttable.cpp @@ -211,7 +211,7 @@ int CountTable::createTable(string namefile, string groupfile, bool createGroup) } } /************************************************************/ -int CountTable::readTable(string file) { +int CountTable::readTable(string file, bool readGroups) { try { filename = file; ifstream in; @@ -227,7 +227,7 @@ int CountTable::readTable(string file) { indexNameMap.clear(); counts.clear(); map originalGroupIndexes; - if (columnHeaders.size() > 2) { hasGroups = true; numGroups = columnHeaders.size() - 2; } + if ((columnHeaders.size() > 2) && readGroups) { hasGroups = true; numGroups = columnHeaders.size() - 2; } for (int i = 2; i < columnHeaders.size(); i++) { groups.push_back(columnHeaders[i]); originalGroupIndexes[i-2] = columnHeaders[i]; totalGroups.push_back(0); } //sort groups to keep consistent with how we store the groups in groupmap sort(groups.begin(), groups.end()); @@ -248,7 +248,13 @@ int CountTable::readTable(string file) { //if group info, then read it vector groupCounts; groupCounts.resize(numGroups, 0); - for (int i = 0; i < numGroups; i++) { int thisIndex = indexGroupMap[originalGroupIndexes[i]]; in >> groupCounts[thisIndex]; m->gobble(in); totalGroups[thisIndex] += groupCounts[thisIndex]; } + if (columnHeaders.size() > 2) { //file contains groups + if (readGroups) { //user wants to save them + for (int i = 0; i < numGroups; i++) { int thisIndex = indexGroupMap[originalGroupIndexes[i]]; in >> groupCounts[thisIndex]; m->gobble(in); totalGroups[thisIndex] += groupCounts[thisIndex]; } + }else { //read and discard + m->getline(in); m->gobble(in); + } + } map::iterator it = indexNameMap.find(name); if (it == indexNameMap.end()) {