X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=summarycommand.cpp;h=1e0e8dbc552a872df3fe591d15ea378db3316959;hb=3aa0b70bf057656ccc2bae1de9816583f2a91779;hp=d68d00ac6258e0ac10346ce5b67b7d10a2de7495;hpb=26b30b0881a37665b18746d2851607c494e8ccc0;p=mothur.git diff --git a/summarycommand.cpp b/summarycommand.cpp index d68d00a..1e0e8db 100644 --- a/summarycommand.cpp +++ b/summarycommand.cpp @@ -506,52 +506,64 @@ string SummaryCommand::createGroupSummaryFile(int numLines, int numCols, vector< //open each groups summary file string newLabel = ""; - ifstream* temp; - map filehandles; + map > files; for (int i=0; iopenInputFile(outputNames[i], *(temp)); + vector thisFilesLines; + + ifstream temp; + m->openInputFile(outputNames[i], temp); //read through first line - labels string tempLabel; if (i == 0) { //we want to save the labels to output below for (int j = 0; j < numCols+1; j++) { - *(temp) >> tempLabel; + temp >> tempLabel; if (j == 1) { newLabel += "group\t" + tempLabel + '\t'; }else{ newLabel += tempLabel + '\t'; } } - }else{ for (int j = 0; j < numCols+1; j++) { *(temp) >> tempLabel; } } + }else{ for (int j = 0; j < numCols+1; j++) { temp >> tempLabel; } } + + m->gobble(temp); + + //for each label + for (int k = 0; k < numLines; k++) { + + string thisLine = ""; + string tempLabel; + + for (int j = 0; j < numCols+1; j++) { + temp >> tempLabel; + + //save for later + if (j == 1) { thisLine += groups[i] + "\t" + tempLabel + "\t"; } + else{ thisLine += tempLabel + "\t"; } + } + + thisLine += "\n"; + + thisFilesLines.push_back(thisLine); + + m->gobble(temp); + } + + files[outputNames[i]] = thisFilesLines; - m->gobble(*(temp)); + temp.close(); } //output label line to new file out << newLabel << endl; //for each label - for (int i = 0; i < numLines; i++) { + for (int k = 0; k < numLines; k++) { //grab summary data for each group for (int i=0; i> tempLabel; - - //print to combined file - if (j == 1) { out << groups[i] << '\t' << tempLabel << '\t'; } - else{ out << tempLabel << '\t'; } - } - - out << endl; - m->gobble(*(filehandles[outputNames[i]])); + out << files[outputNames[i]][k]; } } - //close each groups summary file - for (int i=0; i