+ m->errorOut(e, "SummaryCommand", "parseSharedFile");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+string SummaryCommand::createGroupSummaryFile(int numLines, int numCols, vector<string>& outputNames) {
+ try {
+
+ ofstream out;
+ string combineFileName = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "groups.summary";
+
+ //open combined file
+ m->openOutputFile(combineFileName, out);
+
+ //open each groups summary file
+ string newLabel = "";
+ map<string, vector<string> > files;
+ for (int i=0; i<outputNames.size(); i++) {
+ vector<string> 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;
+
+ if (j == 1) { newLabel += "group\t" + tempLabel + '\t';
+ }else{ newLabel += tempLabel + '\t'; }
+ }
+ }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;
+
+ temp.close();
+ remove(outputNames[i].c_str());
+ }
+
+ //output label line to new file
+ out << newLabel << endl;
+
+ //for each label
+ for (int k = 0; k < numLines; k++) {
+
+ //grab summary data for each group
+ for (int i=0; i<outputNames.size(); i++) {
+ out << files[outputNames[i]][k];
+ }
+ }
+
+ outputNames.clear();
+
+ out.close();
+
+ //return combine file name
+ return combineFileName;
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SummaryCommand", "createGroupSummaryFile");